CALLBACK回调函数能作为C++的类中的成员函数嘛?
如下的一段程序是C写的,我需要用C++的OOP方法来实现
,那个EnumWindowsProc回调函数可写成C++类里的成员函数嘛?
typedef struct
{
HWND hWnd;
char cWinBuf[256];
}WINLIST;
WINLIST gWinList[256];
int giCountWin,j;
BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
{
char buffer[256];
GetWindowText(hWnd, buffer, 256);
if ( strlen(buffer) )
{
if (giCountWin < 256)
{
gWinList[ giCountWin].hWnd = hWnd;
strcpy(gWinList[ giCountWin].cWinBuf,buffer);
giCountWin ++;
}
}
return TRUE;
}
void CloseSpedia()
{
giCountWin = 0;
EnumWindows( (WNDENUMPROC)EnumWindowsProc,0);
for ( j = 0; j<giCountWin; j++)
{
if ( strcmp(gWinList[j].cWinBuf,"画笔") == 0 )
{
::PostMessage( gWinList[j].hWnd,WM_CLOSE,0,0);
break;
}
}
}