|
From: Noorez K. <coo...@ho...> - 2003-12-24 21:27:03
|
This WinApp closes too fast to see results
#include <windows.h>
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsgId, WPARAM wParam, LPARAM
lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
pszCmdLine, int nCmdShow)
{
static char szAppName[] = "hello";
HWND hWnd;
MSG msg;
WNDCLASSEX wndClass;
//register class
wndClass.style = 0;
wndClass.lpfnWndProc = WindowProc;
wndClass. cbClsExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon( hInstance, szAppName);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = szAppName;
wndClass.hIconSm = wndClass.hIcon;
if(RegisterClassEx(&wndClass)==0)//register class...
return 0; //quit if it doesn't work
//now create window
hWnd = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance,
NULL);
if(hWnd == NULL)
return 0;
ShowWindow(hWnd, nCmdShow);
UpdateWindow( hWnd );
while( GetMessage(&msg, NULL, 0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//process functions
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsgId, WPARAM wParam, LPARAM
lParam)
{
static char *pszHello = "Hello, world";
switch(uMsgId)
{
case WM_PAINT:
{
HDC hDC;
PAINTSTRUCT paintStruct;
hDC = BeginPaint( hWnd, &paintStruct);
TextOut(hDC, 0,0, pszHello, lstrlen(pszHello));
EndPaint( hWnd, &paintStruct );
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,uMsgId,wParam,lParam);
}
return 0;
}
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/photos&pgmarket=en-ca&RU=https%3a%2f%2f2.zoppoz.workers.dev%3a443%2fhttp%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
|