Skip to content

Instantly share code, notes, and snippets.

@aoisensi
Created August 25, 2012 04:07
Show Gist options
  • Save aoisensi/3460535 to your computer and use it in GitHub Desktop.
Save aoisensi/3460535 to your computer and use it in GitHub Desktop.
cpp win form test 2
#include <Windows.h>
#include <tchar.h>
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPInst, LPSTR lpCmd, int nCmd)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MsgProc;
wc.cbClsExtra = 0L;
wc.cbWndExtra = 0L;
wc.hInstance = hInst;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = _T("ilformtest");
wc.hIconSm = NULL;
if(!RegisterClassEx( &wc ))
{
return 0;
}
HWND hWnd = CreateWindow( _T("ilformtest"), _T("WindowName"), WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, hInst, NULL );
ShowWindow( hWnd, SW_SHOWDEFAULT);
//msgloop
MSG msg;
ZeroMemory(&msg, sizeof(msg));
while(msg.message != WM_QUIT)
{
if( PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
UnregisterClass(_T("ilformtest"), hInst);
return 0;
}
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
}
return( DefWindowProc( hWnd, msg, wParam, lParam) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment