| Contents> C++ Labo.>ex-0 |
|
ウィンドウの子ウィンドウのハンドル一覧を取得しようと、 WindowsAPIのEnumChildWindows関数とEnumChildProcコールバック関数を使い、 以下の用にプログラムを組んでビルドをしました。
#include <windows.h>
#include <winuser.h>
#include <stdio.h>
BOOL CALLBACK EnumChildProc(HWND,long);
BOOL CALLBACK EnumChildProc(HWND hWnd,long lparam)
{
char lpText[256];
GetWindowText(hWnd, lpText,256);
printf("Handle=[%x] ControlText=[%s]\n", hWnd, lpText);
return TRUE;
}
int main(int argc, char* argv[])
{
HWND hWnd = FindWindow(NULL,"何かウィンドウタイトル");
EnumChildWindows(hWnd, EnumChildProc,0);
return 0;
}
|
・E2034 'int (__stdcall *)(void *, long)'型は'int (__stdcall *)()'型に変換できない ・E2034 パラメータ'lpEnumFunc'は'int (__stdcall *)()'型として定義されているので 'int (__stdcall *)(void *, long)'型は渡せない |
typedef BOOL (CALLBACK* WNDENUMPROC)(HWND, LPARAM);
(中略)
typedef FARPROC WNDENUMPROC;
(中略)
WINUSERAPI
BOOL
WINAPI
EnumChildWindows(
IN HWND hWndParent,
IN WNDENUMPROC lpEnumFunc,
IN LPARAM lParam);
|