Jump to content
  • Advertisement

Archived

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

dave

Problem Creating Normal Window...

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

Thanks in advance to anyone who can help me. The code below is the problem. Basically what i have done is i have a standard WinMain function declared correctly, it works, below is where i have tried to move the windows creation code to a function called WinMainBase which lies inside a class. I have passed all appropriate variables to the function and all possible handles are available to it. The errors that the compiler gives are : error C2440: ''initializing'' : cannot convert from '''' to ''long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'' None of the functions with this name in scope match the target type error C2440: ''initializing'' : cannot convert from ''struct HINSTANCE__ *'' to ''int'' This conversion requires a reinterpret_cast, a C-style cast or function-style cast error C2440: ''initializing'' : cannot convert from ''char [11]'' to ''struct HBRUSH__ *'' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Error executing cl.exe. Creating browse info file... RobustBasicWindow.exe - 3 error(s), 0 warning(s)
WinMainBase( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR, INT, HWND hWnd )
{
	l_hWnd = hWnd;

    WNDCLASS wndClass = {	0,
							MsgProc, 
							0, 
							0, 
							hInst,
							NULL,
							NULL,
							NULL,
							NULL, 
							"D3D Window" };

    RegisterClass( &wndClass );

    l_hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 01: CreateDevice", 
                              WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
                              GetDesktopWindow(), NULL, wndClass.hInstance, NULL );
	
	if (l_hWnd
		== NULL)
		MessageBox(l_hWnd, "Function CreateWindow() Failed!", "Function Failure!", MB_OK);
I have also tried using the class WNDCLASSEX and RegisterEx as well and the same problem occurs. The only way i can get the code to compile is if i remove teh "msgProc" parameter. BTW the MsgProc exists and is also a function inside the same class. Hope someone can help regards, ace

Share this post


Link to post
Share on other sites
Advertisement
A window''s msgproc cannot be inside a class unless they are static .
But you could make it static and then store a pointer to your class
in your window''s user data.

Sorry for my bad English.
I hope I helped.


Kam1kaz3

Share this post


Link to post
Share on other sites
Fror more detail on that whole process (encapsulating a window), see the article at http://www.gamedev.net/reference/articles/article1810.asp

It''s all about that whole situation.

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.

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!