All pastes #839442 Raw Edit

Miscellany

public cpp v1 · immutable
#839442 ·published 2007-12-31 00:49 UTC
rendered paste body
#define WINVER 0x500#include <windows.h>int sinp = 0, sinusindex, sinus[1440], scroller_index, xpos = 360, text_length;char* sinus_text = "ZOXC, DET FUNGERER! WOHOO! :) ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";HICON hIcon;HBITMAP scroller_font, buffer;BITMAP bm;RECT rc;PAINTSTRUCT ps;HDC hdcWindow, hdcMemory, hdcBuffer;HBRUSH hbBackground;BOOL DoubleBuffering;BOOL CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){	switch (Message) {		case WM_COMMAND:		{			switch (LOWORD(wParam)) {				case 1:					SendMessage(hwnd, WM_CLOSE, (WPARAM)0, (LPARAM)0);				break;			}		}		break;		case WM_TIMER:		{			if (scroller_font) {				xpos--;				if (xpos < -(text_length * 32)) xpos = 360;				sinp++;				if (sinp >= 1440) sinp -= 1440;				sinusindex = sinp;				sinusindex += 32;				if (sinusindex >= 1440) sinusindex -= 1440;				InvalidateRect(hwnd, &rc, 0);			}		}		break;		case WM_PAINT:		{			if (scroller_font) {				hdcWindow = BeginPaint(hwnd, &ps);				FillRect(hdcBuffer, &rc, hbBackground);				for (scroller_index = 0; scroller_index <= text_length; scroller_index++) {				    int x;					for (x = 0; x < 32; x++) {						sinusindex += 1;						if (sinusindex >= 1440) sinusindex -= 1440;						BitBlt(hdcBuffer, (scroller_index * 32) + (x + xpos), sinus[sinusindex], 1, 32, hdcMemory, ((sinus_text[scroller_index] - ' ') * 32 + x), 0, SRCCOPY);					}				}                BitBlt(hdcWindow, 0, 0, rc.right, rc.bottom, hdcBuffer, 0, 0, SRCCOPY);				EndPaint(hwnd, &ps);			}		}		break;        case WM_ERASEBKGND:             if((HWND)wParam == hwnd)                return 1;        break;		case WM_CTLCOLORDLG:        case WM_CTLCOLORSTATIC:			return (LRESULT)hbBackground;		break;		case WM_LBUTTONDOWN:			SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, lParam);		break;		case WM_INITDIALOG:		{			GetObject(scroller_font, sizeof(bm), &bm);			GetClientRect(hwnd, &rc);			text_length = strlen(sinus_text);			hbBackground = CreateSolidBrush(0xFFFFFF);            hdcWindow = GetDC(0);			hdcMemory = CreateCompatibleDC(hdcWindow);			SelectObject(hdcMemory, scroller_font);            hdcBuffer = CreateCompatibleDC(hdcWindow);            buffer = CreateCompatibleBitmap(hdcWindow, rc.right, rc.bottom);            SelectObject(hdcBuffer, buffer);            int i;			for (i = 0; i < 1440; i++)				sinus[i] = sin(i * 3.1415926 / 360) * 60 + 70;			SetWindowText(hwnd, "GDI Sine Scroller");			SendMessage(hwnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);			SetTimer(hwnd, 1, 10, NULL);		}		break;		case WM_CLOSE:		{			KillTimer(hwnd, 1);			EndDialog(hwnd, 0);		}		break;		case WM_DESTROY:		    DeleteDC(hdcMemory);		    DeleteObject(scroller_font);		    DeleteObject(hbBackground);		    DeleteDC(hdcBuffer);		    DeleteObject(buffer);			PostQuitMessage(0);		break;	}	return 0;}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){     hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(300));	scroller_font = LoadBitmap(hInstance, MAKEINTRESOURCE(400));	DialogBox(hInstance, MAKEINTRESOURCE(1000), 0, &WndProc);	return 0;}