Here I through this together in two seconds. It's sloppy but you get the idea.
Code:
#include <windows.h>
#define APPNAME "TEST"
#define CLASSNAME "MyClass"
LRESULT CALLBACK MyWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
case WM_CLOSE:
PostQuitMessage( 0 ); // Exit our program
return 0;
case WM_KEYUP:
if( wParam == 27 ) // 27 = ESC key
PostQuitMessage( 0 );
return 0;
case WM_PAINT:
{
// Obtain our device context
HDC hDC = GetDC( hWnd );
// Output a text string on screen
// Params: HDC, XPOS, YPOS, string, string length
TextOut( hDC, 50, 50, "Hello World", 11 );
// Give back our device context
ReleaseDC( hWnd, hDC );
return 0;
}
}
// Let the default proc handle messages we don't
return DefWindowProc( hWnd, msg, wParam, lParam );
}
BOOL RegisterWindow( HINSTANCE hInst )
{
WNDCLASSEX wndclex = { 0 };
wndclex.cbSize = sizeof( WNDCLASSEX );
wndclex.hInstance = hInst;
wndclex.style = 0;
wndclex.hIcon = NULL; // Default icon
wndclex.hCursor = LoadCursor( NULL, IDC_ARROW );
wndclex.cbClsExtra = 0;
wndclex.cbWndExtra = 0;
wndclex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclex.lpszMenuName = 0;
wndclex.lpfnWndProc = MyWndProc;
wndclex.lpszClassName = CLASSNAME;
if( RegisterClassEx( &wndclex ) == 0 )
return FALSE;
return TRUE;
}
int __stdcall WinMain( HINSTANCE hInst,
HINSTANCE hPrev,
LPSTR lpCmdLine,
int nShowCmd )
{
HWND hWnd;
MSG msg;
if( RegisterWindow( hInst ) == FALSE )
{
MessageBox( 0, "Register Window Failed", "Failure", MB_OK );
return 0;
}
// Here we create our main window
hWnd = CreateWindowEx( WS_EX_TOPMOST,
CLASSNAME,
APPNAME,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
NULL,
NULL );
if( hWnd == NULL )
{
MessageBox( 0, "CreateWindowEx Failed", "Failure", MB_OK );
return 0;
}
// Update the window then display it
UpdateWindow( hWnd );
ShowWindow( hWnd, SW_SHOW );
// Main message pump
while( GetMessage( &msg, 0, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
Sleep(1);
}
// Quit the program
return msg.wParam;
}