Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- static bool Running;
- LRESULT CALLBACK MainWindowCallback(HWND Window,
- UINT Message,
- WPARAM wParam,
- LPARAM lParam)
- {
- LRESULT Result = 0;
- switch (Message)
- {
- case WM_SIZE:
- {
- OutputDebugString("WM_SIZE\n");
- } break;
- case WM_DESTROY:
- {
- Running = false;
- OutputDebugString("WM_DESTROY\n");
- } break;
- case WM_CLOSE:
- {
- Running = false;
- OutputDebugString("WM_CLOSE\n");
- } break;
- case WM_ACTIVATEAPP:
- {
- OutputDebugString("WM_ACTIVATEAPP\n");
- } break;
- case WM_PAINT:
- {
- PAINTSTRUCT Paint;
- HDC DeviceContext = BeginPaint(Window, &Paint);
- int x = Paint.rcPaint.left;
- int y = Paint.rcPaint.top;
- int Width = Paint.rcPaint.right - Paint.rcPaint.left;
- int Height = Paint.rcPaint.bottom - Paint.rcPaint.top;
- static DWORD Operation = WHITENESS;
- PatBlt(DeviceContext, x, y, Width, Height, Operation);
- if (Operation == WHITENESS)
- {
- Operation = BLACKNESS;
- }
- else{
- Operation = WHITENESS;
- }
- EndPaint(Window, &Paint);
- } break;
- default:
- {
- //OutputDebugString("DEFAULT\n")
- Result = DefWindowProc(Window, Message, wParam, lParam);
- } break;
- }
- return(Result);
- }
- int CALLBACK WinMain(HINSTANCE Instance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
- {
- WNDCLASS WindowClass = {};
- WindowClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
- WindowClass.lpfnWndProc = MainWindowCallback;
- WindowClass.hInstance = Instance;
- //WindowClass.hIcon;
- WindowClass.lpszClassName = "BitterProjectWindowClass";
- if (RegisterClass(&WindowClass)){
- HWND WindowHandle = CreateWindowEx(0,
- WindowClass.lpszClassName,
- "BitterProject",
- WS_OVERLAPPEDWINDOW | WS_VISIBLE,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 0,
- 0,
- Instance,
- 0);
- if (WindowHandle)
- {
- MSG Message;
- Running = true;
- while (Running)
- {
- BOOL MessageResult = GetMessage(&Message, 0, 0, 0);
- if (MessageResult > 0)
- {
- TranslateMessage(&Message);
- DispatchMessage(&Message);
- }
- else{
- break;
- }
- }
- }
- else
- {
- OutputDebugString("Window handle didn't get sent properly i don't know");
- }
- }
- else {
- OutputDebugString("Window somehow didn't get created. Shit i don't know.");
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement