Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. #include <Windows.h>
  2. static bool Running;
  3.  
  4. LRESULT CALLBACK MainWindowCallback(HWND Window,
  5.     UINT Message,
  6.     WPARAM wParam,
  7.     LPARAM lParam)
  8. {
  9.     LRESULT Result = 0;
  10.     switch (Message)
  11.     {
  12.     case WM_SIZE:
  13.     {
  14.                     OutputDebugString("WM_SIZE\n");
  15.     } break;
  16.  
  17.     case WM_DESTROY:
  18.     {
  19.                        Running = false;
  20.                        OutputDebugString("WM_DESTROY\n");
  21.     } break;
  22.  
  23.     case WM_CLOSE:
  24.     {  
  25.                      Running = false;
  26.                      OutputDebugString("WM_CLOSE\n");
  27.     } break;
  28.  
  29.     case WM_ACTIVATEAPP:
  30.     {    
  31.  
  32.                            OutputDebugString("WM_ACTIVATEAPP\n");
  33.     } break;
  34.     case WM_PAINT:
  35.     {
  36.                      PAINTSTRUCT Paint;
  37.                      HDC DeviceContext = BeginPaint(Window, &Paint);
  38.                      int x = Paint.rcPaint.left;
  39.                      int y = Paint.rcPaint.top;
  40.                      int Width = Paint.rcPaint.right - Paint.rcPaint.left;
  41.                      int Height = Paint.rcPaint.bottom - Paint.rcPaint.top;
  42.                      static DWORD Operation = WHITENESS;
  43.                      PatBlt(DeviceContext, x, y, Width, Height, Operation);
  44.                      if (Operation == WHITENESS)
  45.                      {
  46.                          Operation = BLACKNESS;
  47.                      }
  48.                      else{
  49.                          Operation = WHITENESS;
  50.                      }
  51.                      EndPaint(Window, &Paint);
  52.  
  53.     } break;
  54.  
  55.     default:
  56.     {
  57.                //OutputDebugString("DEFAULT\n")
  58.                Result = DefWindowProc(Window, Message, wParam, lParam);
  59.  
  60.     } break;
  61.     }
  62.     return(Result);
  63. }
  64.  
  65.  
  66. int CALLBACK WinMain(HINSTANCE Instance,
  67.     HINSTANCE hPrevInstance,
  68.     LPSTR lpCmdLine,
  69.     int nCmdShow)
  70. {
  71.  
  72.     WNDCLASS WindowClass = {};
  73.  
  74.     WindowClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
  75.     WindowClass.lpfnWndProc = MainWindowCallback;
  76.     WindowClass.hInstance = Instance;
  77.     //WindowClass.hIcon;
  78.     WindowClass.lpszClassName = "BitterProjectWindowClass";
  79.  
  80.     if (RegisterClass(&WindowClass)){
  81.         HWND WindowHandle = CreateWindowEx(0,
  82.             WindowClass.lpszClassName,
  83.             "BitterProject",
  84.             WS_OVERLAPPEDWINDOW | WS_VISIBLE,
  85.             CW_USEDEFAULT,
  86.             CW_USEDEFAULT,
  87.             CW_USEDEFAULT,
  88.             CW_USEDEFAULT,
  89.             0,
  90.             0,
  91.             Instance,
  92.             0);
  93.         if (WindowHandle)
  94.         {
  95.             MSG Message;
  96.             Running = true;
  97.             while (Running)
  98.             {
  99.                 BOOL MessageResult = GetMessage(&Message, 0, 0, 0);
  100.                 if (MessageResult > 0)
  101.                 {
  102.                     TranslateMessage(&Message);
  103.                     DispatchMessage(&Message);
  104.                 }
  105.                 else{
  106.                     break;
  107.                 }
  108.  
  109.             }
  110.  
  111.  
  112.         }
  113.         else
  114.         {
  115.             OutputDebugString("Window handle didn't get sent properly i don't know");
  116.         }
  117.     }
  118.     else {
  119.         OutputDebugString("Window somehow didn't get created. Shit i don't know.");
  120.     }
  121.  
  122.  
  123.     return(0);
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement