列舉當前開啟的所有視窗

2021-06-16 01:05:18 字數 2569 閱讀 5644

四、主要實現**:

初始化部分(全域性):

hwnd hwnd;

hwnd m_hwndfind[100] = ;

int m_num = 0 ;

tchar m_store[max_path];

tchar m_name[max_path];

tchar m_strclass[max_path];

tchar m_filepath[max_path];

tchar m_filename[24];

列舉處理的**:

ctime year,day,month,hour,minute,second;

cstdiofile fp;

ctime current = ctime::getcurrenttime();

year = current.getyear();

month = current.getmonth();

day = current.getday();

sprintf(m_filename,"%4d%02d%02d.txt",year,month,day);

::getmodulefilename(null,m_filepath,max_path);

(_tcsrchr(m_filepath,'/'))[1] = 0;

//sprintf(m_filename,"info%d.txt",rand());

strcat(m_filepath,"info/");

trycatch(...)

{}try

catch(...)

{}strcat(m_filepath,m_filename);

if((fp.open(m_filepath,cfile::modecreate | cfile::modenotruncate | cfile::modereadwrite))==0)

return;

cbutton *button = (cbutton*)getdlgitem(idc_btn_start);

if(button)

//enable reset button

cbutton *button2 = (cbutton *)getdlgitem(idc_btn_reset);

if(button2)

//enumerate windows by enumwindowproc function

::enumwindows(cemutewindowsdlg::enumwindowsproc,null);

//add the title of the window in listbox

for(int i = 0;i <=m_num;i++)

while(nidfirst != ::getdlgctrlid(hwnd));

sprintf(m_name,"(%d)標題名稱:",i);

strcat(m_name,m_store);

strcat(m_name,"      類名稱:");

strcat(m_name,m_strclass);

m_strlist.addstring(m_name);

fp.seektoend();

fp.writestring(m_name);

fp.writestring("");

}fp.seektoend();

fp.writestring("");

hour = current.gethour();

minute=current.getminute();

second = current.getsecond();

sprintf(m_filepath,"********************%02d時%02d分%02d秒寫入***********************",hour,minute,second);

fp.writestring(m_filepath);

fp.writestring("");

fp.close();

重新列舉處理:

cbutton *button  = (cbutton *)getdlgitem(idc_btn_start);

if(button)

//disable reset button

cbutton *button2  = (cbutton *)getdlgitem(idc_btn_reset);

if(button2)

m_strlist.resetcontent();//reset the listbox content

m_num = 0;//reset the count 

列舉視窗控制代碼的函式:

在標頭檔案中宣告為:

static bool callback enumwindowsproc(hwnd hwnd, lparam lparam);

實現部分:

bool cemutewindowsdlg::enumwindowsproc(hwnd hwnd, lparam lparam)

return 1;

}除錯環境:

win2000 adv server + vc6.0 + vsp5.0

windows列舉所有視窗

目錄 列舉所有視窗,根據視窗的標題進行處理 列舉所有視窗,根據視窗的類進行處理 include include bool callback enumwindowsproc hwnd hwnd,lparam lparam getwindowtext hwnd,sztitle,max path wpri...

CTreeCtrl 中列舉系統中的所有視窗! I

本文將給出乙個源程式 在乙個對話方塊中的treectrl中用樹的形式列舉視窗 這是標頭檔案 winlist.h header file cwinlist dialog class cwinlist public cdialog ctreectrl m tree afx data overrides ...

IDEA開啟視窗的數量及開啟視窗的排列方式調整

在我們專案的開發過程中,由於專案涉及的類過多,以至於我們會開啟很多的視窗。使用idea預設的配置,個人覺的十分不便。但我們可以對視窗的排列方式和開啟視窗的排列方式進行設定。預設設定為一行展示所有視窗,視窗數量限制10個 修改idea編譯器展示頁面,使其能夠堆疊顯示,不在橫著一排 預設的設定為在一行顯...