- 注册时间
- 2011-3-6
- 最后登录
- 1970-1-1
该用户从未签到
|
楼主 |
发表于 2011-3-29 08:52:35
|
显示全部楼层
我自己写了一段代码,为什么只对一个窗口有效,当双开以上就不好使呢?窗口标题不样的时候好使
var
Form1: TForm1;
Nhwnd:HWND;
implementation
{$R *.dfm}
function EnumWinProc(Wnd : HWND; form1 : TForm1) : Boolean; Export; {$IFDEF Win32}StdCall;{$ENDIF}
var
WinText : Array[0..255] of Char;
begin
GetWindowText(Wnd, WinText, 255);
Result := True;
if (StrPas(WinText) = 'Element Client') then
Form1.CheckListBox1.Items.Add(StrPas(WinText));
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
EnumWindows(@EnumWinProc, LongInt(Self));
end;
procedure TForm1.CheckListBox1ClickCheck(Sender: TObject);
begin
if checklistbox1.Checked[checklistbox1.ItemIndex]=true then
begin
Nhwnd:=findwindow(NIL,pchar(Checklistbox1.Items[Checklistbox1.ItemIndex])); //转到选中窗口
ShowWindow(Nhwnd,Sw_Hide);
end else
begin
Nhwnd:=findwindow(NIL,pchar(Checklistbox1.Items[Checklistbox1.ItemIndex])); //转到选中窗口
ShowWindow(Nhwnd,sw_SHOW);
end;
end;
end. |
|