Code:
#define _WIN32_WINNT (0x500)
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#define MAIN_APP_WINDOW_CLASS TEXT("ScratchProgramWindowClass")
//+-----------------------------------------------------------------------------
LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch(uMsg)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
//+-----------------------------------------------------------------------------
BOOL SetupWindowClass( void )
{
WNDCLASSEX wc = { 0 };
INITCOMMONCONTROLSEX ice = { 0 };
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIconSm = NULL;
wc.lpfnWndProc = WndProc;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = MAIN_APP_WINDOW_CLASS;
return (BOOL) RegisterClassEx(&wc);
}
//+-----------------------------------------------------------------------------
BOOL CALLBACK CreateAppWindows( int nCmdShow )
{
DWORD style;
HWND hwnd, hwndChild;
hwnd = CreateWindowEx(WS_EX_LAYERED, MAIN_APP_WINDOW_CLASS, TEXT("Main Window"), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, 500, 500,
NULL, NULL, GetModuleHandle(NULL), NULL);
/* Set a transparency value of 70% */
SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA);
if ( !hwnd )
return FALSE;
style = ES_MULTILINE | ES_WANTRETURN | ES_LEFT | WS_VISIBLE |
WS_CHILD | WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL;
hwndChild = CreateWindowEx(0, TEXT("EDIT"), TEXT("Hello World!"), style,
0, 0, 400, 400,
hwnd, (HMENU) 1337, GetModuleHandle(NULL), NULL);
if ( !hwndChild )
{
DestroyWindow(hwnd);
return FALSE;
}
ShowWindow(hwnd, nCmdShow);
return TRUE;
}
//+-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE reserved, LPSTR lpCommand, INT nCmdShow )
{
MSG msg;
if( !SetupWindowClass() )
return -1;
if ( !CreateAppWindows( nCmdShow ) )
return -1;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}