please help me. i am almost...
please help me. I am almost on my last leg trying to get a program to work. I am using borland C++ 5, and i am trying to make a windows 98 program. I get 7 errors when i try to compile. they all seem to be undefined symbols or calls to undeclared functions. someone suggested that i should play around with my header/lib paths. i can get to the screen to do this (by right clicking on one of the nodes). I dont know what to do from here.
can someone please help me?
- Moe -
Are you using the borland libs (and including them in your project)? There is a special set of libs you must use for borland compilers.
--TheGoop
--TheGoop
Mr. Moe, are you using DirectX? If so, make sure you''re using the Borland specific DirectX libraries. And if you''re trying to use multimedia stuff (like sound), you might need to manually include the winmm.lib file in your project. Other than that, everything should already be configured for you. Could you be more specific with the errors so more people could help you out?
Al
Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
Alright. You want specific errors, here we go:
Type name expected
Undefined Symbol szWinName
Undefined symbol WindowFunc
Undefined symbol IDI_WINDOWLOGO
called to undefined function RegisterClassEx
Undefined symbol CW_USERDEFAULT
Type name expected
How should i go about including the borland libs.
BTW I''m not using directX (yet).
- Moe -
Type name expected
Undefined Symbol szWinName
Undefined symbol WindowFunc
Undefined symbol IDI_WINDOWLOGO
called to undefined function RegisterClassEx
Undefined symbol CW_USERDEFAULT
Type name expected
How should i go about including the borland libs.
BTW I''m not using directX (yet).
- Moe -
I don''t think I even use those identifiers in my Windows functions. Are you sure you have all the names right? I guess I''ll end your suffering now, Moe, and let you see the source code I basically use as the framework for all my DirectX applications. I think it''s really easy to understand the way I have it broken down. Here''s the code (long):
I use Visual C++ myself, but I think this code should work on any compiler. It''s basically just the code from Andre Lamothe''s game programming books, but very slightly modified. Programming Windows code is so tedious, so maybe the code will help you out.
Good luck,
Al
#define WIN32_LEAN_AND_MEAN// INCLUDES /////////////////////////////////////////////////////////#include // include windows stuff#include // DEFINES //////////////////////////////////////////////////////////// defines for windows #define WINDOW_CLASS_NAME "WINCLASS" // class name#define WINDOW_WIDTH 640 // size of window viewport#define WINDOW_HEIGHT 480// GLOBALS //////////////////////////////////////////////////////////// WindowsHWND main_window_handle = NULL; // save the window handleHINSTANCE main_instance = NULL; // save the instanceBOOL bActive; // tracks if application has focus// PROTOTYPES ///////////////////////////////////////////////////////int Game_Init(); // Performs game specific initializationint Game_Main(); // Main game loopint Game_Shutdown(); // Shuts down game before exiting// WINDOWS FUNCTIONS /////////////////////////////////////////////////************************************************************************WindowProc()Handles all Windows messages************************************************************************/LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){// this is the main message handler of the systemPAINTSTRUCT ps; // used in WM_PAINTHDC hdc; // handle to a device context// what is the message switch(msg) { case WM_CREATE: { // do initialization stuff here return(0); } break; case WM_PAINT: { // start painting hdc = BeginPaint(hwnd,&ps); // end painting EndPaint(hwnd,&ps); return(0); } break; case WM_DESTROY: { // kill the application PostQuitMessage(0); return(0); } break; case WM_ACTIVATEAPP: { // check if application has the focus bActive = wparam; return(0); } break; default:break; } // end switch// process any messages that weren''t taken care of return (DefWindowProc(hwnd, msg, wparam, lparam));} // end WinProc/************************************************************************WinMain()The big daddy************************************************************************/int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow){WNDCLASS winclass; // this will hold the class we createHWND hwnd; // generic window handleMSG msg; // generic message// first fill in the window class stucturewinclass.style = CS_DBLCLKS / CS_OWNDC / CS_HREDRAW / CS_VREDRAW;winclass.lpfnWndProc = WindowProc;winclass.cbClsExtra = 0;winclass.cbWndExtra = 0;winclass.hInstance = hinstance;winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);winclass.hCursor = LoadCursor(NULL, IDC_ARROW);winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME;// register the window classif (!RegisterClass(&winclass)) return(0);// create the windowif (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class "Generic Game", // title WS_POPUP / WS_VISIBLE, 0,0, // x,y WINDOW_WIDTH, // width WINDOW_HEIGHT, // height NULL, // handle to parent NULL, // handle to menu hinstance,// instance NULL))) // creation parmsreturn(0);// save the window handle and instance in a globalmain_window_handle = hwnd;main_instance = hinstance;// perform all game console specific initializationGame_Init();// enter main event loopwhile(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // 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 else if (bActive) // does application have focus // main game loop Game_Main(); else WaitMessage(); } // end while// shutdown game and release all resourcesGame_Shutdown();// return to Windowsreturn(msg.wParam);} // end WinMain// GAME FUNCTIONS ////////////////////////////////////////////////////************************************************************************Game_InitInitializes DirectX and game objects************************************************************************/int Game_Init(){ /* initialize everything ... */ // return success to Windows return(1);} // end Game_Init/************************************************************************Game_ShutdownShuts down DirectX and frees memory from game************************************************************************/int Game_Shutdown(){ /* shutdown everything ... */ // return success to windows return(1);} // end Game_Shutdown/************************************************************************Game_MainMain game loop where all the action takes place************************************************************************/int Game_Main(){ /* game logic ... */ // return success return(1);} // end Game_Main
I use Visual C++ myself, but I think this code should work on any compiler. It''s basically just the code from Andre Lamothe''s game programming books, but very slightly modified. Programming Windows code is so tedious, so maybe the code will help you out.
Good luck,
Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
Wait, Mr. Moe!
hehe...I think that code got screwed up when I posted it. All the whitespaces and formatting got messed up when I pasted in the code. And the include files got erased somehow. The include files are supposed to be windows.h and windowsx.h
That should be it.
Good luck,
Al
hehe...I think that code got screwed up when I posted it. All the whitespaces and formatting got messed up when I pasted in the code. And the include files got erased somehow. The include files are supposed to be windows.h and windowsx.h
That should be it.
Good luck,
Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
BTW, just for your information, here is the source code i copied from the book
// minimal windows skeleton
#include
LRESULT CALLBACK WindowFunc (HWND, UNIT, WPARAM, LPARAM);
char szWinNaMe[] = "MyWin"; //name of windows class
int WINAPI WinMain (HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
//define a window class
wcl.cbSize = sizeof (WNDCLASSEX);
wcl.hInstance = hThisInst; //handle to this instance
wcl.lpszClassName = szWinName; //window class name
wcl.lpfnWndProc = WindowFunc; //window function
wcl.style = 0; //default style
wcl.hIcon = LoadIcon (NULL, IDI_APPLICATION); //standard icon
wcl.hIconSm = LoadIcon (NULL, IDI_WINDOWLOGO); //small icon
wcl.hCursor = LoadCursor (NULL, IDC_ARROW); //cursor style
//make the window background white
wcl.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
//register the window class
if (!RegisterCLassEx(& wcl)) return 0;
//now that a window class has been registered, a window can be created
hwnd = CreateWindow (
szWinName, //name of window class
"Windows 98 Skeleton", //title
WS_OVERLAPPEDWINDOW, //window style - normal
CW_USERDEFAULT, //x coordinate - let windows decide
CW_USERDEFAULT, //y coordinate - let windows decide
CW_USERDEFAULT, //width - let windows decide
CW_USERDEFAULT, //height - let windows decide
HWND_DESKTOP, //no parent window
NULL, //no menu
hThisInst, //handle of this instance of the program
NULL //no additional arguments
);
//display the window
ShowWindow (hwnd, nWinMode);
UpdateWindow (hwnd);
//create the message loop
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg); //translate keyboard messages
DispatchMessage (&msg); //return control to windows 98
}
return msg.wParam;
}
//this function is called by windows 98 and is passed messages
//from the message queue
LRESULT CALLBACK WindowFunc (HWND hwnd, UNIT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_DESTROY: //terminate the program
PostQuitMessage (0);
break;
defualt:
//let windows 98 process any messages not specified in the preceding swith statement
}
return 0;
}
// minimal windows skeleton
#include
LRESULT CALLBACK WindowFunc (HWND, UNIT, WPARAM, LPARAM);
char szWinNaMe[] = "MyWin"; //name of windows class
int WINAPI WinMain (HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
//define a window class
wcl.cbSize = sizeof (WNDCLASSEX);
wcl.hInstance = hThisInst; //handle to this instance
wcl.lpszClassName = szWinName; //window class name
wcl.lpfnWndProc = WindowFunc; //window function
wcl.style = 0; //default style
wcl.hIcon = LoadIcon (NULL, IDI_APPLICATION); //standard icon
wcl.hIconSm = LoadIcon (NULL, IDI_WINDOWLOGO); //small icon
wcl.hCursor = LoadCursor (NULL, IDC_ARROW); //cursor style
//make the window background white
wcl.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
//register the window class
if (!RegisterCLassEx(& wcl)) return 0;
//now that a window class has been registered, a window can be created
hwnd = CreateWindow (
szWinName, //name of window class
"Windows 98 Skeleton", //title
WS_OVERLAPPEDWINDOW, //window style - normal
CW_USERDEFAULT, //x coordinate - let windows decide
CW_USERDEFAULT, //y coordinate - let windows decide
CW_USERDEFAULT, //width - let windows decide
CW_USERDEFAULT, //height - let windows decide
HWND_DESKTOP, //no parent window
NULL, //no menu
hThisInst, //handle of this instance of the program
NULL //no additional arguments
);
//display the window
ShowWindow (hwnd, nWinMode);
UpdateWindow (hwnd);
//create the message loop
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg); //translate keyboard messages
DispatchMessage (&msg); //return control to windows 98
}
return msg.wParam;
}
//this function is called by windows 98 and is passed messages
//from the message queue
LRESULT CALLBACK WindowFunc (HWND hwnd, UNIT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_DESTROY: //terminate the program
PostQuitMessage (0);
break;
defualt:
//let windows 98 process any messages not specified in the preceding swith statement
}
return 0;
}
no problem here, bigshot. check out the source code i had and see if you can figure out what i was doing wrong.
(you did have me wondering there for a bit, include what?)
(you did have me wondering there for a bit, include what?)
I''ve never even heard of the WindowFunc function, but then again I don''t do a lot of Windows stuff, so I wouldn''t know if that''s valid or not.
There''s something about my code that I don''t like. If the application is running full screen (like it does... I also have separate code for windowed games), if you press CTRL-TAB or CTRL-ESC or something that would minimize the application, when you try to restore the it again, it just crashes. Does anyone know how to fix that? Maybe WindowProc needs additional messages to process.
Al
There''s something about my code that I don''t like. If the application is running full screen (like it does... I also have separate code for windowed games), if you press CTRL-TAB or CTRL-ESC or something that would minimize the application, when you try to restore the it again, it just crashes. Does anyone know how to fix that? Maybe WindowProc needs additional messages to process.
Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement