Desparate Debugging
ok i realli need some help here, i got 5 errors to the code below>
#includes .............................
.............................
// WINMAIN ////////////////////////////////////////////////
int WINAPI WinMain( HINSTANCE hinstance, //handle of app.instance
HINSTANCE hprevinstance,
LPSTR lpcmdline, //pointer->cmdline parameters
int ncmdshow) //directs how init.window is to be shown
{
WNDCLASS winclass; // a declaration of a window class
HWND hwnd; // generic window handle
MSG msg; // generic message
HDC hdc; // generic dc
PAINTSTRUCT ps; // generic paintstruct
// first fill in the window class stucture
winclass.style = CS_DBLCLKS | CS_OWNDC | //style field
CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc; //function ptr that points to event handler function
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance; //store instance of app.
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); //@handle of icon to display
winclass.hCursor = LoadCursor(NULL, IDC_ARROW); //@handle to cursor
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); //handle to backgrd brush
winclass.lpszMenuName = NULL; //name of resource for the menu attached to window
winclass.lpszClassName = WINDOW_CLASS_NAME; //@name i wish to refer to my new window class
// register the window class
if (!RegisterClass(&winclass))
return(0);
// create the window
if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, //@preregistered clas
"Crystal Breakers", //@title of window
WS_POPUP | WS_VISIBLE, //@window creation style flags
0,0, //x,y positions to open window at
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN), //width, height of SCREEN
NULL, //handle to parent
NULL , //handle to menu
hinstance, //instance from WinMain
NULL))) //creation parms
return(0);
//SET MENU
HMENU hmymenu = LoadMenu(hinstance, "Crystal_menu");
SetMenu(hwnd, hmymenu);
// save the window handle in a global
main_window_handle = hwnd;
main_instance = hinstance;
// perform all game console specific initialization
Game_Init();
// enter main event loop, loop until there is a WM_QUIT message
while(1)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) //pointed msg structure
{
// test if this is a quit
if (msg.message == WM_QUIT)
break;
// translate any accelerator keys
TranslateMessage(&msg);
// send the message to the window proc
DispatchMessage(&msg);
} // end if
// main game processing goes here
Game_Main();
} // end while
// shutdown game and release all resources
Game_Shutdown();
// return to Windows like this
return(msg.wParam);
} // end WinMain
///////////////////////////////////////////////////////////
// WINX GAME PROGRAMMING CONSOLE FUNCTIONS ////////////////
int Game_Init(void *parms)
{
// this function is where you do all the initialization
// for your game
// create object and test for error
if (DirectDrawCreate(NULL,&lpdd,NULL)!=DD_OK)
return(0);
// set cooperation level to windowed mode normal
if ((lpdd->SetCooperativeLevel(hwnd,DDSCL_ALLOWMODEX | DDSCL_ALLOWREBOOT |
DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN))!=DD_OK)
return(0);
// set the display mode
if ((lpdd->SetDisplayMode(640,480,16))!=DD_OK) //@switch & menu!!
return(0);
// return success
return(1);
} // end Game_Init
///////////////////////////////////////////////////////////
int Game_Shutdown(void *parms)
{
// this function is where you shutdown your game and
// release all resources that you allocated
// release the directdraw object
if (lpdd!=NULL)
lpdd->Release();
// return success
return(1);
} // end Game_Shutdown
///////////////////////////////////////////////////////////
int Game_Main(void *parms)
{
// this is the workhorse of your game it will be called
// continuously in real-time this is like main() in C
// all the calls for you game go here!
// your code goes here
// return success
return(1);
} // end Game_Main
///////////////////////////////////////////////////////////
[edited by - edwinnie on April 7, 2002 4:24:47 AM]
[edited by - edwinnie on April 7, 2002 4:30:06 AM]
It would help if you told us what the errors are ...
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
my header files are these>
//Crystal_menu.h
#define ID_Crystal_menu_File_NewGame 1000
#define ID_Crystal_menu_File_Exit 1001
#define ID_Crystal_menu_Video_640x480x16 2000
#define ID_Crystal_menu_Video_800x600x16 2001
#define ID_Crystal_menu_Video_800x600x32 2002
#define ID_Crystal_menu_Help_About 3000
the resource script is>
#include "Crystal_menu.h"
Crystal_menu MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "New &Game", ID_Crystal_menu_File_NewGame
MENUITEM "E&xit", ID_Crystal_menu_File_Exit
END
POPUP "&Video"
BEGIN
MENUITEM "640x480x16", ID_Crystal_menu_Video_640x480x16
MENUITEM "800x600x16", ID_Crystal_menu_Video_800x600x16
MENUITEM "800x600x32", ID_Crystal_menu_Video_800x600x32
END
POPUP "&Help"
BEGIN
MENUITEM "&About", ID_Crystal_menu_Help_About
END
END
//Crystal_menu.h
#define ID_Crystal_menu_File_NewGame 1000
#define ID_Crystal_menu_File_Exit 1001
#define ID_Crystal_menu_Video_640x480x16 2000
#define ID_Crystal_menu_Video_800x600x16 2001
#define ID_Crystal_menu_Video_800x600x32 2002
#define ID_Crystal_menu_Help_About 3000
the resource script is>
#include "Crystal_menu.h"
Crystal_menu MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "New &Game", ID_Crystal_menu_File_NewGame
MENUITEM "E&xit", ID_Crystal_menu_File_Exit
END
POPUP "&Video"
BEGIN
MENUITEM "640x480x16", ID_Crystal_menu_Video_640x480x16
MENUITEM "800x600x16", ID_Crystal_menu_Video_800x600x16
MENUITEM "800x600x32", ID_Crystal_menu_Video_800x600x32
END
POPUP "&Help"
BEGIN
MENUITEM "&About", ID_Crystal_menu_Help_About
END
END
the errors are>
e:\crystal breakers\crystal.cpp(197) : error C2601: ''WinMain'' : local function definitions are illegal
e:\crystal breakers\crystal.cpp(280) : error C2601: ''Game_Init'' : local function definitions are illegal
e:\crystal breakers\crystal.cpp(304) : error C2601: ''Game_Shutdown'' : local function definitions are illegal
e:\crystal breakers\crystal.cpp(319) : error C2601: ''Game_Main'' : local function definitions are illegal
e:\crystal breakers\crystal.cpp(356) : fatal error C1004: unexpected end of file found
the last error is at the end of the file, after the many slashes
///////////////////////////////////////////////////////////////
e:\crystal breakers\crystal.cpp(197) : error C2601: ''WinMain'' : local function definitions are illegal
e:\crystal breakers\crystal.cpp(280) : error C2601: ''Game_Init'' : local function definitions are illegal
e:\crystal breakers\crystal.cpp(304) : error C2601: ''Game_Shutdown'' : local function definitions are illegal
e:\crystal breakers\crystal.cpp(319) : error C2601: ''Game_Main'' : local function definitions are illegal
e:\crystal breakers\crystal.cpp(356) : fatal error C1004: unexpected end of file found
the last error is at the end of the file, after the many slashes
///////////////////////////////////////////////////////////////
i also got an error due to the header file
something like "unexpected end of file".
something like "unexpected end of file".
I think one of your headers doesn''t close all it''s brackets or braces properly.
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
i think i am missing something to the header file>
wat is it?
i tried adding 2 braces...and that header error is gone
but now got this error>
e:\crystal breakers\crystal_menu.h(2) : error C2447: missing function header (old-style formal list?)
//Crystal_menu.h
{
#define ID_Crystal_menu_File_NewGame 1000
#define ID_Crystal_menu_File_Exit 1001
#define ID_Crystal_menu_Video_640x480x16 2000
#define ID_Crystal_menu_Video_800x600x16 2001
#define ID_Crystal_menu_Video_800x600x32 2002
#define ID_Crystal_menu_Help_About 3000
}
wat is it?
i tried adding 2 braces...and that header error is gone
but now got this error>
e:\crystal breakers\crystal_menu.h(2) : error C2447: missing function header (old-style formal list?)
//Crystal_menu.h
{
#define ID_Crystal_menu_File_NewGame 1000
#define ID_Crystal_menu_File_Exit 1001
#define ID_Crystal_menu_Video_640x480x16 2000
#define ID_Crystal_menu_Video_800x600x16 2001
#define ID_Crystal_menu_Video_800x600x32 2002
#define ID_Crystal_menu_Help_About 3000
}
Stop. Go back to plain C/C++ and console applications. Get a grasp of the language, then come back to Win32.
That''s all I''ll say on the matter.
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions ]
Thanks to Kylotan for the idea!
That''s all I''ll say on the matter.
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions ]
Thanks to Kylotan for the idea!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement