|
From: Michael C U. <mu...@cb...> - 2003-12-24 23:27:26
|
Hi Noorez,
The problem is in your switch structure. Your callback function doesn't
return a value from WM_PAINT. Replace the break statement at the end of
your case with a "return 0" statement, and I think that might fix your
problem.
Also. note that the braces around the code in your WM_PAINT case are not
necessary. You don't need to use braces to group case statements as all of
hem will execute up until it encounters a break or return.
Try replacing "break" with "return 0;" and also removing the braces from
the WM_PAINT case. That might fix your problem.
On Wed, 24 Dec 2003, Noorez Kassam wrote:
> 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
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|