界面库

优化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.parent := self;
FCalender.Visible := false;
FScreenRect := _wapi.GetScreenRect();
//FScreenRect := _wapi.GetScreenRect();
decodedate(date(),y,m,d);
setDate(y,m,d);
FCalender.onSelect := function(o,e)begin
@ -4067,10 +4067,12 @@ type tdatetimepicker = class(tthreeEntry)
if FCalender.Visible = nv then return FCalender.show(0);
rc := ClientRect;
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
nrc[1]:= nrc[0]-height-FCalender.height-2;
end
nrc := ClientToScreen(rc[0],rc[1]-FCalender.height);
end
FCalender.Left := nrc[0];
FCalender.top := nrc[1];
dt := getDate();
@ -4114,7 +4116,7 @@ type tdatetimepicker = class(tthreeEntry)
ti := strtointdef(t,1);
return ti;
end
FScreenRect;
//FScreenRect;
FCalender;
[weakref]Fonselectchange;
end

View File

@ -21,12 +21,24 @@ uses uwindowsinterface;
4. 下面的external函数的win32api可以在msdn中查找具体用法
**}
public
function GetScreenRect();
function GetScreenRect(p);
begin
{**
@explan(说明) 获取屏幕大小%%
@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();
SystemParametersInfoA(0x30,0,rc._getptr_(),0);
return rc._getdata_();

View File

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

View File

@ -4055,7 +4055,7 @@ type TCustomComboBoxbase=class(TCustomControl)
inherited;
FBtnWidth := 20;
FmaxListItemShow := 10;
FScreenRect := _wapi.GetScreenRect();
//FScreenRect := _wapi.GetScreenRect();
FListBox := CreateAlist();
if FListBox is class(TWinControl)then
begin
@ -4164,24 +4164,24 @@ type TCustomComboBoxbase=class(TCustomControl)
**}
if not(FListBox is class(TWinControl))then return;
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]);
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
nrc[2]:= width+nrc[0];
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
FListBox.SetBoundsRect(nrc);
nrc := ClientToScreen(rc[0],rc[1]-h);
end
FListBox.Width := Width;
FListBox.left := nrc[0];
FListBox.top := nrc[1];
end
FListBox;
private
FmaxListItemShow;
FScreenRect; //×ÀÃæÇøÓò
//FScreenRect; //×ÀÃæÇøÓò
FBtnRect; //按钮区域
weakref
FOnSelchanged; //选择改变

View File

@ -248,6 +248,8 @@ type twindowsapi = class()
//¶¨Ê±Æ÷
//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 GetDpiForWindow(hwnd:pointer):integer;stdcall;external "User32.dll" name "GetDpiForWindow";
function GetMonitorInfoA(hMonitor:pointer;lpmi:pointer):integer;stdcall;external "User32.dll" name "GetMonitorInfoA";
@ -725,10 +727,10 @@ begin
begin
g_windows_proc_handle := makeinstance(thisfunction(tslvclproc));
end
try
{try
SetProcessDpiAwareness(2); //shez dpi¸ÐÖª
except
end
end }
end
function uninit();//Ð¶ÔØ
begin