Windows Z order 里有许多不可见窗体,尤其是对于MDI窗口,他们的GetWindowText将返回空。可以递归来获取其内子窗体的标题内容。procedure TForm1.Button1Click(Sender: TObject);
var
pstr:pchar;
hwndcurrent:integer;
begin
getmem(pstr,255);
hwndcurrent:=GetNextWindow(application.handle,GW_HWNDNEXT);
GetWindowText(hwndcurrent,pstr,255);
edit1.Text :=strpas(pstr) ;
hwndcurrent:=GetNextWindow(hwndcurrent,GW_HWNDNEXT);
GetWindowText(hwndcurrent,pstr,255);
edit2.Text :=strpas(pstr) ;
。
freemem(pstr);
end;
var
pstr:pchar;
hwndcurrent:integer;
begin
getmem(pstr,255);
hwndcurrent:=GetNextWindow(application.handle,GW_HWNDNEXT);
GetWindowText(hwndcurrent,pstr,255);
edit1.Text :=strpas(pstr) ;
hwndcurrent:=GetNextWindow(hwndcurrent,GW_HWNDNEXT);
GetWindowText(hwndcurrent,pstr,255);
edit2.Text :=strpas(pstr) ;
。
freemem(pstr);
end;
那我要获得当前窗体下面的那个可见窗体应该怎么写?
OldStly : Longword;
begin
Oldstly := GetWindowLong(Handle,GWL_STYLE);//这个handle就是目标窗体的handle ;
if (WS_VISIBLE and OldStly)>1 then 可见
else 不可见;
end;