Jump to content
  • Advertisement

Archived

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

Arkantis

Win32 run problems

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

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
But what we need to know:
What is the error? The debug output does not contain ANY error messages, so where is the problem?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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 !

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
BTW, that message loop is horrible. Use the example on WinProg.net, there is no need to use PeekMessage() in a basic message loop.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
learn to crawl before you try to run: http://gamedev.net/community/forums/forum.asp?forum_id=31

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!