1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
// #include <windows.h> // If you compiler doesn't like the next one.
#include <Windows.h>
LRESULT CALLBACK WindowProcedure( HWND, UINT, WPARAM, LPARAM );
int WINAPI WinMain( HINSTANCE CurrInst, HINSTANCE PrevInst, LPSTR CmdLine, int CmdArgs )
{
WNDCLASSEX ClassEx;
::ZeroMemory( &ClassEx, sizeof( WNDCLASSEX ) );
ClassEx.cbSize = sizeof( WNDCLASSEX );
ClassEx.lpfnWndProc = &( *WindowProcedure );
ClassEx.hInstance = &( *CurrInst );
ClassEx.hIcon = ::LoadIcon( nullptr, IDI_APPLICATION );
ClassEx.hCursor = ::LoadCursor( nullptr, IDC_ARROW );
ClassEx.hbrBackground = ::CreateSolidBrush( RGB( 200, 200, 200 ) );
ClassEx.lpszClassName = TEXT( "DEFAULT_CLASS" );
::RegisterClassEx( &ClassEx );
HWND WindowHandle( nullptr );
WindowHandle = ::CreateWindowEx( 0, TEXT( "DEFAULT_CLASS" ), TEXT( "Window Name" ),
WS_OVERLAPPEDWINDOW, 10, 10, 500, 400, &( *::GetDesktopWindow( ) ),
nullptr, &( *CurrInst ), nullptr );
if( WindowHandle == nullptr )
{
::MessageBox( &( *GetDesktopWindow( ) ), TEXT( "Failed to create the window." ), TEXT( "Failure" ),
( MB_OK | MB_ICONERROR | WS_POPUP ) );
return 1;
}
::ShowWindow( &( *WindowHandle ), SW_SHOW );
MSG Messages;
::ZeroMemory( &Messages, sizeof( MSG ) );
while( GetMessage( &Messages, nullptr, 0, 0 ) != WM_QUIT )
{
TranslateMessage( &Messages );
DispatchMessage( &Messages );
}
return 0;
}
LRESULT CALLBACK WindowProcedure( HWND Handle, UINT Msg, WPARAM WParam, LPARAM LParam )
{
switch( Msg )
{
case WM_QUIT:
PostQuitMessage( 0 );
return 0;
default:
break;
}
return DefWindowProc( &( *Handle ), Msg, WParam, LParam );
}
|