Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
- LPCWSTR className = L"REghZy Frame Control";
- LPCWSTR winTitle = L"Frame Control";
- WNDCLASSW wc = {};
- wc.lpfnWndProc = WindowProc;
- wc.hInstance = hInstance;
- wc.lpszClassName = className;
- if (!RegisterClassW(&wc)) {
- printf("Failed to register class");
- MessageBoxW(NULL, L"Failed to register application class", L"App init failure - instance", NULL);
- return 0;
- }
- HWND hwnd = CreateWindowExW(
- 0, // Optional window styles.
- className, // Window class
- winTitle, // Window titlebar
- WS_OVERLAPPEDWINDOW, // Window style
- // Size and position
- CW_USEDEFAULT, // x
- CW_USEDEFAULT, // y
- 500, // w
- 500, // h
- NULL, // Parent window
- NULL, // Menu
- hInstance, // Instance handle
- NULL // Additional application data
- );
- if (!hwnd) {
- printf("Failed to register class");
- MessageBoxW(NULL, L"Failed to create application main window", L"App init failure - window", NULL);
- return 0;
- }
- ShowWindow(hwnd, nCmdShow);
- // Run the message loop.
- MSG msg = { };
- while (GetMessage(&msg, NULL, 0, 0) > 0) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- switch (uMsg) {
- case WM_DESTROY: {
- PostQuitMessage(0);
- return 0;
- }
- case WM_PAINT: {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hwnd, &ps);
- // All painting occurs here, between BeginPaint and EndPaint.
- FillRect(hdc, &ps.rcPaint, (HBRUSH)(COLOR_WINDOW + 1));
- EndPaint(hwnd, &ps);
- }
- return 0;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement