Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

krang

my app is still running as a process after i quit *fixed*

This topic is 5410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i have a simple app that displays a window (its code from 32bits.co) and well, it runs when i compile it, but when i quit it, when i click the close button in the corner of the window it closes the window, but when i go to the task manager it says that it is still running and that it is using 99% of the CPU! i dont understand what is happening and was hoping someone could explain it to me please? this is the entire code:
#define WIN32_LEAN_AND_MEAN

#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);

LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	
	WNDCLASSEX wc;

    ZeroMemory(&wc, sizeof(WNDCLASSEX));
    wc.cbSize=sizeof(WNDCLASSEX);                       // size of the window struct in bytes

    wc.style=CS_HREDRAW | CS_VREDRAW | CS_OWNDC;        // window styles to use

    wc.lpfnWndProc=MsgProc;                             // function name of event handler

    wc.hInstance=hInstance;                             // handle to this apps instance

    wc.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);// background colour of window

    wc.hIcon= LoadIcon(NULL, IDI_APPLICATION);          // icon for the app window

    wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);         // icon when minimized to taskbar

    wc.hCursor=LoadCursor(NULL, IDC_ARROW);             // cursor to use for this window

    wc.lpszClassName="MyClass";                        // name for this class


    // Register the window class

    RegisterClassEx( &wc );

    // Create the application's window

    HWND hWnd = CreateWindow("LEM3D", "First Windows App",
        WS_OVERLAPPEDWINDOW, 100, 100, 640, 480,
        NULL, NULL, wc.hInstance, NULL );

    // Show the window

    ShowWindow( hWnd, nCmdShow );
    UpdateWindow( hWnd );

	//handle messages

	MSG msg;
	ZeroMemory( &msg, sizeof(msg) );

	while( (msg.message!=WM_QUIT) || (done!=true))
	{
		if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
		else
		{

		}
	}

    UnregisterClass("MyClass", wc.hInstance );

	return 0;							// Exit The Program

}


LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	HDC hDC;
	PAINTSTRUCT PaintStruct;


    switch( msg )
    {
	case WM_PAINT:
		{
			hDC=BeginPaint(hWnd, &PaintStruct);		// Tell windows we want to update the window


			// Do GDI drawing here


			EndPaint(hWnd, &PaintStruct);
			return 0;
		}
	case WM_KEYDOWN:
		{
			switch(wParam)
			{
				
			case VK_SPACE:
				{
					PostQuitMessage( 0 );
					return 0;			
				}
			}
		}
	
	case WM_DESTROY:
		{
			PostQuitMessage( 0 );
			return 0;
		}
		
	default:	
		return DefWindowProc( hWnd, msg, wParam, lParam );
    }
	
}

I've fixed this now, turns out i had some crappy code in there hehe [] [edited by - krang on February 21, 2004 7:17:11 AM]

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!