• Advertisement

Archived

This topic is now archived and is closed to further replies.

help this pitiful soul

This topic is 6540 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i as a beginner programmer, i have just been getting into windows 98 programming. i am using borland C++ 5 (or so). i tried to write a simple program that displays a window (with no menus, or anything). i copied the code right out of the book, but i get 7 error messages. it seems to me that borland c++ won''t recognize the windows 98 functions. does bc++ only work with win 95? -Moe- (someone said that there should be more rhymes in posts so i will give it a try) complain, complain, thats all i get its a problem, i will bet, can borland do it? did i blew it? oh help this soul so it can rest from this problem the dang pest just let me do it cuz i know i can do it and if i cant there''ll be no show

Share this post


Link to post
Share on other sites
Advertisement
I would be glad to help you, but you have not told me what is wrong. When you post to a board and say, my code does not work, it is not very helpful. Post the error messages you got, also the book you are copying code from would be helpful.
Later,
Eck

Share this post


Link to post
Share on other sites
I bet you it''s because you chose the wrong project from the New.. menu. It should be "Win 32 Console" .

JoeG

Share this post


Link to post
Share on other sites
Okay here is the problem (sorry for not posting it before)

I am trying to get a win98 skeleton program to work. When I try to compile i get the following errors:

Type name expected
Undefined symbol WindowFunc
wrong number of arguments in call of macro CreateAWindow
expression syntax
Undefined symbol nWinMode
type name expected

Now here is the code i copied from the book:

//a minimal win98 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 nWimMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;

//define a window class
wcl.hInstance = hThisInst; //handle to this instance
wcl.lpszClassName = szWinName; //window class name
wcl.lpfnWndProc = WindowFunc; //windows function
wcl.style = 0; //default style

wcl.hIcon = LoadIcon (NULL, IDI_APPLICATION); //standard icon
wcl.hIconSm = LoadIcon (NULL, IDI_WINLOGO); //small icon
wcl.hCursor = LoadCursor (NULL, IDC_ARROW); // cursor style

wcl.lpszMenuName = NULL; //no menu
wcl.cbClsExtra = 0; //no extra info needed
wcl.cbWndExtra = 0; //no extra info needed

//make the background brush 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 coord - let windows decide
CW_USERDEFAULT, //y coord - let windows decide
CW_USERDEFAULT, //width - let windows decide
CW_USERDEFAULT, //hight - 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;
default:
//let windows 98 process any messages not specified in the proceeding
//switch statement
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}

Any ideas that could be causing those errors?
(i dont think it is from selecting console (i am sure that i hit GUI)

Share this post


Link to post
Share on other sites
well I''m not sure if this is a large part of your problem but this bit:
LRESULT CALLBACK WIndowFunc(HWND, UNIT, WPARAM, LPARAM);
the I in WIndow is capitalized, and I don''t think you want it to be. (maybe that''s just a typo the the message board)

Share this post


Link to post
Share on other sites
I had this problem b4. Try
#define WIN32
or
#define _WIN32
or add it to your project-compiler-preprocessor
or something like this before including windows.h

Happy trying.

Share this post


Link to post
Share on other sites
Is it just me, or is there nothing following the #include statement... I might have missed something or looked at it wrong, no time now for reading posts...

--the Rabid_Stick

P.S. does anyone know the Magic Knight Rayearth theme song? if so, how did you get it out of your head?

Share this post


Link to post
Share on other sites
You''ve also spelt nWinMode wrong in the declaration of WinMain

No sense being pessimistic. It wouldn''t work anyway.

Share this post


Link to post
Share on other sites
I found the place where i spelled nWinName wrong. Is it just me or is windows programming a big pain in the butt?

Share this post


Link to post
Share on other sites
no Moe, it isn''t just you.. windows programming is a pain in the.. uhh, butt...
i''m a bit new to it myself, though i''m starting to get a handle on it.. (i''ve found Tricks of the Windows Game Programming Gurus very useful) i use VC++ 6, though, and i''m not sure how much is compiler specific, so i don''t know if i can help..
as a suggestion, if you could include which line each error was referenced too, it''d make it alot easier to find the problem.
just know that you''re not alone. dos/unix programming is so nice and pure. windows is the spawn of satan. but DirectX is so sexy...

Share this post


Link to post
Share on other sites
by the way, Moe, the Game Design Corner probably wasn''t the best place to post this. you''d probably get more responses (and help) is you posted it somewhere in the technical/programming section, or the lounge.

Share this post


Link to post
Share on other sites
Saruman, i''m sure there was something after the #include.. i think the message board supports HTML tags, so anything contained in less than and greater than will be interpretted as a tag, and therefore ignored if the browser doesn''t recognize it.. someone previously mentions the code tag..
an example:
(without the code tag)
#include
(with the code tag
#include

Share this post


Link to post
Share on other sites
i suppose i should use code tag next time, and i will be sure to post it somewhere like graphics theory, or something.

there was a windows.h after the #include

- Moe -

Share this post


Link to post
Share on other sites
I still couldn''t see what you included. I''m using IE5, maybe it''s just stupid that way.

How about the "pre" tag? I''ll try it...


#include


could you see that?

E:cb woof!

Share this post


Link to post
Share on other sites
it seems to work fine with IE4. maybe there is some glitch in IE5. who knows...

i thought this post would have been long dead by now...

- Moe -

Share this post


Link to post
Share on other sites

  • Advertisement