Skip to main content
gamedev.net
🔒 Locked

Window Problem (Need help)

Started by podbuster 2 replies 800+ views
Original Post
podbuster
podbuster
I recently found the source code to make a basic window in C++. I created a regular Win32 Application and input the code. Every time I compile the code, I get this error:
  
-----------------------------------
Configuration: Window - Win32 Debug
Compiling...
Window.cpp
d:\program files\microsoft visual studio\myprojects\window\window.cpp(63) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

Window.obj - 1 error(s), 0 warning(s)
-----------------------------------
  
Here is the code I am using:
  
#include <windows.h>

// Message Handling Procedure

LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	switch (Msg)
	{
	case WM_DESTROY:
		{
			// Send a WM_QUIT message, as we want the app to exit once the window is destroyed

			PostQuitMessage(0);
		}
		break;
	}
	// Use the default message handler

	return DefWindowProc(hWnd, Msg, wParam, lParam);
}

// Windows Main function

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX WndClassEx;
	WndClassEx.cbSize			= sizeof(WndClassEx);
	WndClassEx.cbClsExtra		= 0;									// No extra storage

	WndClassEx.cbWndExtra		= 0;									// No extra storage

	WndClassEx.hbrBackground	= (HBRUSH)GetStockObject(WHITE_BRUSH);	// White background

	WndClassEx.hCursor			= LoadCursor(NULL, IDC_ARROW);			// Default arrow cursor

	WndClassEx.hIcon			= LoadIcon(NULL, IDI_APPLICATION);		// Default app icon

	WndClassEx.hIconSm			= LoadIcon(NULL, IDI_APPLICATION);		// Default app icon

	WndClassEx.hInstance		= hInstance;							// Application instance

	WndClassEx.lpfnWndProc		= WndProc;								// Message Procedure

	WndClassEx.lpszClassName	= "Window Class";						// Class name

	WndClassEx.lpszMenuName		= NULL;									// No menu

	WndClassEx.style			= CS_VREDRAW | CS_HREDRAW | CS_OWNDC;	// Class styles


	// Register the window class so it can be used

	if (!RegisterClassEx(&WndClassEx))
	{
		MessageBox(NULL, "Unable to register window class.", "Error", MB_ICONERROR);
		return 0;
	}

	// Create the window

	HWND hWnd = CreateWindowEx(NULL, "Window Class", "Window", WS_VISIBLE | WS_OVERLAPPEDWINDOW, 200, 200, 320, 240, NULL, NULL, hInstance, NULL);
	if (hWnd == NULL)
	{
		MessageBox(NULL, "Unable to create window.", "Error", MB_ICONERROR);
		return 0;
	}

	MSG Msg;

	// Mssage pump

	while (GetMessage(&Msg, NULL, 0, 0) > 0)
	{
		TranslateMessage(&Msg);
		DispatchMessage(&Msg);
	}

	return 0;
}

I would really appreciate any help! Thanks.
  
PodBuster [Edit: Use the [source][/source] tags to get the white boxes; use [code][/code] for just text formatting.] [edited by - Oluseyi on October 9, 2002 10:54:54 PM]
Brian Jones
Brian Jones
I''m not sure if this will solve your problem but go to project->settings C/C++ Tab - where it says "Project options" remove "/Yu [filename]"

I don''t have a signature
I don't have a signature
dedrick
dedrick
just turn off precompiled headers. go to project settings, c++ tab, in the drop down box, select precopiled headers, and tell it not to use them.

alternatively, if you wanted to use precompiled headers, you could, but the correct way to use them is probably beyond the scope of this topic. see the msdn.

luck

dedrick@whiteknucklegames.com
dedrickwww.whiteknucklegames.com
Oluseyi
Oluseyi
quote:
Original post by Brian Jones
I''m not sure if this will solve your problem but go to project->settings C/C++ Tab - where it says "Project options" remove "/Yu [filename]"

An English description would be a bit more helpful .

podbuster, MSVC has this facility called pre-compiled headers. They''re useful, but for very small programs and projects they''re an annoyance (and they confuse learners). By default, a number of C++ projects require them. You need to go into the Projects->Settings... dialog box, select the C/C++ tab and set the "Precompiled headers" radio boxes to "Never" (or "None", I forget which).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.