Created
August 25, 2012 03:22
-
-
Save aoisensi/3459883 to your computer and use it in GitHub Desktop.
cpp win form test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <tchar.h> | |
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); | |
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPInst, LPSTR lpCmd, int nCmd) | |
{ | |
WNDCLASSEX wc; | |
wc.cbClsExtra = sizeof(WNDCLASSEX); | |
wc.style = CS_CLASSDC; | |
wc.lpfnWndProc = WndProc; | |
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; | |
RegisterClassEx( &wc ); | |
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 CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) | |
{ | |
switch( msg ) | |
{ | |
case WM_DESTROY: | |
PostQuitMessage( 0 ); | |
return 0; | |
default: | |
return( DefWindowProc( hWnd, msg, wParam, lParam) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment