Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  4.  
  5. INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow)
  6. {
  7.     HWND     hWnd;
  8.     MSG      msg;
  9.     WNDCLASS wndClass;
  10.  
  11.     wndClass.style = CS_HREDRAW | CS_VREDRAW;
  12.     wndClass.lpfnWndProc = WndProc;
  13.     wndClass.cbClsExtra = 0;
  14.     wndClass.cbWndExtra = 0;
  15.     wndClass.hInstance = hInstance;
  16.     wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  17.     wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
  18.     wndClass.hbrBackground = (HBRUSH)(COLOR_BACKGROUND);//(HBRUSH)GetStockObject(NULL_BRUSH);
  19.     wndClass.lpszMenuName = NULL;
  20.     wndClass.lpszClassName = TEXT("Teste");
  21.  
  22.     RegisterClass(&wndClass);
  23.  
  24.     hWnd = CreateWindow(
  25.         TEXT("Teste"),   // window class name
  26.         TEXT(""),  // window caption
  27.         WS_POPUP,      // window style
  28.         300,            // initial x position
  29.         300,            // initial y position
  30.         250,            // initial x size
  31.         50,            // initial y size
  32.         NULL,                     // parent window handle
  33.         NULL,                     // window menu handle
  34.         hInstance,                // program instance handle
  35.         NULL);                    // creation parameters
  36.  
  37.     ShowWindow(hWnd, iCmdShow);
  38.     UpdateWindow(hWnd);
  39.     SetTimer(hWnd, 1, 5000, NULL);
  40.  
  41.     while (GetMessage(&msg, NULL, 0, 0))
  42.     {
  43.         TranslateMessage(&msg);
  44.         DispatchMessage(&msg);
  45.     }
  46.  
  47.     return msg.wParam;
  48. }  // WinMain
  49.  
  50. LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
  51.     WPARAM wParam, LPARAM lParam)
  52. {
  53.     HDC          hdc;
  54.     PAINTSTRUCT  ps;
  55.  
  56.     switch (message)
  57.     {
  58.     case WM_PAINT:
  59.         hdc = BeginPaint(hWnd, &ps);
  60.         RECT pos;
  61.         pos.left = 0;
  62.         pos.right = 249;
  63.         pos.top = 0;
  64.         pos.bottom = 49;
  65.         DrawText(hdc, "Texto da janela", -1, &pos, DT_CENTER or DT_VCENTER);
  66.         EndPaint(hWnd, &ps);
  67.         return 0;
  68.     case WM_DESTROY:
  69.         PostQuitMessage(0);
  70.         return 0;
  71.     case WM_TIMER:
  72.         PostQuitMessage(0);
  73.     default:
  74.         return DefWindowProc(hWnd, message, wParam, lParam);
  75.     }
  76. } // WndProc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement