I Have a app that needs detect insertion new devices. But i get a error on "wndClass.lpfnWndProc = reinterpret_cast(WndProcTest );" the error is "Member function must be called or its address taken". I use Borland C++ builder 6. Maybe someone knows what I'm doing wrong?
My code AppMainForm.cpp:
bool TAppMainForm::InitWindowClass()
{
WNDCLASSEX wndClass;
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
wndClass.hInstance = reinterpret_cast<HINSTANCE>(GetModuleHandle(0));
wndClass.lpfnWndProc = reinterpret_cast<WNDPROC>(WndProcTest );
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hIcon = LoadIcon(0,IDI_APPLICATION);
wndClass.hbrBackground = CreateSolidBrush(RGB(192,192,192));
wndClass.hCursor = LoadCursor(0, IDC_ARROW);
wndClass.lpszClassName = g_szClassName;
wndClass.lpszMenuName = NULL;
wndClass.hIconSm = wndClass.hIcon;
if ( ! RegisterClassEx(&wndClass) )
{
//ErrorHandler(TEXT("RegisterClassEx"));
return false;
}
return true;
}
INT_PTR WINAPI TAppMainForm::WndProcTest(
HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam
)
{
// do something
}
Header File:
public:
bool InitWindowClass();
INT_PTR WINAPI WndProcTest(
HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam
);
The problem you've got is that you're trying to take the address of a C++ member function and assign it to a pointer to a C function, lpfnWndProc
.