Jeg fik noget strikket sammen:
#define _WIN32_WINNT 0x0500
#include <windows.h>
#define IDC_STATIC_1 1200
#define IDC_STATIC_2 1201
#define IDC_TIMER_1 1202
HINSTANCE InstanceHandle;
int Trans;
bool Running = true;
HBRUSH BackBrush;
LRESULT CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
CreateWindow("STATIC",
"Some multi line\\r\\nText", // Initial Text
WS_CHILD | WS_VISIBLE | SS_CENTER, // Style
5, 5, 150, 40, // position
hwndDlg, // Owner
(HMENU)(IDC_STATIC_1), // ID
InstanceHandle, // The application
0);
CreateWindow("STATIC",
"Text in read", // Initial Text
WS_CHILD | WS_VISIBLE | SS_CENTER, // Style
5, 45, 150, 40, // position
hwndDlg, // Owner
(HMENU)(IDC_STATIC_2), // ID
InstanceHandle, // The application
0);
SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE) & ~WS_CAPTION);
LONG OldState = GetWindowLong(hwndDlg, GWL_EXSTYLE);
LONG 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);
break;
}
case WM_CTLCOLORSTATIC:
{
HDC dc = (HDC )wParam;
SetBkMode(dc, TRANSPARENT);
int Id = GetDlgCtrlID((HWND )lParam);
if(Id == IDC_STATIC_1)
SetTextColor(dc, RGB(255, 255, 255));
else
SetTextColor(dc, RGB(255, 0, 0));
return (LRESULT )BackBrush;
}
case WM_TIMER:
{
Trans += 4;
if(Trans >= 0x200)
Running = false;
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;
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",
"", // Caption text
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
Width - 150, Height - 100, 150, 100, // Position
NULL,
NULL,
InstanceHandle,
0);
MSG Msg;
while(Running && GetMessage(&Msg, WindowHandle, 0, 0xFFFF) > 0)
{
if(!IsDialogMessage(WindowHandle, &Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return 0;
}