

LpszClassName Name to identify the class with. LpszMenuName Name of a menu resource to use for the windows with this class. HbrBackground Background Brush to set the color of our window. HCursor Cursor that will be displayed over our window. HIcon Large (usually 32x32) icon shown when the user presses Alt+Tab. HInstance Handle to application instance (that we got in the first parameter of WinMain()). Usually 0.ĬbWndExtra Amount of extra data allocated in memory per window of this type. LpfnWndProc Pointer to the window procedure for this window class.ĬbClsExtra Amount of extra data allocated for this class in memory. Style Class Styles ( CS_*), not to be confused with Window Styles ( WS_*) This can usually be set to 0. The members of the struct affect the window class as follows: We fill out the members of a WNDCLASSEX structure and call This is the code we use in WinMain() to register our window class. To register our window class with the system. The variable above stores the name of our window class, we will use it shortly Most of the attributes you set in the window class can be changed on a per-windowĪ Window Class has NOTHING to do with C++ classes.

This way, you can register a class once, and createĪs many windows as you want from it, without having to specify all those attributes overĪnd over. Window Procedure which controls the window, the small and large icons for the To compile then this one should work with no problems.Ī Window Class stores information about a type of window, including it's MessageBox(NULL, "Window Creation Failed!", "Error!",įor most part this is the simplest windows program you can write that actuallyĬreates a functional window, a mere 70 or so lines. MessageBox(NULL, "Window Registration Failed!", "Error!", Wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION) Wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1) Wc.hCursor = LoadCursor(NULL, IDC_ARROW) Wc.hIcon = LoadIcon(NULL, IDI_APPLICATION) Int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, Return DefWindowProc(hwnd, msg, wParam, lParam) LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) I always liked to do things first and learn them later.so here is the code toĪ simple window which will be explained shortly.Ĭonst char g_szClassName = "myWindowClass" They're more than can be simply explained over a chat room, or a quick note. It's not difficult once you know what you'reĭoing but there are quite a few things you need to do to get a window to show up And Sometimes people come on IRC and ask "How do I make a window?".Well it's notĮntirely that simple I'm afraid. Tutorial: A Simple Window theForger's Win32 API Programming Tutorial
