Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<Windows.h>
- #define WIN32_LEAN_AND_MEAN //speeds up compiler
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { //Window message processing
- switch (msg)
- {
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return 0;
- }
- int WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow){ //Entry Point
- //(Optional stuff, does nothing)
- UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(lpCmdLine);
- UNREFERENCED_PARAMETER(nCmdShow);
- WNDCLASS window; //Create window class
- //Define window class
- window.cbClsExtra = NULL;
- window.cbWndExtra = NULL;
- window.hbrBackground = (HBRUSH)COLOR_WINDOW;
- window.hCursor = LoadCursor(NULL, IDC_ARROW);
- window.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- window.hInstance = hInstance;
- window.lpfnWndProc = WndProc;
- window.lpszClassName = "just_window";
- window.lpszMenuName = nullptr;
- window.style = NULL;
- RegisterClass(&window); //Register the defined window class
- CreateWindow("just_window","Test", WS_VISIBLE | WS_SYSMENU,0,0,500,500,nullptr,nullptr,hInstance,nullptr); //Create the defined window
- MSG msg; //Create message class
- while (GetMessage(&msg, NULL, 0, 0)) { //Message loop, get message
- TranslateMessage(&msg); //Translate Message
- DispatchMessage(&msg); //Send message to WndProc
- }
- return (int) msg.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement