Advertisement
HeavenHU

Untitled

Nov 11th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.34 KB | None | 0 0
  1. #include <Windows.h>
  2.  
  3. int ScreenWidth, ScreenHeight;
  4. int Interval = 100;
  5.  
  6. // callback for the melting effect
  7. LRESULT CALLBACK Melter(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
  8. {
  9.     switch (Msg)
  10.     {
  11.     case WM_CREATE:
  12.     {
  13.         HDC Desktop = GetDC(HWND_DESKTOP);
  14.         HDC Window = GetDC(hWnd);
  15.  
  16.         BitBlt(Window, 0, 0, ScreenWidth, ScreenHeight, Desktop, 0, 0, SRCCOPY);
  17.         ReleaseDC(hWnd, Window);
  18.         ReleaseDC(HWND_DESKTOP, Desktop);
  19.  
  20.         SetTimer(hWnd, 0, Interval, 0);
  21.         ShowWindow(hWnd, SW_SHOW);
  22.         break;
  23.     }
  24.     case WM_PAINT:
  25.     {
  26.         ValidateRect(hWnd, 0);
  27.         break;
  28.     }
  29.     case WM_TIMER:
  30.     {
  31.         HDC Window = GetDC(hWnd);
  32.         int X = (rand() % ScreenWidth) - (150 / 2),
  33.             Y = (rand() % 15),
  34.             Width = (rand() % 150);
  35.         BitBlt(Window, X, Y, Width, ScreenHeight, Window, X, 0, SRCCOPY);
  36.         ReleaseDC(hWnd, Window);
  37.         break;
  38.     }
  39.     case WM_DESTROY:
  40.     {
  41.         KillTimer(hWnd, 0);
  42.         PostQuitMessage(0);
  43.         break;
  44.     }
  45.     return 0;
  46.     }
  47.     return DefWindowProc(hWnd, Msg, wParam, lParam);
  48. }
  49.  
  50. int APIENTRY WinMain(HINSTANCE Inst, HINSTANCE Prev, LPSTR Cmd, int showcmd)
  51. {
  52.     // Get the width & height of current display
  53.     ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
  54.     ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
  55. // class for initializing the window
  56.     WNDCLASS wndClass = { 0, Melter, 0,0, Inst, 0, LoadCursorW(0,IDC_ARROW), 0, 0, L"ScreenMelter" };
  57.    
  58. // register the class
  59.     if (RegisterClass(&wndClass))
  60.     {
  61.         // Create the "melter", an overlapping window.
  62.         HWND hWnd = CreateWindowExA(WS_EX_TOPMOST, "ScreenMelter", 0, WS_POPUP,
  63.             0, 0, ScreenWidth, ScreenHeight, HWND_DESKTOP, 0, Inst, 0);
  64.  
  65.         if (hWnd) //if the window is created successfully
  66.         {
  67.             // seed for randomization
  68.             srand(GetTickCount());
  69.             MSG Msg = { 0 };
  70.             // Run the melter loop as long as the program isn't given the shutdown signal
  71.             while (Msg.message != WM_QUIT)
  72.             {
  73.                 if (PeekMessage(&Msg, 0, 0, 0, PM_REMOVE))
  74.                 {
  75.                     TranslateMessage(&Msg);
  76.                     DispatchMessage(&Msg);
  77.                 }
  78.             }
  79.         }
  80.     }
  81.     return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement