如何返回当前已打开的所有窗体的CAPTION(30分)

  • 主题发起人 主题发起人 SamHunt
  • 开始时间 开始时间
S

SamHunt

Unregistered / Unconfirmed
GUEST, unregistred user!
如何返回当前已打开的所有窗体的CAPTION
 
用此函数EnumWindowsProc
 
本人对回调函数不是很了解。<br>还是给例子
 
例:<br>type<br>&nbsp; { Define a record/class to hold the window name and class name for<br>&nbsp; &nbsp; each window. Instances of this class will get added to ListBox1 }<br>&nbsp; TWindowInfo = class<br>&nbsp; &nbsp; WindowName, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// The window name<br>&nbsp; &nbsp; WindowClass: String; // The window's class name<br>&nbsp; &nbsp; fmhwnd: thandle;<br>&nbsp; end;<br><br>// lbWinInfo: TListBox;<br><br>function EnumWindowsProc(Hw: HWnd; AMainForm: TMainForm): Boolean; stdcall;<br>var<br>&nbsp; WinName, CName: array[0..144] of char;<br>&nbsp; i: integer;<br>begin<br>&nbsp; Result := True;<br>&nbsp; GetWindowText(Hw, WinName, 144); // Obtain the current window text<br>&nbsp; GetClassName(Hw, CName, 144); &nbsp; &nbsp;// Obtain the class name of the window<br>&nbsp; if iswindowvisible(hw) then<br>&nbsp; begin<br>&nbsp; &nbsp; WindowInfo := TWindowInfo.Create;<br>&nbsp; &nbsp; with WindowInfo do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; SetLength(WindowName, strlen(WinName));<br>&nbsp; &nbsp; &nbsp; SetLength(WindowClass, StrLen(CName));<br>&nbsp; &nbsp; &nbsp; WindowName := StrPas(WinName);<br>&nbsp; &nbsp; &nbsp; WindowClass := StrPas(CName);<br>&nbsp; &nbsp; &nbsp; fmhwnd := hw;<br>&nbsp; &nbsp; end;<br>// &nbsp; &nbsp;lbWinInfo.Items.AddObject('', WindowInfo); // Add to Objects array<br>&nbsp; end;<br>end;<br>
 
查MSDN不就行了吗<br>干吗浪费分哪
 
本人是初学的,对于调用WIN32API不熟,了解了一下有以下几个问题请指教:<br><br>一般的函数是程序调用的,而回调函数是否系统调用自己写的程序?<br><br>philipliu兄 给出的函数,但是如何激活该函数呢?<br><br>要先将给出的函数写成DLL吗?<br><br>能否有更详细点?有劳!<br><br>
 
不用啦,这样调用就行!!<br>EnumWindows(@EnumWindowsProc, 0);
 
THANK YOU VERY MUCH !!!<br>虽然分数不多,但受益非浅.
 
后退
顶部