Win32 WinClassEx Help

Started by
1 comment, last by eloadrin 13 years, 3 months ago
#include
#include
#include

using namespace std;

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

WNDCLASSEX wcex;
HWND hWnd;
HINSTANCE hInstance;
MSG msg;
BOOL quit = FALSE;

wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WinProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = GetStockBrush(WHITE_BRUSH);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "MyWndClassEx"
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);;

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char * cmdParam, int cndShow)
{
RegisterClassEx(&wcex);

hwnd = CreateWindowEx(0,
"MyWndClassEx",
"Hello World!",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
500,
500,
NULL,
NULL,
hInstance,
NULL);

ShowWindow(hwnd, nCmdShow);

while (quit != TRUE)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (msg.message == WM_QUIT)
{
quit = TRUE;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return msg.wParam;

}



My MinGW compiler on Code::Blocks prevents me compiling the wcex WinClassEx because of "expected constructor, destructor, or type conversion before '-' token."

Also, can someone recommend me a good WinAPI tutorial that can teach me to create text areas and buttons? I want to create a simple add/sub calculator.

Thanks.

- Thsotus
http://thsotusgames.wordpress.com/ - My beginning, sad, studios.
Advertisement
You can't assign to member variables like that outside of a function. You have to do it inside a function.
SiCrane is right, also there is a minor mistake in your code here:


wcex.lpszClassName = "MyWndClassEx"
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);;

It should be:


wcex.lpszClassName = "MyWndClassEx";
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

This topic is closed to new replies.

Advertisement