界面库

优化windows下多屏幕大小的计算
This commit is contained in:
JianjunLiu 2023-11-08 11:49:57 +08:00
parent e084664fff
commit 7406cfb299
5 changed files with 39 additions and 24 deletions

View File

@ -3953,7 +3953,7 @@ type tdatetimepicker = class(tthreeEntry)
FCalender.WsPopUp := true; FCalender.WsPopUp := true;
FCalender.parent := self; FCalender.parent := self;
FCalender.Visible := false; FCalender.Visible := false;
FScreenRect := _wapi.GetScreenRect(); //FScreenRect := _wapi.GetScreenRect();
decodedate(date(),y,m,d); decodedate(date(),y,m,d);
setDate(y,m,d); setDate(y,m,d);
FCalender.onSelect := function(o,e)begin FCalender.onSelect := function(o,e)begin
@ -4067,9 +4067,11 @@ type tdatetimepicker = class(tthreeEntry)
if FCalender.Visible = nv then return FCalender.show(0); if FCalender.Visible = nv then return FCalender.show(0);
rc := ClientRect; rc := ClientRect;
nrc := ClientToScreen(rc[0],rc[3]); nrc := ClientToScreen(rc[0],rc[3]);
if FScreenRect[3]-nrc[1]<200 then p2 := clienttoscreen(rc[0],rc[1]+FCalender.height);
src := _wapi.GetScreenRect(nrc);
if (src[3]<p2[1]) then //由于缩放问题暂时屏蔽
begin begin
nrc[1]:= nrc[0]-height-FCalender.height-2; nrc := ClientToScreen(rc[0],rc[1]-FCalender.height);
end end
FCalender.Left := nrc[0]; FCalender.Left := nrc[0];
FCalender.top := nrc[1]; FCalender.top := nrc[1];
@ -4114,7 +4116,7 @@ type tdatetimepicker = class(tthreeEntry)
ti := strtointdef(t,1); ti := strtointdef(t,1);
return ti; return ti;
end end
FScreenRect; //FScreenRect;
FCalender; FCalender;
[weakref]Fonselectchange; [weakref]Fonselectchange;
end end

View File

@ -21,12 +21,24 @@ uses uwindowsinterface;
4. 下面的external函数的win32api可以在msdn中查找具体用法 4. 下面的external函数的win32api可以在msdn中查找具体用法
**} **}
public public
function GetScreenRect(); function GetScreenRect(p);
begin begin
{** {**
@explan(说明) 获取屏幕大小%% @explan(说明) 获取屏幕大小%%
@return(array) 左上右下 %% @return(array) 左上右下 %%
**} **}
{$ifdef linux}
{$else}
if ifarray(p) then getmonitorrect := true;
{$endif }
if getmonitorrect then
begin
r1 := array(p[0]-2,p[0]+2,p[1]-2,p[1]+2);
mh := MonitorFromRect(r1,2);
info := new TMONITORINFO();
GetMonitorInfoA(mh,info._getptr_);
return info.rcmonitor;
end
rc := new tcrect(); rc := new tcrect();
SystemParametersInfoA(0x30,0,rc._getptr_(),0); SystemParametersInfoA(0x30,0,rc._getptr_(),0);
return rc._getdata_(); return rc._getdata_();

View File

@ -1464,9 +1464,6 @@ type Ttagxform=class(tslcstructureobj)
property edx index 4 read _getvalue_ write _setvalue_; property edx index 4 read _getvalue_ write _setvalue_;
property edy index 5 read _getvalue_ write _setvalue_; property edy index 5 read _getvalue_ write _setvalue_;
end end
implementation
(*
type TMONITORINFO=class(tslcstructureobj) type TMONITORINFO=class(tslcstructureobj)
private private
static SSTRUCT; static SSTRUCT;
@ -1492,6 +1489,8 @@ type TMONITORINFO=class(tslcstructureobj)
property rcwork index "rcwork" read _getvalue_ write _setvalue_; property rcwork index "rcwork" read _getvalue_ write _setvalue_;
property dwflags index "dwflags" read _getvalue_ write _setvalue_; property dwflags index "dwflags" read _getvalue_ write _setvalue_;
end end
implementation
(*
//묏야으,榴檄으 //묏야으,榴檄으
type ttagNMCUSTOMDRAWINFO=class(tslcstructureobj) type ttagNMCUSTOMDRAWINFO=class(tslcstructureobj)

View File

@ -4055,7 +4055,7 @@ type TCustomComboBoxbase=class(TCustomControl)
inherited; inherited;
FBtnWidth := 20; FBtnWidth := 20;
FmaxListItemShow := 10; FmaxListItemShow := 10;
FScreenRect := _wapi.GetScreenRect(); //FScreenRect := _wapi.GetScreenRect();
FListBox := CreateAlist(); FListBox := CreateAlist();
if FListBox is class(TWinControl)then if FListBox is class(TWinControl)then
begin begin
@ -4164,24 +4164,24 @@ type TCustomComboBoxbase=class(TCustomControl)
**} **}
if not(FListBox is class(TWinControl))then return; if not(FListBox is class(TWinControl))then return;
rc := ClientRect; rc := ClientRect;
FListbox.height := getlistitemheight()* (min(max(0,getlistitemcount()),FmaxListItemShow))+10; h := getlistitemheight()* (min(max(0,getlistitemcount()),FmaxListItemShow))+10;
FListbox.height := h;
nrc := ClientToScreen(rc[0],rc[3]); nrc := ClientToScreen(rc[0],rc[3]);
if FScreenRect[3]-nrc[1]<250 then src := _wapi.GetScreenRect(nrc);
p2 := clienttoscreen(rc[0],rc[1]+h);
if src[3]<p2[1] then
begin begin
nrc[2]:= width+nrc[0]; nrc := ClientToScreen(rc[0],rc[1]-h);
nrc[3]:= nrc[1]-height;
nrc[1]:= nrc[3]-FListBox.Height;
end else
begin
nrc[2]:= width+nrc[0];
nrc[3]:= FListBox.Height+nrc[1];
end end
FListBox.SetBoundsRect(nrc); FListBox.Width := Width;
FListBox.left := nrc[0];
FListBox.top := nrc[1];
end end
FListBox; FListBox;
private private
FmaxListItemShow; FmaxListItemShow;
FScreenRect; //×ÀÃæÇøÓò //FScreenRect; //×ÀÃæÇøÓò
FBtnRect; //按钮区域 FBtnRect; //按钮区域
weakref weakref
FOnSelchanged; //选择改变 FOnSelchanged; //选择改变

View File

@ -248,6 +248,8 @@ type twindowsapi = class()
//¶¨Ê±Æ÷ //¶¨Ê±Æ÷
//function SetClassLongA(hWnd:pointer; nIDEvent:pointer):integer;stdcall;external "User32.dll" name " SetClassLongA"; //function SetClassLongA(hWnd:pointer; nIDEvent:pointer):integer;stdcall;external "User32.dll" name " SetClassLongA";
function MonitorFromRect(rec :array of integer;dwFlags:integer):pointer;stdcall;external "User32.dll" name "MonitorFromRect";
function MonitorFromPoint(rec:pointer;dwFlags:integer):pointer;stdcall;external "User32.dll" name "MonitorFromPoint";
function GetDpiFromDpiAwarenessContext(v:pointer):integer;stdcall;external "User32.dll" name "GetDpiFromDpiAwarenessContext"; function GetDpiFromDpiAwarenessContext(v:pointer):integer;stdcall;external "User32.dll" name "GetDpiFromDpiAwarenessContext";
function GetDpiForWindow(hwnd:pointer):integer;stdcall;external "User32.dll" name "GetDpiForWindow"; function GetDpiForWindow(hwnd:pointer):integer;stdcall;external "User32.dll" name "GetDpiForWindow";
function GetMonitorInfoA(hMonitor:pointer;lpmi:pointer):integer;stdcall;external "User32.dll" name "GetMonitorInfoA"; function GetMonitorInfoA(hMonitor:pointer;lpmi:pointer):integer;stdcall;external "User32.dll" name "GetMonitorInfoA";
@ -725,10 +727,10 @@ begin
begin begin
g_windows_proc_handle := makeinstance(thisfunction(tslvclproc)); g_windows_proc_handle := makeinstance(thisfunction(tslvclproc));
end end
try {try
SetProcessDpiAwareness(2); //shez dpi¸ÐÖª SetProcessDpiAwareness(2); //shez dpi¸ÐÖª
except except
end end }
end end
function uninit();//Ð¶ÔØ function uninit();//Ð¶ÔØ
begin begin