Jump to content

  • Log In with Google      Sign In   
  • Create Account


please help me. i am almost...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 Moe   Crossbones+   -  Reputation: 1235

Like
Likes
Like

Posted 12 February 2000 - 06:55 AM

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 -

Sponsor:

#2 Facehat   Members   -  Reputation: 696

Like
Likes
Like

Posted 12 February 2000 - 07:10 AM

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

#3 Bigshot   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 February 2000 - 07:32 AM

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

#4 Moe   Crossbones+   -  Reputation: 1235

Like
Likes
Like

Posted 12 February 2000 - 01:29 PM

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 -



#5 Bigshot   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 February 2000 - 02:22 PM

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):


#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 //////////////////////////////////////////////////////////
// Windows
HWND main_window_handle = NULL; // save the window handle
HINSTANCE main_instance = NULL; // save the instance
BOOL bActive; // tracks if application has focus



// PROTOTYPES ///////////////////////////////////////////////////////
int Game_Init(); // Performs game specific initialization
int Game_Main(); // Main game loop
int 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 system
PAINTSTRUCT ps; // used in WM_PAINT
HDC 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 create
HWND hwnd; // generic window handle
MSG msg; // generic message

// first fill in the window class stucture
winclass.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 class
if (!RegisterClass(&winclass))
return(0);

// create the window
if (!(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 parms
return(0);

// save the window handle and instance in a global
main_window_handle = hwnd;
main_instance = hinstance;

// perform all game console specific initialization
Game_Init();

// enter main event loop
while(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 resources
Game_Shutdown();

// return to Windows
return(msg.wParam);

} // end WinMain



// GAME FUNCTIONS ///////////////////////////////////////////////////
/************************************************************************
Game_Init
Initializes DirectX and game objects
************************************************************************/
int Game_Init()
{
/* initialize everything
...
*/

// return success to Windows
return(1);

} // end Game_Init



/************************************************************************
Game_Shutdown
Shuts down DirectX and frees memory from game
************************************************************************/
int Game_Shutdown()
{
/* shutdown everything
...
*/

// return success to windows
return(1);

} // end Game_Shutdown



/************************************************************************
Game_Main
Main 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

#6 Moe   Crossbones+   -  Reputation: 1235

Like
Likes
Like

Posted 12 February 2000 - 02:26 PM

thanks bigshot, I''ll give it a try



#7 Bigshot   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 February 2000 - 02:29 PM

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

#8 Moe   Crossbones+   -  Reputation: 1235

Like
Likes
Like

Posted 12 February 2000 - 02:40 PM

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;
}





#9 Moe   Crossbones+   -  Reputation: 1235

Like
Likes
Like

Posted 12 February 2000 - 02:42 PM

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?)




#10 Bigshot   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 February 2000 - 04:13 AM

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

#11 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 13 February 2000 - 05:59 AM

what book are you using? I first learned windows programming from WINDOWS GAME PROGRAMMING FOR DUMMIES by LaManthe. He uses WNDCLASS rather than WNDCLASSEX. It works for me, and you should learn to use it. I find it a lot easier than what you are doing.

#12 Mezz   Members   -  Reputation: 570

Like
Likes
Like

Posted 13 February 2000 - 06:17 AM

Hey Moe, I think I have some of the things you were doing wrong,

The error ''undefined... szWinName''
is because when you defined it, you put szWinNaMe
and C++ is case sensitive, so that should take care of that error.

''Undefined symbol WindowFunc''
I''m not sure about this, try defining your WindowFunc before WinMain(), it could just be that the compiler is being a sod, but I don''t see why (just try it)

''Undefined symbol IDI_WINDOWLOGO''
its IDI_WINLOGO, not IDI_WINDOWLOGO, I believe.

''called to undefined function RegisterCLassEx''
a typo, in your source you call RegisterCLassEx
drop the L to lower case.

''Undefined symbol CW_USERDEFAULT''
Its USEDEFAULT, and you should be using CreateWindowEx if you have a WNDCLASSEX structure.

I think thats right, If I''ve made any mistakes let me know,

Take it easy,

-Mezz



#13 Moe   Crossbones+   -  Reputation: 1235

Like
Likes
Like

Posted 13 February 2000 - 11:26 AM

I am using ''windows 98 programming from the ground up'' (by Herbet Schildt).

Thanks for the ideas about those errors. Maybe i can get things cleared ups right awsy.

I will be sure to take things easy (I already am).

- Moe -

#14 Moe   Crossbones+   -  Reputation: 1235

Like
Likes
Like

Posted 14 February 2000 - 11:25 AM

I got the WINLOGO fixed, and same with the szWinName, ClassEx. The USERDEFAULT is still giving me trouble along with the two ''type name expected'' errors. I think I will give bigshot''s code a try.



#15 Armitage   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 February 2000 - 11:48 AM

Try CW_USEDEFAULT...
And
LRESULT CALLBACK WindowFunc (HWND, UNIT, WPARAM, LPARAM);
should be
LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);



A polar bear is a rectangular bear after a coordinate transform.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS