線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1235
推到 Plurk!
推到 Facebook!

How can I get the list of all opened windows?

 
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-08-28 10:33:56 IP:61.218.xxx.xxx 未訂閱

How can I get the list of all opened windows?

資料來源:http://free.prohosting.com/~cbdn/ Applications such as WinSight 32® shipped in the C Builder package can retrieve the list of all opened windows and show their corresponding class. How can I do this in my own application? 1. Start a new project using File | New Application. 2. Add a ListView. Set its ViewStyle to vsReport. Edit the Columns property and add two columns. The first one will contain the caption and the second one the class of the window. 3. Declare the callback function by inserting the following in your source code:
 
bool CALLBACK EnumWindowsProc(HWND hWnd, TListView *ListView1) 
{ 
    char WindowName[80], ClassName[80]; 
 
    GetWindowText(hWnd, WindowName, 80); 
    GetClassName(hWnd, ClassName, 80); 
 
    TListItem *item; 
    item = ListView1->Items->Add(); 
    item->Caption = WindowName; 
    item->SubItems->Add(ClassName); 
 
    return true; 
}
4. Add a Button. Double-click its OnClick event:
 
void __fastcall TForm1::Button1Click(TObject *Sender) 
{ 
    EnumWindows((WNDENUMPROC)EnumWindowsProc, 
      (LPARAM)ListView1); 
} 
The Win32 API function EnumWindows enumerates each window handle-by-handle until all the windows are finished. Each time a window is checked, the function sends the information the callback function EnumWindowsProc. Once you got the handle of a window, it is easy to get the information. You can use GetWindowText to retrieve the caption and GetClassName to retrieve the class name. C Builder Developer's Network Copyright © Yoto Yotov 聯盟----Visita網站http://www.vista.org.tw ---[ 發問前請先找找舊文章 ]---
sge
一般會員


發表:5
回覆:2
積分:1
註冊:2002-12-19

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-01-16 11:46:09 IP:210.241.xxx.xxx 未訂閱
各位高手前輩請教一下 如果用以上的這個方式得到了另一個視窗內的各個class name, 那我如何去使用它呢?比如說, 我得知另一個視窗有TEdit class,我想對它輸入一下數字,或有一個按鍵TButton,我想按下它,要如何才能作到? 我用::SendMessage(handle,WM_COMMAND,10,123); 可是我不知道這個TEdit的ID, 我用另一個函式 key_event(char)'a',0,0,0)就可以但是很麻煩,一次只能送一個字。 在這討論區上我找不到其它的例子,可能請高手提供個例子或指點指點 請不吝請指教,謝謝
tender
初階會員


發表:23
回覆:90
積分:37
註冊:2002-09-26

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-01-23 18:41:24 IP:211.75.xxx.xxx 未訂閱
可以用GetDlgCtrlID可以取出
系統時間:2024-04-25 9:32:20
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!