Archived

This topic is now archived and is closed to further replies.

error message with WindowProc

This topic is 6358 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to put window initialization in the class. It gives me some error message covering the WNDCLASS property. Property name is lpfnWndProc. Error message is: d:\dx\gameproject\code\c3dscene.cpp(408) : error C2440: 'type cast' : cannot convert from '' " to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)' Any ideas? Scene.h class C3DScene { BOOL Init(HINSTANCE hInstance, int nCmdShow); } Scene.cpp BOOL C3DScene::Init(HINSTANCE hInstance, int nCmdShow) { WNDCLASS wc; // Set up and register window class wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof(DWORD); wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = szClass; if (!RegisterClass(&wc)) { ErrStr=Err_Reg_Class; return FALSE; } // Get dimensions of display int ScreenWidth = GetSystemMetrics(SM_CXSCREEN); int ScreenHeight = GetSystemMetrics(SM_CYSCREEN); // Create a window and display HWND hWnd; hWnd = CreateWindow(szClass, // class szCaption, // caption WS_VISIBLE|WS_POPUP, // style 0, // left 0, // top ScreenWidth, // width ScreenHeight, // height NULL, // parent window NULL, // menu hInstance, // instance NULL); // parms if (!hWnd) { ErrStr=Err_Create_Win; return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // initialze DirectDraw if (!m_scene->init_ddraw(hWnd)) return FALSE; // initialize Direct3D if (!m_scene->init_d3d()) return FALSE; // return success to caller return TRUE; } Edited by - zalian on 7/18/00 1:22:28 AM

Share this post


Link to post
Share on other sites
My guess is that you are trying to use a member function for the WindowProc. This can''t be done because member functions implicitly send a pointer to the object to the function, but the WindowProc doesn''t want this pointer.

Look at my Direct3D framework and you''ll see how I have put the window in a class.

D3DApp



- WitchLord

Share this post


Link to post
Share on other sites
It''s declared as follows:

LRESULT CALLBACK C3DScene::WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY: PostQuitMessage(0);
break;

default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}

return 0L;
}

and in .h file there''s line
LRESULT CALLBACK WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);

When it''s declared like this it gives error message:
d:\dx\gameproject\code\c3dscene.cpp(729) :

error C2440: ''='' : cannot convert from
''long (__stdcall C3DScene::*)(struct HWND__ *,unsigned int,unsigned int,long)''

to ''long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)''




Share this post


Link to post
Share on other sites