active
This commit is contained in:
JianjunLiu 2022-12-22 13:47:45 +08:00
parent 05ae594b93
commit 5c87f678d6
4 changed files with 153 additions and 81 deletions

View File

@ -1073,7 +1073,7 @@ type TFTSLScriptMemo = class(TFTSLScriptcustomMemo)
begin begin
inherited; inherited;
end end
function SetFocus(); function SetFocus();override;
begin begin
global g_script_can_set_not_focus; global g_script_can_set_not_focus;
if g_script_can_set_not_focus then return ; if g_script_can_set_not_focus then return ;

View File

@ -4502,6 +4502,11 @@ type tapplicationwindow=class(TWinControl)
function DoCnNotify(o,e);override; function DoCnNotify(o,e);override;
begin begin
end end
private
function setactivecontrol(ctl);virtual;
begin
end
end end
type TImageListDrawStyle = class() type TImageListDrawStyle = class()

View File

@ -16,6 +16,7 @@ type TWinControl = class(tcontrol)
//__wstylestruct; //样式消息结构体 //__wstylestruct; //样式消息结构体
__clientsize; //客户区大小 __clientsize; //客户区大小
//__oldclientsize; //旧客户区大小 //__oldclientsize; //旧客户区大小
factivated;
FClientleft; FClientleft;
FClientTop; FClientTop;
FClientWdith; FClientWdith;
@ -221,6 +222,7 @@ type TWinControl = class(tcontrol)
nv := v?true:false; nv := v?true:false;
if nv <> FWsPopUp then if nv <> FWsPopUp then
begin begin
factivated := false;
FWsPopUp := nv; FWsPopUp := nv;
if HandleAllocated()then RecreateWnd(); if HandleAllocated()then RecreateWnd();
end end
@ -846,7 +848,14 @@ type TWinControl = class(tcontrol)
end end
function WMACTIVATE(o,e):WM_ACTIVATE;virtual; function WMACTIVATE(o,e):WM_ACTIVATE;virtual;
begin begin
factivated := e.wparam;
CallMessgeFunction(OnActivate,o,e); CallMessgeFunction(OnActivate,o,e);
if e.skip then return ;
defaulthandler(e);
if factivated and ContainsControl(factivecontrol) then
begin
factivecontrol.SetFocus();
end
end end
function GetClientRect();override; function GetClientRect();override;
begin begin
@ -910,6 +919,7 @@ type TWinControl = class(tcontrol)
function WMNCDESTROY(o,e):WM_NCDESTROY;virtual; function WMNCDESTROY(o,e):WM_NCDESTROY;virtual;
begin begin
FHandle := nil; FHandle := nil;
factivated := false;
for i := 0 to FControls.count-1 do for i := 0 to FControls.count-1 do
begin begin
item := FControls[i]; item := FControls[i];
@ -1642,11 +1652,19 @@ type TWinControl = class(tcontrol)
**} **}
if HandleAllocated()then return _wapi.UpdateWindow(self.Handle); if HandleAllocated()then return _wapi.UpdateWindow(self.Handle);
end end
function SetFocus(); function SetFocus();virtual;
begin begin
if HandleAllocated()then if HandleAllocated()then
begin begin
_wapi.SetFocus(self.Handle); r := _wapi.SetFocus(self.Handle);
return r;
end
end
function setactive(); virtual;
begin
if WsPopUp and HandleAllocated() then
begin
_wapi.SetActiveWindow(self.Handle);
end end
end end
function DescendantHwnd(hwnd); function DescendantHwnd(hwnd);
@ -1769,9 +1787,10 @@ type TWinControl = class(tcontrol)
return r; return r;
end end
end end
function ContainsControl(Control:TControl):bool; function ContainsControl(Control_:TControl):bool;//°üº¬¿Ø¼þ
begin begin
while(Control <> nil)and(Control <> Self) do Control := Control.Parent; Control := Control_;
while(Control is class(TWinControl)) and(Control <> Self) do Control := Control.Parent;
return Control=Self; return Control=Self;
end end
function create(owner);override; //type_twinctrol function create(owner);override; //type_twinctrol
@ -1824,6 +1843,7 @@ type TWinControl = class(tcontrol)
ImageList := nil; ImageList := nil;
FonSetFocus := nil; FonSetFocus := nil;
FonKillFocus := nil; FonKillFocus := nil;
factivecontrol := nil;
inherited; inherited;
end end
function RecreateWnd();virtual; function RecreateWnd();virtual;
@ -1861,6 +1881,14 @@ type TWinControl = class(tcontrol)
InitializeWnd(); InitializeWnd();
if HandleAllocated()then ControlCreateWnd(); if HandleAllocated()then ControlCreateWnd();
end end
function Notification(ac,op);override;
begin
if op=opRecycling and ac=factivecontrol then
begin
factivecontrol := nil;
end
inherited;
end
protected protected
function drawdesigninggrid(); function drawdesigninggrid();
begin begin
@ -1913,6 +1941,7 @@ type TWinControl = class(tcontrol)
@explan(说明)析构窗口句柄 %% @explan(说明)析构窗口句柄 %%
**} **}
EndModal(); EndModal();
factivated := false;
if HandleAllocated()then if HandleAllocated()then
begin begin
{FTRACKMOUSEEVENT.hwndtrack := handle; {FTRACKMOUSEEVENT.hwndtrack := handle;
@ -2465,7 +2494,7 @@ type TWinControl = class(tcontrol)
MainWndProc(h,WM_NCCREATE,0,0); MainWndProc(h,WM_NCCREATE,0,0);
end end
end end
public //¶ÔÍâproperty published //¶ÔÍâproperty
property MinWidth:natural read FMinWidth write SetMinWidth; property MinWidth:natural read FMinWidth write SetMinWidth;
property MinHeight:natural read FMinHeigt write SetMinHeight; property MinHeight:natural read FMinHeigt write SetMinHeight;
//property MaxWidth:integer read FMaxWidth write SetMaxWidth; //property MaxWidth:integer read FMaxWidth write SetMaxWidth;
@ -2493,6 +2522,7 @@ type TWinControl = class(tcontrol)
property onKillFocus:eventhandler read FonKillFocus write FonKillFocus; property onKillFocus:eventhandler read FonKillFocus write FonKillFocus;
property onSetFocus:eventhandler read FonSetFocus write fonSetFocus; property onSetFocus:eventhandler read FonSetFocus write fonSetFocus;
property oncreated:eventhandler read foncreated write foncreated; property oncreated:eventhandler read foncreated write foncreated;
property ActiveControl read getactivecontrol write setactivecontrol;
private //模态相关 private //模态相关
property Modaling read FModaling; property Modaling read FModaling;
@ -2565,4 +2595,33 @@ type TWinControl = class(tcontrol)
if mu.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut"; if mu.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut";
end end
end end
function setactivecontrol(ctl);virtual;
begin
if WsPopUp then
begin
if factivecontrol = ctl then return ;
if ctl is class(TWinControl) then
begin
factivecontrol := ctl;
if factivated then
begin
ctl.SetFocus();
end
end else
begin
factivecontrol := nil;
end
end else
begin
p := parent ;
if p then return p.ActiveControl := ctl;
end
end
function getactivecontrol();
begin
if WsPopUp then return factivecontrol;
factivecontrol := nil;
end
factivecontrol;
end end

View File

@ -57,9 +57,8 @@ type tsgtkapi = class(tgtkapis)
global G_GTK_WINDOW_ACTIVATE; global G_GTK_WINDOW_ACTIVATE;
if not hwd then return ; if not hwd then return ;
if not GTK_WIDGET(hwd) then return ; if not GTK_WIDGET(hwd) then return ;
if f =0 then if f =0 then //Òþ²Ø
begin begin
if gtk_widget_is_toplevel(hwd) then if gtk_widget_is_toplevel(hwd) then
begin begin
p := GetParent(hwd); p := GetParent(hwd);
@ -67,7 +66,14 @@ type tsgtkapi = class(tgtkapis)
end end
gtk_widget_hide(hwd); gtk_widget_hide(hwd);
end else end else
if f=0xc then if f=0x3 then //×î´ó»¯
begin
if gtk_widget_is_toplevel(hwd) then
begin
gtk_window_maximize(hwd);
end
end else
if f=0xc then //show
begin begin
if gtk_widget_is_toplevel(hwd) then if gtk_widget_is_toplevel(hwd) then
begin begin
@ -80,8 +86,9 @@ type tsgtkapi = class(tgtkapis)
if pp then gtk_window_set_transient_for(hwd,pp); if pp then gtk_window_set_transient_for(hwd,pp);
end end
end end
gtk_widget_show_all(hwd); //gtk_widget_show_all(hwd);
end else gtk_widget_show(hwd);
end else //ÆäËû
begin begin
if gtk_widget_is_toplevel(hwd) then if gtk_widget_is_toplevel(hwd) then
begin begin
@ -3791,7 +3798,8 @@ type tgtkapis = class() //gtk
function gtk_widget_get_window(g:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_widget_get_window(g:pointer):pointer;cdecl;external 'libgtk-3.so';
procedure gtk_window_get_position(g:pointer;var x:integer;var y:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_get_position(g:pointer;var x:integer;var y:integer);cdecl;external 'libgtk-3.so';
function gtk_image_new_from_file(f:string):pointer;cdecl;external 'libgtk-3.so'; function gtk_image_new_from_file(f:string):pointer;cdecl;external 'libgtk-3.so';
procedure gtk_widget_show_all (window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so'; procedure gtk_widget_show_all(window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so';
procedure gtk_window_maximize(window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so';
procedure gtk_widget_show(window:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_show(window:pointer);cdecl;external 'libgtk-3.so';
procedure gtk_widget_show_now(window:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_show_now(window:pointer);cdecl;external 'libgtk-3.so';
procedure gtk_widget_hide(window:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_hide(window:pointer);cdecl;external 'libgtk-3.so';