Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.16 KB | None | 0 0
  1. #include<Windows.h>
  2. #include<time.h>
  3. #include<stdlib.h>
  4. #include<TCHAR.H>
  5. #include<math.h>
  6. #include "resource1.h"
  7.  
  8. HINSTANCE hInst;
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg,
  16.     WPARAM wParam, LPARAM lParam)
  17. {
  18.     HDC         hdc,memdc;
  19.     PAINTSTRUCT ps;
  20.     static HBITMAP hBit, oldBit;
  21.     static RECT rectView;
  22.     static int yPos;
  23.     TCHAR word[] = _T("20141825 한창기 만세");
  24.  
  25.     switch (iMsg)
  26.     {
  27.     case WM_CREATE:
  28.         yPos = -30;
  29.         GetClientRect(hwnd, &rectView);
  30.         SetTimer(hwnd, 1, 10, NULL);
  31.         hBit = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
  32.         break;
  33.     case WM_TIMER:
  34.         yPos += 1;
  35.         if (yPos > rectView.bottom)yPos = -30;
  36.         InvalidateRgn(hwnd, NULL, TRUE);
  37.         return 0;
  38.     case WM_PAINT:
  39.         GetClientRect(hwnd, &rectView);
  40.         hdc = BeginPaint(hwnd, &ps);
  41.         memdc = CreateCompatibleDC(hdc);
  42.         oldBit = (HBITMAP)SelectObject(memdc, hBit);
  43.         BitBlt(hdc, 0, 0, 1024, 768, memdc, 0, 0, SRCCOPY);
  44.         SelectObject(memdc, oldBit);
  45.         DeleteDC(memdc);
  46.         TextOut(hdc, 200, yPos, word, _tcslen(word));
  47.         EndPaint(hwnd, &ps);
  48.         break;
  49.     case WM_DESTROY:
  50.         PostQuitMessage(0);
  51.         break;
  52.     }
  53.     return(DefWindowProc(hwnd, iMsg, wParam, lParam));
  54. }
  55.  
  56. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  57.     LPSTR lpszCmdLine, int nCmdShow)
  58. {
  59.     srand((unsigned)time(NULL));
  60.     HWND     hwnd;
  61.     MSG      msg;
  62.     WNDCLASS WndClass;
  63.     hInst = hInstance;
  64.     WndClass.style = CS_HREDRAW | CS_VREDRAW;
  65.     WndClass.lpfnWndProc = WndProc;
  66.     WndClass.cbClsExtra = 0;
  67.     WndClass.cbWndExtra = 0;
  68.     WndClass.hInstance = hInstance;
  69.     WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  70.     WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
  71.     WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
  72.     WndClass.lpszMenuName = NULL;
  73.     WndClass.lpszClassName = _T("Window Class Name");
  74.     RegisterClass(&WndClass);
  75.     hwnd = CreateWindow(_T("Window Class Name"),
  76.         _T("Window Title Name"),
  77.         WS_OVERLAPPEDWINDOW,
  78.         CW_USEDEFAULT,
  79.         CW_USEDEFAULT,
  80.         600,
  81.         600,
  82.         NULL,
  83.         NULL,
  84.         hInstance,
  85.         NULL
  86.         );
  87.     ShowWindow(hwnd, nCmdShow);
  88.     UpdateWindow(hwnd);
  89.  
  90.     while (GetMessage(&msg, NULL, 0, 0))
  91.     {
  92.         TranslateMessage(&msg);
  93.         DispatchMessage(&msg);
  94.     }
  95.     return (int)msg.wParam;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement