• Advertisement

Archived

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

The dreaded WNDCLASSEX

This topic is 5551 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

ok, i wrote this basic shell to expand upon, compiled, ran, and it worked. the only preblem was that it wouldn''t leave...the black screen went away, but it was still listed in the task manager...sitll running...and eating my processer alive! i think it has something to do with WNDCLASSEX, but i''m not sure. anyway, here is the source:
  
#include "stdafx.h"


#define WIN32_LEAN_AND_MEAN //No MFC, at all


#define KEYUP(vk_code)		((GetAsyncKeyState(vk_code) & 0x8000) ? 0:1)
#define KEYDOWN(vk_code)	((GetAsyncKeyState(vk_code) & 0x8000) ? 1:0)


#include "windows.h"
#include "windowsx.h"
#include "ddraw.h"  //for futrue expansion


LRESULT CALLBACK WinProc(HWND hWnd, UINT msg,
						 WPARAM wParam, LPARAM lParam);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	WNDCLASSEX winclass; 
	winclass.cbSize = sizeof(winclass);
	winclass.style = CS_DBLCLKS | CS_OWNDC |
					 CS_HREDRAW | CS_VREDRAW;
	winclass.cbClsExtra = 0;
	winclass.cbWndExtra = 0;
	winclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
	winclass.hCursor = LoadCursor(NULL,IDC_ARROW);
	winclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
	winclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
	winclass.lpfnWndProc = WinProc;
	winclass.hInstance = hInstance;
	winclass.lpszMenuName = NULL;
	winclass.lpszClassName = "WindowClass1";

	RegisterClassEx(&winclass);


	HWND hWnd;

	if(!(hWnd = CreateWindowEx(NULL,"WindowClass1","FirstDD",
								WS_POPUP | WS_VISIBLE,0,0,
								GetSystemMetrics(SM_CXSCREEN),
								GetSystemMetrics(SM_CYSCREEN),
								NULL,NULL,hInstance,NULL)))

			return 0; //Return if false


	if(hWnd == NULL)
	{
		return 0;
	}


	//GameInit();


	MSG msg;

	while(TRUE)
	{
		if(PeekMessage(&msg,hWnd,0,0,PM_REMOVE))
		{
			if(msg.message == WM_QUIT)
				break; //break if were stopping


			TranslateMessage(&msg);

			DispatchMessage(&msg);

		}//end if


		//ok, with that out of the way, let''s do game stuff...


		//GameMain();


	}


	//GameShutdown()

	

	// TODO: Place code here.


	return 0;
}


LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_KEYDOWN:
		DestroyWindow(hWnd);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	default:
		break;
	}

	return DefWindowProc(hWnd,msg,wParam,lParam);
}

  
please excuse the notes to myself... thanks alot... MattS423

Share this post


Link to post
Share on other sites
Advertisement
In your loop change hWnd by NULL like this:

    
while(TRUE) {
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{ if(msg.message == WM_QUIT) break; //break if were stopping TranslateMessage(&msg); DispatchMessage(&msg);

}//end if //ok, with that out of the way, let's do game stuff... //GameMain();

}


[edited by - remi on November 6, 2002 10:27:42 PM]

Share this post


Link to post
Share on other sites

  • Advertisement