📄 csdn_文档中心_在 ctreectrl 中枚举系统中的所有窗口!(ii).htm
字号:
width=770></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=770>
<TBODY>
<TR>
<TD bgColor=#f3f9fc height=23 width=10></TD>
<TD bgColor=#f3f9fc>
<MARQUEE onmouseout=this.start() onmouseover=this.stop() scrollAmount=5
scrollDelay=80>
<SCRIPT
src="CSDN_文档中心_在 CTreeCtrl 中枚举系统中的所有窗口!(II).files/marquee.htm"></SCRIPT>
</MARQUEE></TD>
<TD align=right bgColor=#f3f9fc width=101>
<SCRIPT>document.write("<img src=http://count.csdn.net/count/pageview1.asp?columnid=4&itemid=11 border=0 width=0 height=0>");</SCRIPT>
<B>
<SCRIPT language=JavaScript>
<!--
document.ns = navigator.appName == "Netscape"
tmpDate = new Date();
date = tmpDate.getDate();
month= tmpDate.getMonth() + 1 ;
if(document.ns)
{
year1=tmpDate.getYear()
year= year1.toString().substr(1,2);
}
else
year= tmpDate.getYear();
document.write(year);
document.write(".");
document.write(month);
document.write(".");
document.write(date);
// -->
</SCRIPT>
</B> </TD></TR>
<TR bgColor=#999999>
<TD colSpan=3 height=1></TD></TR></TBODY></TABLE>
<TABLE border=0 width=770>
<TBODY>
<TR>
<TD align=middle bgColor=#fafafa class=td1 vAlign=top width=150><BR>
<SCRIPT
src="CSDN_文档中心_在 CTreeCtrl 中枚举系统中的所有窗口!(II).files/microsoft.js"></SCRIPT>
</TD>
<TD align=middle width=620>
<TABLE bgColor=#eeeeee border=0 cellPadding=0 cellSpacing=0 width=600>
<TBODY>
<TR bgColor=#ffffff>
<TD align=middle height=10 width=50></TD>
<TD align=right><A href="http://www.csdn.net/">CSDN</A> - <A
href="http://www.csdn.net/develop/">文档中心</A> - <FONT
color=#003399>Visual C++</FONT> </TD></TR>
<TR>
<TD align=middle height=5></TD>
<TD align=middle width=500></TD></TR>
<TR>
<TD align=middle bgColor=#003399 height=10><FONT
color=#ffffff>标题</FONT></TD>
<TD><B> 在 CTreeCtrl
中枚举系统中的所有窗口!(II)</B> ghj1976(收藏) </TD></TR>
<TR>
<TD align=middle height=5></TD>
<TD align=middle width=500></TD></TR>
<TR>
<TD align=middle bgColor=#003399><FONT color=#ffffff>关键字</FONT></TD>
<TD width=500> 在 CTreeCtrl
中枚举系统中的所有窗口!(II)</TD></TR>
<TR>
<TD align=middle height=5></TD>
<TD align=middle width=500></TD></TR></TBODY></TABLE><!--文章说明信息结束//-->
<TABLE border=0 width=600>
<TBODY>
<TR>
<TD
align=left><BR>发信人: cvisual (贝贝), 信区: VisualC <BR>标 题: 在 CTreeCtrl 中枚举系统中的所有窗口!(II) <BR>发信站: BBS 水木清华站 (Tue May 19 14:37:24 1998) <BR> <BR>这是实现文件 <BR> <BR>// WinList.cpp : implementation file <BR>// <BR> <BR>#include "stdafx.h" <BR>#include "mfc.h" <BR>#include "WinList.h" <BR>#include "mfcApi.h" <BR> <BR>#ifdef _DEBUG <BR>#define new DEBUG_NEW <BR>#undef THIS_FILE <BR>static char THIS_FILE[] = __FILE__; <BR>#endif <BR> <BR>///////////////////////////////////////////////////////////////////////////// <BR>// CWinList dialog <BR> <BR> <BR>CWinList::CWinList(CWnd* pParent /*=NULL*/) <BR> : CDialog(CWinList::IDD, pParent) <BR>{ <BR> //{{AFX_DATA_INIT(CWinList) <BR> // NOTE: the ClassWizard will add member initialization here <BR> //}}AFX_DATA_INIT <BR>} <BR> <BR> <BR>void CWinList::DoDataExchange(CDataExchange* pDX) <BR>{ <BR> CDialog::DoDataExchange(pDX); <BR> //{{AFX_DATA_MAP(CWinList) <BR> DDX_Control(pDX, IDTREE, m_Tree); <BR> //}}AFX_DATA_MAP <BR>} <BR> <BR> <BR>BEGIN_MESSAGE_MAP(CWinList, CDialog) <BR> //{{AFX_MSG_MAP(CWinList) <BR> ON_BN_CLICKED(IDREFRESH, OnRefresh) <BR> ON_NOTIFY(TVN_SELCHANGED, IDTREE, OnSelchangedTree) <BR> //}}AFX_MSG_MAP <BR>END_MESSAGE_MAP() <BR> <BR>///////////////////////////////////////////////////////////////////////////// <BR>// CWinList message handlers <BR> <BR>static CDWordArray WinArray; <BR>static unsigned long Level; <BR>static int Ignore[10]; <BR>static HWND hPrevWnd; <BR> <BR>BOOL CALLBACK CWinList::EnumChildProc(HWND hwnd,LPARAM lParam) <BR>{ <BR> Ignore[Level]++; <BR> if (Ignore[Level+1]) Ignore[Level+1]--; <BR> else <BR> { WinArray.Add((unsigned long)((Level<<16)|(unsigned long)hwnd)); <BR> Level++;Ignore[Level+1]=0; <BR> EnumChildWindows(hwnd,EnumChildProc,(long)0); <BR> Level--; <BR> } <BR> <BR> return TRUE; <BR>} <BR> <BR>BOOL CALLBACK CWinList::EnumWindowsProc(HWND hwnd, LPARAM lParam) <BR>{ <BR> WinArray.Add((unsigned long)hwnd); <BR> Level=1;Ignore[Level+1]=0; <BR> EnumChildWindows(hwnd,EnumChildProc,(long)0); <BR> return TRUE; <BR>} <BR> <BR>void CWinList::BuiltTree(HWND hWnd) <BR>{ char Temp[90]; <BR> char Text[50]; <BR> char Name[20]; <BR> <BR> TreeItem.hParent=RootArray[RootPt]; <BR> <BR> ::GetWindowText(hWnd,Text,50); <BR> ::GetClassName(hWnd,Name,20); <BR> sprintf(Temp,"[%04x]:{%s}:%s",hWnd,Name,Text); <BR> TreeItem.item.pszText=Temp; <BR> TreeItem.item.lParam=(unsigned long)hWnd; <BR> HTREEITEM TempItem=m_Tree.InsertItem(&TreeItem); <BR> RootArray[RootPt+1]=TempItem; <BR>} <BR> <BR>void CWinList::DrawFlash(HWND hWnd) <BR>{ <BR> HDC hDC; <BR> RECT rc; <BR> HPEN hPen; <BR> <BR> ::GetWindowRect(hWnd, &rc); <BR> hDC=::GetWindowDC(hWnd); <BR> ::SetROP2(hDC,R2_NOT); <BR> hPen=::CreatePen(PS_INSIDEFRAME,5*GetSystemMetrics(SM_CXBORDER),RGB(255,0,0)); <BR> ::SelectObject(hDC,hPen); <BR> ::SelectObject(hDC,GetStockObject(NULL_BRUSH)); <BR> ::Rectangle(hDC,0,0,rc.right-rc.left,rc.bottom-rc.top); <BR> ::ReleaseDC(hWnd,hDC); <BR> ::DeleteObject(hPen); <BR>} <BR> <BR>void CWinList::Refresh() <BR>{ RootArray[0]=TVI_ROOT; <BR> RootPt=0; <BR> <BR> TreeItem.hInsertAfter=TVI_LAST; <BR> TreeItem.item.mask=TVIF_TEXT|TVIF_PARAM; <BR> WinArray.RemoveAll(); <BR> m_Tree.SetFont(&TreeFont); <BR> m_Tree.DeleteAllItems(); <BR> Level=0; <BR> for(int j=0;j<10;j++) Ignore[j]=0; <BR> EnumWindows(EnumWindowsProc,(long)0); <BR> <BR> for(int i=0;i<WinArray.GetSize();i++) <BR> { RootPt=(int)((WinArray[i]&0xFFFF0000)>>16); <BR> BuiltTree((HWND)(WinArray[i]&0x0000FFFF)); <BR> } <BR>} <BR> <BR>BOOL CWinList::OnInitDialog() <BR>{ <BR> CDialog::OnInitDialog(); <BR> <BR> // TODO: Add extra initialization here <BR> m_hSelected=NULL; <BR> hPrevWnd=NULL; <BR> Refresh(); <BR> return TRUE; // return TRUE unless you set the focus to a control <BR> // EXCEPTION: OCX Property Pages should return FALSE <BR>} <BR> <BR>void CWinList::OnRefresh() <BR>{ <BR> // TODO: Add your control notification handler code here <BR> Refresh(); <BR>} <BR> <BR>void CWinList::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult) <BR>{ <BR> NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; <BR> // TODO: Add your control notification handler code here <BR> <BR> HWND hWnd=(HWND)pNMTreeView->itemNew.lParam; <BR> m_hSelected=hWnd; <BR> if (hPrevWnd) DrawFlash(hPrevWnd); <BR> hPrevWnd=hWnd; <BR> DrawFlash(hWnd); <BR> <BR> *pResult = 0; <BR>} <BR> <BR>BOOL CWinList::DestroyWindow() <BR>{ <BR> // TODO: Add your specialized code here and/or call the base class <BR> if (hPrevWnd) DrawFlash(hPrevWnd); <BR> return CDialog::DestroyWindow(); <BR>} <BR> <BR>///////////////////////////////////////////////////////////////////////////// <BR>// DLL Export Interface <BR> <BR>extern "C" <BR>HWND FAR PASCAL EXPORT SearchWindow() <BR>{ <BR> CWinList WinList; <BR> if (WinList.DoModal()==IDOK) <BR> return WinList.m_hSelected; <BR> else <BR> return (HWND)NULL; <BR>} <BR> <BR> <BR>-- <BR>┌————┐ <BR>│ 贝 贝 │ <BR>└————┘ <BR> <BR> <BR>※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: bbs.nju.edu.cn] <BR><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center bgColor=#006699 border=0 cellPadding=0 cellSpacing=0
width=770>
<TBODY>
<TR bgColor=#006699>
<TD align=middle bgColor=#006699 id=white><FONT
color=#ffffff>对该文的评论</FONT></TD>
<TD align=middle>
<SCRIPT
src="CSDN_文档中心_在 CTreeCtrl 中枚举系统中的所有窗口!(II).files/readnum.htm"></SCRIPT>
</TD></TR></TBODY></TABLE><BR>
<DIV align=center>
<TABLE align=center bgColor=#cccccc border=0 cellPadding=2 cellSpacing=1
width=770>
<TBODY>
<TR>
<TH bgColor=#006699 id=white><FONT
color=#ffffff>我要评论</FONT></TH></TR></TBODY></TABLE></DIV>
<DIV align=center>
<TABLE border=0 width=770>
<TBODY>
<TR>
<TD>你没有登陆,无法发表评论。 请先<A
href="http://www.csdn.net/member/login.asp?from=/Develop/read_article.asp?id=3913">登陆</A>
<A
href="http://www.csdn.net/expert/zc.asp">我要注册</A><BR></TD></TR></TBODY></TABLE></DIV><BR>
<HR noShade SIZE=1 width=770>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=500>
<TBODY>
<TR align=middle>
<TD height=10 vAlign=bottom><A
href="http://www.csdn.net/intro/intro.asp?id=2">网站简介</A> - <A
href="http://www.csdn.net/intro/intro.asp?id=5">广告服务</A> - <A
href="http://www.csdn.net/map/map.shtm">网站地图</A> - <A
href="http://www.csdn.net/help/help.asp">帮助信息</A> - <A
href="http://www.csdn.net/intro/intro.asp?id=2">联系方式</A> - <A
href="http://www.csdn.net/english">English</A> </TD>
<TD align=middle rowSpan=3><A
href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010"><IMG
border=0 height=48
src="CSDN_文档中心_在 CTreeCtrl 中枚举系统中的所有窗口!(II).files/biaoshi.gif"
width=40></A></TD></TR>
<TR align=middle>
<TD vAlign=top>百联美达美公司 版权所有 京ICP证020026号</TD></TR>
<TR align=middle>
<TD vAlign=top><FONT face=Verdana>Copyright © CSDN.net, Inc. All rights
reserved</FONT></TD></TR>
<TR>
<TD height=15></TD>
<TD></TD></TR></TBODY></TABLE></DIV>
<DIV></DIV><!--内容结束//--><!--结束//--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -