首页 > 代码库 > Delphi FindowWindow,FindowWindowEx
Delphi FindowWindow,FindowWindowEx
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) btnFindWindow: TButton; btnFindWindowEx: TButton; procedure btnFindWindowClick(Sender: TObject); procedure btnFindWindowExClick(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.btnFindWindowClick(Sender: TObject);var hNotepad : HWND;begin //Find Window hNotepad := FindWindow(‘Notepad‘,nil); ShowMessage(format(‘Notepad HWND:$%x‘,[hNotepad]));end;procedure TForm1.btnFindWindowExClick(Sender: TObject);var p : pchar; hNotepad,hEdit : HWND;begin GetMem(p,255); hNotepad := FindWindow(‘Notepad‘,nil); // ClassName, WindowName hEdit := FindWindowEx(hNotepad,0,‘Edit‘,nil); //ShowMessageFmt(‘Edit handle: $%x‘,[hEdit]); //GetWindowText(hEdit, p, 255); //此函数不能取得 Edit中的文本,但可以取得窗口标题 SendMessage(hEdit,WM_GETTEXT,255,Integer(p)); ShowMessage(p); FreeMem(p);end;end.
Delphi FindowWindow,FindowWindowEx
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。