X
xinxin0519
Unregistered / Unconfirmed
GUEST, unregistred user!
不好意思,小弟没有分了,小弟遇到一个问题,请各位大侠帮忙。我在自己的程序中打开显示属性,但是我没有办法在程序中从主题切换到设置中去,如果我用sendmessage和postmessage好象没有办法模拟方向键盘的操作。但是可以模拟TAB的操作,原代码如下:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Memo1: TMemo;<br> btn_listwindow: TButton;<br> Button1: TButton;<br> Edit1: TEdit;<br> Label1: TLabel;<br> procedure btn_listwindowClick(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> function EnumChildWndProc(AhWnd:LongInt;<br> AlParam:lParam):boolean;stdcall;<br><br><br>implementation<br><br>{$R *.dfm}<br>function EnumChildWndProc(AhWnd:LongInt;<br> AlParam:lParam):boolean;stdcall;<br><br>var<br><br> WndClassName: array[0..254] of Char;<br> WndCaption: array[0..254] of Char;<br>begin<br> GetClassName(AhWnd,wndClassName,254);<br> GetWindowText(aHwnd,WndCaption,254);<br> with form1.memo1 do<br> begin<br> lines.add( string(wndClassName));<br> lines.add( string(wndCaption));<br> lines.add('-------');<br><br>if (string(WndCaption)='取消') then<br>begin<br> PostMessage(AhWnd,WM_KEYDOWN,VK_TAB,0);//<br> PostMessage(AhWnd,WM_KEYDOWN,VK_right,0);//这个地方 没有办法执行成功,没有反应 <br> end<br><br> end ;<br> result:=true;<br><br>end;<br><br>procedure TForm1.btn_listwindowClick(Sender: TObject);<br><br>var<br> hWnd:LongInt;<br><br>begin<br> memo1.Lines.Clear;<br> Memo1.Lines.Add(Edit1.Text+' 有如下控件类名称');<br> hWnd:=FindWindow(nil,'显示 属性');<br> if hWnd<>0 then<br> begin<br><br> EnumChildWindows(hWnd,@EnumChildWndProc,0);<br> end<br> else MessageBox(self.handle,'没找到该窗口句柄','提示',0);<br>end;<br>end.<br><br>请各位大侠不要嫌分少,谢谢。