Jump to content
  • Advertisement
Sign in to follow this  
Thsotus

Win32 WinClassEx Help

This topic is 2714 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

#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

Share this post


Link to post
Share on other sites
Advertisement
You can't assign to member variables like that outside of a function. You have to do it inside a function.

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!