/* The original version of this program can be found at http://damb.dk */
#define _WIN32_WINNT 0x0500
#include <windows.h>
#define WINDOW_WIDTH 150
#define WINDOW_HEIGHT 100
#define IDC_STATIC_1 1200
#define IDC_STATIC_2 1201
#define IDC_TIMER_1 1202
HINSTANCE InstanceHandle;
int Trans;
HBRUSH TextBrush;
POINT MyPos;
LRESULT CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
CreateWindow("STATIC",
"Some multi linernText",
WS_CHILD | WS_VISIBLE | SS_CENTER,
5, 5, WINDOW_WIDTH - 10, 45,
hwndDlg,
(HMENU)(IDC_STATIC_1),
InstanceHandle,
0);
CreateWindow("STATIC",
"Text in red",
WS_CHILD | WS_VISIBLE | SS_CENTER,
5, 50, WINDOW_WIDTH - 10, 45,
hwndDlg,
(HMENU)(IDC_STATIC_2),
InstanceHandle,
0);
SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
LONG OldState;
LONG NewState;
OldState = GetWindowLong(hwndDlg, GWL_STYLE);
NewState = OldState & ~WS_CAPTION;
SetWindowLong(hwndDlg, GWL_STYLE, NewState);
OldState = GetWindowLong(hwndDlg, GWL_EXSTYLE);
NewState = OldState | WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW;
SetWindowLong(hwndDlg, GWL_EXSTYLE, NewState);
SetLayeredWindowAttributes(hwndDlg, 0, 0, LWA_ALPHA);
SetTimer(hwndDlg, IDC_TIMER_1, 100, 0);
TextBrush = CreateSolidBrush(RGB(255, 255, 255));
break;
}
case WM_CTLCOLORSTATIC:
{
HDC dc = (HDC )wParam;
SetBkMode(dc, TRANSPARENT);
int Id = GetDlgCtrlID((HWND )lParam);
if(Id == IDC_STATIC_1)
SetTextColor(dc, RGB(0, 0, 0));
else
SetTextColor(dc, RGB(255, 0, 0));
return (LRESULT )TextBrush;
}
case WM_TIMER:
{
Trans += 4;
if(Trans >= 0x200)
PostQuitMessage(0);
else if(Trans < 0x100)
SetLayeredWindowAttributes(hwndDlg, 0, Trans, LWA_ALPHA);
else
SetLayeredWindowAttributes(hwndDlg, 0, 255 - (Trans - 0x100), LWA_ALPHA);
break;
}
}
return DefWindowProc(hwndDlg, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, INT)
{
InstanceHandle = hInstance;
HBRUSH BackBrush = CreateSolidBrush(RGB(0xA0, 0xA0, 0xFF));
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = DialogProc;
wc.hInstance = InstanceHandle;
wc.hbrBackground = BackBrush;
wc.lpszClassName = "WhateverClass";
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
if(!RegisterClass(&wc))
return FALSE;
int Width = GetSystemMetrics(SM_CXFULLSCREEN);
int Height = GetSystemMetrics(SM_CYFULLSCREEN);
HWND WindowHandle = CreateWindow("WhateverClass",
"",
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
Width - WINDOW_WIDTH, Height - WINDOW_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT,
NULL,
NULL,
InstanceHandle,
0);
MSG Msg;
while(GetMessage(&Msg, WindowHandle, 0, 0xFFFF) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return 0;
}