Win32 run problems

Started by
8 comments, last by Arkantis 19 years, 10 months ago
Hey, i''m new to win api programming so i picked up a book and I am trying to make a wrapper class that will register/create/handle messages for the window... So far everything I''ve done is right according to the book and the lack of compile errors(the book had a wrapper example) yet the program starts and I see a window flash for a milisecond and it goes away.... I''m using VC++ 6.0, and under debug it gives these problems Loaded ''ntdll.dll'', no matching symbolic information found. Loaded ''D:\WINDOWS\system32\kernel32.dll'', no matching symbolic information found. Loaded ''D:\WINDOWS\system32\user32.dll'', no matching symbolic information found. Loaded ''D:\WINDOWS\system32\gdi32.dll'', no matching symbolic information found. Loaded ''D:\WINDOWS\system32\advapi32.dll'', no matching symbolic information found. Loaded ''D:\WINDOWS\system32\rpcrt4.dll'', no matching symbolic information found. The thread 0x3BC has exited with code 0 (0x0). anyone know?
Advertisement
Those aren''t errors. Please post your code.

Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud
it compiles but the debugger gives me the output as shown in original post

Main.cpp
GameBase *g_base;LRESULT WINAPI WndProc(HWND, UINT, WPARAM, LPARAM);int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){	MSG msg;	g_base = new GameBase(hInstance, "Game", "Game", 680, 480);	if(!g_base->init(nShowCmd))		return false;	while(TRUE)	{		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))		{			if(msg.message == WM_QUIT)				break;			TranslateMessage(&msg);			DispatchMessage(&msg);		}	}	return msg.wParam;}LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){	return g_base->HandleEvent(hwnd, msg, wParam, lParam);}

gamebase.h
class GameBase{public:	//constructor...	GameBase(HINSTANCE hInstance, LPTSTR szWinClass, LPTSTR szTitle,			int w, int h);	virtual ~GameBase();	bool init(int iCmdShow); // inits the window	LRESULT HandleEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); // message handler	HINSTANCE GetInstance() { return m_hInstance; }	HWND GetWindow() { return m_hwnd; }	void SetWindow(HWND hwnd) { m_hwnd = hwnd; }	int GetHeight() { return m_height; }	int GetWidth() { return m_width; }protected:	HINSTANCE m_hInstance;	HWND m_hwnd;	string m_title;	string m_class;	int m_width, m_height;};

-gamebase.cpp
LRESULT WINAPI WndProc(HWND, UINT, WPARAM, LPARAM);GameBase::GameBase(HINSTANCE hInstance, LPTSTR szWinClass, LPTSTR szTitle, int w = 640, int h = 480){	m_hInstance = hInstance;	m_width = w;	m_height = h;	m_title = szTitle;	m_class = szWinClass;}GameBase::~GameBase(){}bool GameBase::init(int iCmdShow){	WNDCLASSEX wc;		wc.cbSize = sizeof(wc);	wc.style = CS_HREDRAW | CS_VREDRAW;	wc.lpfnWndProc = WndProc;	wc.cbClsExtra = 0;	wc.cbWndExtra = 0;	wc.hInstance = m_hInstance;	wc.hIcon = 0;	wc.hCursor = LoadCursor(NULL, IDC_ARROW);	wc.hbrBackground = 0;	wc.lpszMenuName = NULL;	wc.lpszClassName = m_class.c_str();	wc.hIconSm = 0;	if(!RegisterClassEx(&wc))	{		MessageBox(NULL, "Error registering the class", "error", MB_OK | MB_ICONERROR);		return false;	}	m_hwnd = CreateWindow(m_class.c_str(), m_title.c_str(), WS_OVERLAPPEDWINDOW,							CW_USEDEFAULT, CW_USEDEFAULT, m_width, m_height,							NULL, NULL, m_hInstance, NULL);	if(!m_hwnd)	{		MessageBox(NULL, "Error creating the window", "Error", MB_OK | MB_ICONERROR);		return false;	}	ShowWindow(m_hwnd, iCmdShow);	UpdateWindow(m_hwnd);	return true;}LRESULT GameBase::HandleEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){	switch (msg)	{	case WM_CREATE:	case WM_DESTROY:		PostQuitMessage(0);		break;	case WM_CLOSE:		DestroyWindow(m_hwnd);		break;	}	return DefWindowProc(hwnd, msg, wParam, lParam);}




[edited by - Arkantis on June 9, 2004 2:13:45 PM]
But what we need to know:
What is the error? The debug output does not contain ANY error messages, so where is the problem?
the application loads, i see a quick flash of a window than its gone, i dont want it to be gone =/, i want it to stay and be initialized =p .....
the debugger outputs:
Loaded ''ntdll.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\kernel32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\user32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\gdi32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\advapi32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\rpcrt4.dll'', no matching symbolic information found.The thread 0x3BC has exited with code 0 (0x0).
Your error lies in the gamebase.cpp module

switch (msg)
{
3 case WM_CREATE:
4 case WM_DESTROY:
5 PostQuitMessage(0);
break;

case WM_CLOSE:
DestroyWindow(m_hwnd);
break;
}

According to line 3 4 and 5, when your window is created, the
message handler will receive a WM_CREATE message. The effect
in your switch is that it will call the PostQuitMessage
pocedure that will close your window and finish the application.

You should remove the WM_CREATE part !
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;

Hope it helps !

There is no problem, only solutions...
Looks like Dark Pixel found the answer.
Arkantis, those aren''t errors, they just mean that you won''t be able to debug into those files because they are standard windows files (built as ''release'' versions so that they don''t contain any debugging info or "symbolic information" as the messages put it)
BTW, that message loop is horrible. Use the example on WinProg.net, there is no need to use PeekMessage() in a basic message loop.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
The point DarkPixel is trying to make is that the cases in your switch statement are falling through. Put a break in for the WM_CREATE case and it''ll be fine.

-Auron
learn to crawl before you try to run: http://gamedev.net/community/forums/forum.asp?forum_id=31

This topic is closed to new replies.

Advertisement