Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

could some body help with this code?

Status
Not open for further replies.

tunahead

Programmer
Feb 22, 2003
9
AT
" error C2146: syntax error : missing ';' before identifier 'CreateMainWindow'"


HWND CreateMainWindow(HINSTANCE hInstance)
{
WNDCLASSEX wndClass; //WNDCLASSEX Struktur

//Struktur initialisieren
wndClass.cbSize=sizeof(WNDCLASSEX); //Größe angeben
wndClass.style =CS_DBLCLKS | CS_OWNDC|//Standart
CS_HREDRAW | CS_VREDRAW;//Stile

//Callbackfunktion angeben (noch nicht durchgenommen)
wndClass.lpfnWndProc=MessageHandler;

wndClass.cbClsExtra=0; //Zusätzliche Angaben
wndClass.cbWndExtra=0; //Werden nicht benötigt
wndClass.hInstance=hInstance; //Anwendungsinstanz

//Weisser Pinsel zum füllen des fensterhintergrunds
wndClass.hbrBackground=
(HBRUSH)GetStockObject(WHITE_BRUSH);

//Standart-Mauscursor verwenden
wndClass.hCursor=LoadCursor(NULL, IDC_ARROW);

//Das Fenster soll kein Menü haben
wndClass.lpszMenuName=NULL;

//Der Name der Fensterklasse wird noch beim Aufruf vonCreateWindowEx benötigt
wndClass.lpszClassName="WindowClass";

//Icons für das Fenster festlegen:
wndClass.hIcon=LoadIcon(NULL, IDI_WINLOGO);
wndClass.hIconSm=LoadIcon(NULL, IDI_WINLOGO);

//Fensterklasse registrieren, damit sie von
//CreateWindowEx verwendet werden kann
RegisterClassEx(&wndClass);

//Der Rückgabewert von CreateWindowEx is auch der Rückgabewert von der
//Funktion:
return CreateWindowEx(
NULL, //Ohne erweiterte Stile
"WindowClass", //Klassenname
"Ein einfaches Fenter", //Fenstertitel
WS_OVERLAPPEDWINDOW, //Fenstereingenschaften
WS_VISIBLE,
0, 0, //Anfangsposition
400, 300, //Größe
NULL, //Handle des Elterfensters
NULL, //Handle des Menüs
hInstance, //Anwendungsinstanz
NULL, //Nicht benötigt
);


}


thanks
tunahead
 
Since it says that you are missing a semicolon before the function, try looking for a problem before the declaration of the function :).

I wish I hadn't dropped German, maybe I could read your comments lol.
 
Did my program not work? I will write a short analysis:
1) There are too many arguments to
Code:
CreateWindowEx
- there should be a '|' not a comma between WS_OVERLAPPED and WS_VISIBLE.
2) The error at the beginning is one of two things: either HWND is not being recognized as a typedef (unlikely) OR you are missing a comma before this in your code.
3) Make sure the prototype definition is the same.
If you try the code I wrote, tell me if you get errors and I can help because I wrote it. Adonai :)
 
you have not included some headers and as a result HWND is undefined. You could also have conflicts between includes, for example
//abc.h
#if !defined(abc)
#define abc
..
#endif
//xxx.h
#if defined(xxx)
#define xxx
include<abc.h>
...
#endif

//abc.cpp
#include<xxx.h>//conflict between includes
#include<abc.h>//the content of abc.h will not be visible
Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top