Advertisement

2 windows, 1 opengl and 1 normal ??

Started by May 13, 2002 08:51 AM
-1 comments, last by Xces 22 years, 9 months ago
Hey there, I want to present a normal windows screen so my users can select some options before my opengl application starts. Can anybody give me some source code? I edited WinMain in Nehe''s class; this is what i have come up with:
  
// Process Window Message Callbacks for Options screen

LRESULT CALLBACK OptionsProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	return DefWindowProc (hWnd, uMsg, wParam, lParam);					// Pass Unhandled Messages To DefWindowProc

}
  
and
  
	//------------------------------------------------------------------

	// Show option screen

	HINSTANCE	hInst;
	WNDCLASSEX	wc;
	HWND		hWnd;

	ZeroMemory (&wc, sizeof (WNDCLASSEX));	

	// Fill in window class structure with parameters that describe the

	// main window.

	//...................

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = (WNDPROC)OptionsProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon(hInstance, "itxTest");
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName = "itxTest";
	wc.lpszClassName = "itxTest";
	wc.cbSize = sizeof(WNDCLASSEX);

	// Register the window class

	//...........................

	if ( !RegisterClassEx( &wc ) )
		return( FALSE );	 

	// Save the instance handle for use in

	// the application.

	//.................

	hInst = hInstance;

	// Create the main application window

	//...................................

	hWnd = CreateWindow(
		"itxTest", // See RegisterClass() call.

		"My Application", // Text for window title bar.

		WS_OVERLAPPEDWINDOW, // Window style.

		CW_USEDEFAULT, 0,
		CW_USEDEFAULT, 0, // Use default positioning

		NULL, // Overlapped windows have no parent.

		NULL, // Use the window class menu.

		hInstance, // This instance owns this window.

		NULL ); // We don’t use any data in our WM_CREATE


	if ( hWnd == NULL )
		return( FALSE );

	// Show the window.

	//.................

	ShowWindow( hWnd, nCmdShow );

	// Process application messages until the application closes

	//.......................................

	while( GetMessage( &msg, NULL, 0, 0) )
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	UnregisterClass ("itxTest", hInstance);		// UnRegister Window Class

	//------------------------------------------------------------------


	MessageBox (HWND_DESKTOP, "this is a test", "Error", MB_OK | MB_ICONEXCLAMATION);


	// Fill Out Application Data

	application.className = "OpenGL";									// Application Class Name

	application.hInstance = hInstance;									// Application Instance


	// Fill Out Window

	ZeroMemory (&window, sizeof (GL_Window));							// Make Sure Memory Is Zeroed

	window.keys					= &keys								// Window Key Structure

	window.init.application		= &application							// Window Application

	window.init.title			= "SMS-Screen";							// Window Title

	window.init.width			= 800;									// Window Width

	window.init.height			= 600;									// Window Height

	window.init.bitsPerPixel	= 16;									// Bits Per Pixel

	window.init.isFullScreen	= (MessageBox (HWND_DESKTOP, "Would You Like To Run In Fullscreen Mode?", "Start FullScreen?", MB_YESNO | MB_ICONQUESTION) == IDYES);									// Fullscreen? (Set To TRUE)


	ZeroMemory (&keys, sizeof (Keys));									// Zero keys Structure


	// Register A Class For Our Window To Use

	if (RegisterWindowClass (&application) == FALSE)					// Did Registering A Class Fail?

	{
		// Failure

		MessageBox (HWND_DESKTOP, "Error Registering Window Class!", "Error", MB_OK | MB_ICONEXCLAMATION);
		return -1;														// Terminate Application

	}

  
But it does NOT get to "This is a test". Where is the error?

This topic is closed to new replies.

Advertisement