Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_CREATE:
- break;
- case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
- INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
- {
- WNDCLASSEX wcex;
- wcex.cbClsExtra = 0;
- wcex.cbSize = sizeof(wcex);
- wcex.cbWndExtra = 0;
- wcex.hbrBackground = (HBRUSH)COLOR_WINDOW;
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- wcex.hInstance = hInstance;
- wcex.lpfnWndProc = WndProc;
- wcex.lpszClassName = "MyForm";
- wcex.lpszMenuName = NULL;
- wcex.style = 0;
- if (!RegisterClassEx(&wcex))
- {
- MessageBox(NULL, "RegisterClassEx() failed !", "ERROR", MB_ICONINFORMATION | MB_OK);
- return 1;
- }
- HWND hForm = CreateWindowEx(WS_EX_WINDOWEDGE, wcex.lpszClassName, "IMG", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 600, 500, NULL, NULL, hInstance, NULL);
- if (!hForm)
- {
- MessageBox(NULL, "CreateWindowEx() failed !", "ERROR", MB_ICONINFORMATION | MB_OK);
- return 1;
- }
- ShowWindow(hForm, nCmdShow);
- UpdateWindow(hForm);
- MSG msg{ 0 };
- while (GetMessage(&msg, hForm, NULL, NULL) > NULL)
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement