Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "wndclass1";
/* Make the paint variable available globally */
HDC hdc[3];
/* Make the paint variable available globally */
HWND wndh[3];
/* Main function */
int WINAPI WinMain( HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil )
{
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND + 1;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
int winX = 200;
int winY = 200;
/* The class is registered, let's create the windows */
wndh[0] = CreateWindowEx( 0,
szClassName,
"Window 1",
WS_OVERLAPPEDWINDOW&~WS_THICKFRAME&~WS_MAXIMIZEBOX,
50,
GetSystemMetrics(SM_CYSCREEN)/2-winY/2,
winX,
winY,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL );
wndh[1] = CreateWindowEx( 0,
szClassName,
"Window 2",
WS_OVERLAPPEDWINDOW&~WS_THICKFRAME&~WS_MAXIMIZEBOX,
GetSystemMetrics(SM_CXSCREEN)/2-winX/2,
GetSystemMetrics(SM_CYSCREEN)/2-winY/2,
winX,
winY,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL );
wndh[2] = CreateWindowEx( 0,
szClassName,
"Window 3",
WS_OVERLAPPEDWINDOW&~WS_THICKFRAME&~WS_MAXIMIZEBOX,
GetSystemMetrics(SM_CXSCREEN) - winX - 50,
GetSystemMetrics(SM_CYSCREEN)/2-winY/2,
winX,
winY,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL );
/* Make the windows visible on the screen */
ShowWindow (wndh[0], nFunsterStil);
ShowWindow (wndh[1], nFunsterStil);
ShowWindow (wndh[2], nFunsterStil);
/* Get the window's DC */
hdc[0] = GetDC(wndh[0]);
hdc[1] = GetDC(wndh[1]);
hdc[2] = GetDC(wndh[2]);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
/* Check to see if all the windows are closed */
if(!wndh[0] && !wndh[1] && !wndh[2]) break;
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
SetBkMode(hdc, TRANSPARENT);
char sz[100];
GetWindowText(hwnd, sz, 100);
TextOut(hdc, 65, 75, sz, strlen(sz));
EndPaint(hwnd,&ps);
}
break;
case WM_DESTROY:
{
if(hwnd == wndh[0]) wndh[0] = NULL;
if(hwnd == wndh[1]) wndh[1] = NULL;
if(hwnd == wndh[2]) wndh[2] = NULL;
}
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}