parent
f82cbcfd8d
commit
73bd2e82d3
|
|
@ -366,6 +366,8 @@ type TTslDebuga=class(TCustomControl)
|
|||
Fdbgsybs;
|
||||
Fdbgstack;
|
||||
fdefaultdbger; //编辑器的调试器
|
||||
fpopediterhandle;
|
||||
fcurrentgroundwindow;
|
||||
type tdbgwnd=class(TPanel)
|
||||
uses tslvcl;
|
||||
function Create(AOwner);
|
||||
|
|
@ -812,6 +814,7 @@ type TTslDebuga=class(TCustomControl)
|
|||
//font := ms[1];
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
function addbreak(item,idx,n); //添加断点
|
||||
begin
|
||||
|
|
@ -835,6 +838,29 @@ type TTslDebuga=class(TCustomControl)
|
|||
end
|
||||
end
|
||||
function GetWindowHandleByPID(dwProcessID,api) //通过进程ID获取窗口句柄
|
||||
begin
|
||||
h := api.GetTopWindow(0);
|
||||
while(h) do
|
||||
begin
|
||||
pid := 0;
|
||||
dwTheardId := api.GetWindowThreadProcessId(h,pid);
|
||||
|
||||
if(dwTheardId <> 0) and (pid=dwProcessID) then
|
||||
begin
|
||||
cni := 100;
|
||||
cn := "";setlength(cn,cni);
|
||||
cno := api.GetClassNameA(h,cn,cni);
|
||||
if cno >1 then
|
||||
begin
|
||||
cn := cn[1:cni];
|
||||
if pos("tsui_application",cn) then return h;
|
||||
end
|
||||
end
|
||||
h := api.GetNextWindow(h,2);
|
||||
end
|
||||
return 0;
|
||||
end
|
||||
{function GetWindowHandleByPID2(dwProcessID,api) //ͨ¹ý½ø³ÌID»ñÈ¡´°¿Ú¾ä±ú
|
||||
begin
|
||||
h := api.GetTopWindow(0);
|
||||
while(h) do
|
||||
|
|
@ -853,7 +879,7 @@ type TTslDebuga=class(TCustomControl)
|
|||
h := api.GetNextWindow(h,2);
|
||||
end
|
||||
return 0;
|
||||
end
|
||||
end}
|
||||
function dbgtooldorun(o,e);
|
||||
begin
|
||||
if not(FConnectchannel or FRemoteWait) then
|
||||
|
|
@ -866,16 +892,13 @@ type TTslDebuga=class(TCustomControl)
|
|||
ExecuteCommand("dbgrun");
|
||||
{$ifdef linux}
|
||||
{$else}
|
||||
if not Fdebugedwhandle then
|
||||
Fdebugedwhandle := GetWindowHandleByPID(_wapi.GetProcessId(fdebugproc.Handle),_wapi);
|
||||
if Fdebugedwhandle then
|
||||
begin
|
||||
//echo "\r\nSetForegroundWindow===>",Fdebugedwhandle;
|
||||
//_wapi.ShowWindow(Fdebugedwhandle,SW_SHOW);
|
||||
_wapi.SetForegroundWindow(Fdebugedwhandle);
|
||||
//_wapi.PostMessageA(Fdebugedwhandle,WM_ACTIVATEAPP,1,systhreadid());
|
||||
//_wapi.SetActiveWindow(Fdebugedwhandle);
|
||||
//_wapi.SendMessageA(Fdebugedwhandle,WM_ACTIVATEAPP,true,systhreadid());
|
||||
//if not Fdebugedwhandle then
|
||||
// Fdebugedwhandle := GetWindowHandleByPID(_wapi.GetProcessId(fdebugproc.Handle),_wapi);
|
||||
fcurrentgroundwindow := GetWindowHandleByPID(_wapi.GetProcessId(fdebugproc.Handle),_wapi);
|
||||
fdoforegroundflag := true;
|
||||
if fcurrentgroundwindow then
|
||||
begin
|
||||
_wapi.SetForegroundWindow(fcurrentgroundwindow);
|
||||
end
|
||||
{$endif}
|
||||
end
|
||||
|
|
@ -999,7 +1022,7 @@ type TTslDebuga=class(TCustomControl)
|
|||
end
|
||||
"DebugInfo": //调试信息
|
||||
begin
|
||||
if "dbgdetach"=remotewaitinit(d)then return;
|
||||
if "dbgdetach"=remotewaitinit(d)then return;
|
||||
stk := magicgetarray(d,array("result","CmdData","CallStack")); //深度
|
||||
if fremotedbugstart then
|
||||
begin
|
||||
|
|
@ -1054,7 +1077,7 @@ type TTslDebuga=class(TCustomControl)
|
|||
FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",stk[0,"LINE"]-1);
|
||||
end
|
||||
end
|
||||
_wapi.SetForegroundWindow(self.Handle); //ÒÆ¶¯µ½Ç°¶Ë SetForegroundWindow BringWindowToTop
|
||||
_wapi.ForegroundWindow(geteditorhandle());
|
||||
return;
|
||||
end
|
||||
"detached":
|
||||
|
|
@ -1350,6 +1373,23 @@ type TTslDebuga=class(TCustomControl)
|
|||
end
|
||||
//property rundirect read Frundirect write Frundirect;
|
||||
private
|
||||
function geteditorhandle();
|
||||
begin
|
||||
if not fpopediterhandle then
|
||||
begin
|
||||
o := Owner;
|
||||
while o do
|
||||
begin
|
||||
if o.WSpOPUp then
|
||||
begin
|
||||
fpopediterhandle := o.Handle;
|
||||
break;
|
||||
end
|
||||
o :=o.parent;
|
||||
end
|
||||
end
|
||||
return fpopediterhandle;
|
||||
end
|
||||
function getgtkdisplay(); //去掉try
|
||||
begin
|
||||
dsp := Sysgetenv("DISPLAY");
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ type tapplication=class(tcomponent)
|
|||
{**
|
||||
@explan(说明) active处理
|
||||
**}
|
||||
//echo "\r\nactiveapp:",e.wparam;
|
||||
if Fmainform then
|
||||
begin
|
||||
if e.wparam then
|
||||
|
|
|
|||
|
|
@ -2708,6 +2708,16 @@ type tsgtkapi = class(tgtkapis)
|
|||
end
|
||||
function BringWindowToTop(hwd :pointer);
|
||||
begin
|
||||
end
|
||||
function GetWindowHandleByPID();
|
||||
begin
|
||||
|
||||
end
|
||||
function AllowSetForegroundWindow(hwd :pointer);
|
||||
begin
|
||||
end
|
||||
function ForegroundWindow(hwnd);
|
||||
begin
|
||||
end
|
||||
//socket
|
||||
function socket(af:integer;tp:integer;protocol:integer):pointer;begin end
|
||||
|
|
|
|||
|
|
@ -267,11 +267,32 @@ type twindowsapi = class()
|
|||
function RegisterClassExA(wc:pointer):short;stdcall;external "User32.dll" name "RegisterClassExA";
|
||||
function EnableWindow(wc:pointer;b:integer):integer;stdcall;external "User32.dll" name "EnableWindow";
|
||||
//´°¿Ú²Ù×÷
|
||||
|
||||
function ForegroundWindow(wnd_);
|
||||
begin
|
||||
if not (wnd_>0 or wnd_<0) then return 0;
|
||||
SetWindowPos(wnd_, 0xFFFFFFFF, 0, 0, 0, 0, 1 .| 2);
|
||||
SetWindowPos(wnd_, 0xFFFFFFFE, 0, 0, 0, 0, 1 .| 2);
|
||||
return 1;
|
||||
hForeWnd := GetForegroundWindow();
|
||||
if wnd_ = hForeWnd then return 0;
|
||||
dwForeID := GetWindowThreadProcessId(hForeWnd, 0);
|
||||
dwCurID := systhreadid();
|
||||
if dwForeID = dwCurID then return 0;
|
||||
AttachThreadInput(dwCurID, dwForeID, TRUE);
|
||||
ShowWindow(wnd_, 1);
|
||||
SetWindowPos(wnd_, 0xFFFFFFFF, 0, 0, 0, 0, 1 .| 2);
|
||||
SetWindowPos(wnd_, 0xFFFFFFFE, 0, 0, 0, 0, 1 .| 2);
|
||||
//echo "\r\n brt editor:",SetForegroundWindow(wnd_);
|
||||
AttachThreadInput(dwCurID, dwForeID, FALSE);
|
||||
end
|
||||
function AttachThreadInput(idattach:integer;idattachto:integer;fattach:integer):integer;stdcall;external "User32.dll" name "AttachThreadInput";
|
||||
function ShowWindow(hwd :pointer;f:integer):integer;stdcall;external "User32.dll" name "ShowWindow";
|
||||
function BringWindowToTop(hwd :pointer):integer;stdcall;external "User32.dll" name "BringWindowToTop";
|
||||
function SetForegroundWindow(hwd :pointer):integer;stdcall;external "User32.dll" name "SetForegroundWindow";
|
||||
function AllowSetForegroundWindow(hwd :integer):integer;stdcall;external "User32.dll" name "AllowSetForegroundWindow";
|
||||
function SetWindowPos(wd:pointer;hWndInsertAfter:pointer;
|
||||
X:integer; Y:integer; cx:integer;cy:integer; uFlags:integer):pointer;stdcall;external "User32.dll" name "SetWindowPos";
|
||||
X:integer; Y:integer; cx:integer;cy:integer; uFlags:integer):integer;stdcall;external "User32.dll" name "SetWindowPos";
|
||||
function MoveWindow(wd:pointer; X:integer; Y:integer; cx:integer;cy:integer; bRepaint:integer):pointer;stdcall;external "User32.dll" name "MoveWindow";
|
||||
//´°¿Ú´óС
|
||||
function GetClientRect(hwnd :pointer;var rec:array of integer):integer;stdcall;external "User32.dll" name "GetClientRect";
|
||||
|
|
@ -309,7 +330,7 @@ type twindowsapi = class()
|
|||
{$ENDIF}
|
||||
//function SetWindowLongA(HH:pointer;idx:integer;dwNewLong:pointer):pointer;stdcall;external "User32.dll" name "SetWindowLongA";
|
||||
//function GetWindowLongA(HH:pointer;idx:integer):pointer;stdcall;external "User32.dll" name "GetWindowLongA";
|
||||
function GetClassNameA(HH:pointer;var name:string;len:integer):pointer;stdcall;external "User32.dll" name "GetClassNameA";
|
||||
function GetClassNameA(HH:pointer;var name:string;len:integer):integer;stdcall;external "User32.dll" name "GetClassNameA";
|
||||
function CreateWindowExA(dwExStyle:integer; lpClassName:string; lpWindowName:string;
|
||||
dwStyle:integer;x:integer;y:integer;nWidth:integer;nHeight:integer;
|
||||
hWndParent:pointer;hMenu:pointer; hInstance:pointer;lpParam:pointer):pointer;stdcall;external "User32.dll" name "CreateWindowExA";
|
||||
|
|
|
|||
Loading…
Reference in New Issue