Original Post
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:
Here is the code I am using:
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]
----------------------------------- 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) -----------------------------------
#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.