RegisterClassEX error:C2664
I recently started working on learning windows programming, when I tried to compile my first program I got this error mesage:
Main.cpp
c:\WINDOWS\DESKTOP\BASECODE1\Lines\Main.cpp(52) : error C2664: ''RegisterClassExA'' : cannot convert parameter 1 from ''struct WinMain::_WNDCLASSEX *'' to ''const struct tagWNDCLASSEXA *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
Main.obj - 1 error(s), 0 warning(s)
I looked at 2 different examples of code to set make a window and could not find any difference in my code and theirs. Here is my code if anyone could help me I would greatly appreciate it:
#define WIN32_LEAN_AND_MEAN
#include
#include
LRESULT CALLBACK WindowProc (HWND hwnd, UINT msg, WPARAM wparam,
LPARAM lparam)
{
return(DefWindowProc(hwnd, msg, wparam, lparam));
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdline,
int nShowCmd)
{
typedef struct _WNDCLASSEX
{
UINT cbsize;
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
HICON hIconSm;
} WNDCLASSEX;
WNDCLASSEX winclass;
winclass.cbsize = sizeof (WNDCLASSEX);
winclass.style = CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hInstance;
winclass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = "winclass";
winclass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
RegisterClassEx(&winclass);
HWND hwnd;
if (!(hwnd = CreateWindowEx(NULL,
"winclass",
"Lines",
WS_OVERLAPPED | WS_VISIBLE,
0, 0, 640, 480,
NULL,
NULL,
hInstance,
NULL))) return (0);
return 0;
}
why are you declaring your own WNDCLASSEX structure??? just include windows.h and use the one in that and itll work fine.
I thought that I had to declare my own WINCLASSEX structure. Anyway, I removed it as you suggested and received the following error:
--------------------Configuration: Lines - Win32 Debug--------------------
Compiling...
Main.cpp
c:\WINDOWS\DESKTOP\BASECODE1\Lines\Main.cpp(24) : error C2039: 'cbsize' : is not a member of 'tagWNDCLASSEXA'
c:\program files\microsoft sdk\include\winuser.h(1441) : see declaration of 'tagWNDCLASSEXA'
Error executing cl.exe.
Main.obj - 1 error(s), 0 warning(s)
When I removed cbsize from my program it compiled and linked correctly, but when I executed it the program didn't do anything.
Edited by - ash_nagasaki on October 22, 2001 12:43:19 AM
--------------------Configuration: Lines - Win32 Debug--------------------
Compiling...
Main.cpp
c:\WINDOWS\DESKTOP\BASECODE1\Lines\Main.cpp(24) : error C2039: 'cbsize' : is not a member of 'tagWNDCLASSEXA'
c:\program files\microsoft sdk\include\winuser.h(1441) : see declaration of 'tagWNDCLASSEXA'
Error executing cl.exe.
Main.obj - 1 error(s), 0 warning(s)
When I removed cbsize from my program it compiled and linked correctly, but when I executed it the program didn't do anything.
Edited by - ash_nagasaki on October 22, 2001 12:43:19 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement