Welcome to ZyberPH. Be one of us! Read first our VIP RULES. For more info and guide you. Read our FAQ

*TUT* C/C++ Screen Melting Effect / Prank

Discussions related to C++, HTML, PHP, ASP, ColdFusion, JavaScript, Perl, Python, Ruby, WML, SQL, XML, and other programming languages.
Post Reply
User avatar
Mzteriozo
Moderator
Moderator
Posts: 204
Joined: Thu Sep 08, 2016 3:13 am
Location: Lupang Sinilangan
Contact:

*TUT* C/C++ Screen Melting Effect / Prank

Post by Mzteriozo »

This program creates a full screen transparent overlapping window, in which a "melting" effect is created to make the computer look like it's screen is melting.

Code: Select all


#include <Windows.h>

int ScreenWidth, ScreenHeight;
int Interval = 100;

// callback for the melting effect
LRESULT CALLBACK Melter(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, ScreenWidth, ScreenHeight, Desktop, 0, 0, SRCCOPY);
ReleaseDC(hWnd, Window);
ReleaseDC(HWND_DESKTOP, Desktop);

SetTimer(hWnd, 0, Interval, 0);
ShowWindow(hWnd, SW_SHOW);
break;
}
case WM_PAINT:
{
ValidateRect(hWnd, 0);
break;
}
case WM_TIMER:
{
HDC Window = GetDC(hWnd);
int X = (rand() % ScreenWidth) - (150 / 2),
Y = (rand() % 15),
Width = (rand() % 150);
BitBlt(Window, X, Y, Width, ScreenHeight, Window, X, 0, SRCCOPY);
ReleaseDC(hWnd, Window);
break;
}
case WM_DESTROY:
{
KillTimer(hWnd, 0);
PostQuitMessage(0);
break;
}
return 0;
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
}

int APIENTRY WinMain(HINSTANCE Inst, HINSTANCE Prev, LPSTR Cmd, int showcmd)
{
// Get the width & height of current display
ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
// class for initializing the window
WNDCLASS wndClass = { 0, Melter, 0,0, Inst, 0, LoadCursorW(0,IDC_ARROW), 0, 0, L"ScreenMelter" };

// register the class
if (RegisterClass(&wndClass))
{
// Create the "melter", an overlapping window.
HWND hWnd = CreateWindowExA(WS_EX_TOPMOST, "ScreenMelter", 0, WS_POPUP,
0, 0, ScreenWidth, ScreenHeight, HWND_DESKTOP, 0, Inst, 0);

if (hWnd) //if the window is created successfully
{
// seed for randomization
srand(GetTickCount());
MSG Msg = { 0 };
// Run the melter loop as long as the program isn't given the shutdown signal
while (Msg.message != WM_QUIT)
{
if (PeekMessage(&Msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
}
}
return 0;
}



i'm not going to censor myself to comfort your ignorance
Image
Post Reply

Return to “Programming & Web Design”