Jump to content
  • Advertisement
Sign in to follow this  
ktuluorion

Switched from VC6 to VC .NET 2002, new problems

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

So, I switched from VC6 to .net 2002, and now my program exits when I try to run it. Here is the code:
#include "main.h"

//////////////This is all boring crap that just starts up the window
///////////////PoOp


LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {   
	case WM_LBUTTONDOWN:
          
	case WM_DESTROY:
            PostQuitMessage( 0 );
            return 0;
	}
 
    return DefWindowProc( hWnd, msg, wParam, lParam );
}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	MSG			msg;
	WNDCLASSEX	wndclass;
    HWND hWnd;    

	wndclass.cbSize			= sizeof(wndclass);
	wndclass.style			= CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc	= MsgProc;
	wndclass.cbClsExtra		= 0;
	wndclass.cbWndExtra		= 0;
	wndclass.hInstance		= hInstance;
	wndclass.hIcon			= LoadIcon( NULL, IDI_APPLICATION );
	wndclass.hCursor		= LoadCursor( NULL, IDC_ARROW );
	wndclass.hbrBackground	= (HBRUSH) GetStockObject (BLACK_BRUSH);
	wndclass.lpszMenuName	= NULL;
	wndclass.lpszClassName	= "RPGWIN";	// window class name
	wndclass.hIconSm		= LoadIcon( NULL, IDI_APPLICATION );

	if( RegisterClassEx( &wndclass ) == 0 ) 
	{
		exit(1);
	}

	hWnd = CreateWindow(	"RPGWIN", //window class name
							"RPG",	//title bar name
							WS_POPUP,
							0,
							0,
							800,
							600,
							NULL,
							NULL,
							hInstance,
							NULL );


	ShowWindow( hWnd, iCmdShow );
	UpdateWindow( hWnd );

    
    gameclass game(hInstance,hWnd);

	while(( msg.message!=WM_QUIT) && (game.quit!=true))
	{
	    
		if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
        {
		TranslateMessage( &msg );
		DispatchMessage( &msg );
		}  
		
		
		else{
	//	POINT point;
	//	GetCursorPos(&point);
	//	game.mx=point.x;
	//	game.my=point.y;
			
	     game.doframe();
		}
	}


	game.cleanup();
	UnregisterClass( "RPGWIN", wndclass.hInstance );
	return 0;
}


and here is my new warning: c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\useoldio.h(29) : warning C4995: '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated main.cpp c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\useoldio.h(29) : warning C4995: '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated c:\balls\main.cpp(64) : warning C4700: local variable 'msg' used without having been initialized Anybody know what I have to do to fix it? edit: Line 29 is this: wndclass.lpfnWndProc = MsgProc; That should still work as far as I know.

Share this post


Link to post
Share on other sites
Advertisement
MSDN:

Compiler Warning (level 1) C4995
'function': name was marked as #pragma deprecated
The compiler encountered a function that was marked with pragma deprecated. The function may no longer be supported in a future release. You can turn this warning off with the warning pragma (example below).
The following sample generates C4995:
// C4995.cpp
// compile with: /W1
#include <stdio.h>
// #pragma warning(disable : 4995)
void func1(void){printf("\nIn func1");}

int main() {
func1();
#pragma deprecated(func1)
func1(); // C4995
}

Share this post


Link to post
Share on other sites
Quote:

So, I switched from VC6 to .net 2002, and now my program exits when I try to run it.

You exit (post a quit message) on a left mouse button click event (WM_LBUTTONDOWN), or is that supposed to happen?

Quote:

c:\balls\main.cpp(64) : warning C4700: local variable 'msg' used without having been initialized

Declare it like this: MSG msg = {0};

Share this post


Link to post
Share on other sites
Quote:
Original post by Archi
MSDN:

Compiler Warning (level 1) C4995
'function': name was marked as #pragma deprecated
The compiler encountered a function that was marked with pragma deprecated. The function may no longer be supported in a future release. You can turn this warning off with the warning pragma (example below).
The following sample generates C4995:
// C4995.cpp
// compile with: /W1
#include <stdio.h>
// #pragma warning(disable : 4995)
void func1(void){printf("\nIn func1");}

int main() {
func1();
#pragma deprecated(func1)
func1(); // C4995
}


I actually read that, but my question is why?
I don't see why this should need that.. how would I create a window without doing that?

Share this post


Link to post
Share on other sites
1) That code will exit as soon as there is a left mouse button click in the message queue.

2) I'd suggest removing the left mouse button check and single stepping the code in the debugger to see exactly where the code fails.

3) As for the warnings, check your #include statements - it's likely you're #include'ing something like: <iostream.h> whereas you should be including the version without the .h, such as: <iostream>

4) The warning is telling you there is an issue on line 29 of useoldio.h - not line 29 of your source code file (it would have that name if there was a problem there)

Share this post


Link to post
Share on other sites
Quote:
Original post by ktuluorion
my program exits when I try to run it.


move that code
Quote:

while(( msg.message!=WM_QUIT) && (game.quit!=true))
{

if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}


else{
//POINT point;
//GetCursorPos(&point);
//game.mx=point.x;
//game.my=point.y;

game.doframe();
}
}

game.cleanup();
UnregisterClass( "RPGWIN", wndclass.hInstance );
return 0;

to the MsgProc() function instead of WinMain()

In your case your app actually works, but a very lttle time ;)

Share this post


Link to post
Share on other sites
I just don't get it.

It works under VC6.0 :(

I mean, if that's the problem, fine.. but why does it work fine if I compile it under 6.0 and not with .net 2002?

Share this post


Link to post
Share on other sites
Quote:
Original post by Archi
Quote:
Original post by ktuluorion
my program exits when I try to run it.


move that code

while(( msg.message!=WM_QUIT) && (game.quit!=true))
{

if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}


else{
//POINT point;
//GetCursorPos(&point);
//game.mx=point.x;
//game.my=point.y;

game.doframe();
}
}

game.cleanup();
UnregisterClass( "RPGWIN", wndclass.hInstance );
return 0;

to the MsgProc() function instead of WinMain()

In your case your app actually works, but a very lttle time ;)


??
How would a window be able to process messages, if your stuck in a while loop in the MsgProc?

Share this post


Link to post
Share on other sites
Quote:
Original post by ktuluorion
I just don't get it.

Just foolow my last post - move message checking and quit to the message pump, not to app's entrance point ;)

Quote:

why does it work fine if I compile it under 6.0 and not with .net 2002?

because vc6 is less compliant with ISO standart.

Share this post


Link to post
Share on other sites
Quote:
Original post by S1CA
1) That code will exit as soon as there is a left mouse button click in the message queue.



Yes, I know that's in there. I like to have a left mouse button click exit me from games that only use the keyboard. It's just a personal habit that I use when I am coding. I plan on removing it when i'm done ;)

Quote:


2) I'd suggest removing the left mouse button check and single stepping the code in the debugger to see exactly where the code fails.


I actually think now that it is crashing somewhere else along the line. I can't really see the debugger because I am using DirectX Graphics, and I don't have window switching in yet so I can't flip back and forth.

Quote:

3) As for the warnings, check your #include statements - it's likely you're #include'ing something like: <iostream.h> whereas you should be including the version without the .h, such as: <iostream>


OK.
Quote:

4) The warning is telling you there is an issue on line 29 of useoldio.h - not line 29 of your source code file (it would have that name if there was a problem there)


Makes sense. Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!