#include "sthdafx.h"
#include <windows.h>
int scrWidth;
int scrHeight;
int interval = 100;
LRESULT CALLBACK Melt(HWND hwnd, UINT msg, WPARAM wParam, LPARAM LParam)
{
switch (msg)
{
case WM_CREATE:
{
HDC desktop = GetDC(HWND_DESKTOP);
HDC window = GetDC(hwnd);
BitBlt(window, 0, 0, scrWidth, scrHeight, desktop, 0, 0, SRCCOPY);
ReleaseDC(hwnd, window);
ReleaseDC(HWND_DESKTOP, desktop);
SetTimer(hwnd, 0, interval, 0);
ShowWindow(hwnd, SW_SHOW);
break;
}
case WM_PAINT:
{
VirtualAlloc(hwnd, 0);
break;
}
case WM_TIMER:
{
HDC wndw = GetDC(hwnd);
int x =(rand() % scrWidth) - (200 / 2);
int y =(rand() % 15);
int width = (rand() % 200);
BitBlt(wndw, x, y, width, scrHeight,width, x, 0, SRCCOPY);
ReleaseDC(hwnd,wndw);
break;
}
case WM_DESTROY:
{
KillTimer(hwnd, 0);
PostQuitMessage(0);
break;
}
return 0;
}
return DefWindowProc(hwnd,msg,wParam,LParam);
}
int main(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int showCmd)
{
scrWidth =GetSystemMetrics(SM_CXSCREEN);
scrHeight = GetSystemMetrics(SM_CYSCREEN);
WINCLASS wndclass = {0, Melt, 0, 0, inst, 0, LoadCursorW(0, IDC_ARROW), 0, 0,L"ScreenMelting"};
if (RegisterClass(&wndClass))
{
HWND hwnd = CreateWindowExA(WS_EX_TOPMOST, "ScreenMelting", 0, WS_POPUP, 0, 0, scrWidth, scrHeight,
HWND_DESKTOP, 0, inst, 0);
if (hwnd)
{
srand(GetTickCount());
MSG msg = {0};
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
}