如何取得另一个可执行程序(多文档)的子窗口(子文档窗口)内控件并发消息给控件:急急急--救救我

解决方案 »

  1.   

    先用 Finwindow 找到Desktop窗口句柄(98下通常是0x00000080),所有窗口都是它的子窗口(如你有SPY++会看得很清楚),调用GetWindow()选GW_CHILD 可得其子窗口,选GW_HWNDNEXT或调用GetNextWindow()可得其平级下一窗口,作一递归函数既可得到所有窗口句柄;再用FindWindowEx就可以得到其控件句柄.
      

  2.   

    运用API函数 GetWindow() 配合 GetWindowText() 逐一查出各视窗的标题1. File | New Project 开始一个新的工程2. 在 Form1 中安排 Button 与 Memo 各一3. 在 Button1 的 OnClick 事件中撰写程式如下:procedure TForm1.Button1Click(Sender: TObject);varhCurrentWindow: HWnd;szText: array[0..254] of char;beginhCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);while hCurrentWindow <> 0 dobeginif GetWindowText(hCurrentWindow, @szText, 255) > 0 thenMemo1.Lines.Add(StrPas(@szText));hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);end;end;