help with win prog
I keep getting an error that I dont understand can anyone help me my code is
#include windows.h //didnt add the < cuz I hear they dont show
#include string.h
const char *CLASSNAME = "Tutorial", *WINNAME = "Tutorial 2 - The Window";
LRESULT CALLBACK WndProc(HWND hWnd, unsigned int iMessage, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
// NOTE: The memset() here is added to deal with this code crashing on
// WinNT (reported by Girish Deodhar, solution due to him as well)
// The extra include statement is for memset() too...
memset(&WndClass, 0, sizeof(WndClass));
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
// Typecast added. This line generated compiler errors on some
// compilers previously. Thanks goes to Anton Rapoport for the tip.
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon(hInstance, NULL);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = CLASSNAME;
WndClass.style = CS_HREDRAW / CS_VREDRAW;
if(!RegisterClass(&WndClass))
return 0;
hWnd = CreateWindow(CLASSNAME, WINNAME, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 300, 100,
NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&Message, hWnd, 0, 0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
switch(iMessage)
{
case WM_CLOSE:
case WM_DESTROY:
if(MessageBox(hWnd, "Do you really want to quit?", "Message", MB_YESNO) == IDYES)
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
and the error is
ompiling...
project.cpp
c:\program files\microsoft visual studio\myprojects\proj\project.cpp(61) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
June 13, 2000 05:06 PM
Code works fine.
My guess is you used VC++ to generate the window for you, then changed or deleted the precompiled header.
Try creating an empty project without precompiled headers, and then add the code as a new file.
As far as #include <windows.h>, try typing it as the following:
#include <windows.h>
Also, as a suggestion, put your code in a source block. Just type:
Just makes things easier to read.
My guess is you used VC++ to generate the window for you, then changed or deleted the precompiled header.
Try creating an empty project without precompiled headers, and then add the code as a new file.
As far as #include <windows.h>, try typing it as the following:
#include <windows.h>
Also, as a suggestion, put your code in a source block. Just type:
[source][/source]
Just makes things easier to read.
what errror messages are you getting? o, btw, when you combine values for you window''s style, you need to do a ''/'' instead of a ''/'', the ''/'' means to logically OR the values together. the slash means divide...
Yesterday is the past, tomorrow is the future. Today is a gift, that is why we call it the present.
What version of Visual C++ are you using? I suppose it doesn''t really matter...
Give this a try:
If you created this file yourself, but created your "Win32" app with the wizard, you will need to add this to the top of any cpp file that you create.
Let me know if it works,
David "Dak Lozar" Loeser
Give this a try:
#include "stdafx.h"
If you created this file yourself, but created your "Win32" app with the wizard, you will need to add this to the top of any cpp file that you create.
Let me know if it works,
David "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
quote: Original post by farmersckn
what errror messages are you getting? o, btw, when you combine values for you window''s style, you need to do a ''/'' instead of a ''/'', the ''/'' means to logically OR the values together. the slash means divide...
heheh >GRIN<
See why he had slashes instead of pipes?
We really need to fix this "feature" of the message board.
I understand why the code converts the pipes to slashes but it is hard to write code on the board when it turns out looking like your a lousy coder
Anyway.... / == / (pipe == slash)
David "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement