Advertisement

help this pitiful soul

Started by February 10, 2000 10:29 PM
18 comments, last by Moe 24 years, 9 months ago
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
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

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

Advertisement
I bet you it''s because you chose the wrong project from the New.. menu. It should be "Win 32 Console" .

JoeG
joeG
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)

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)
--- Incompetence is a double edged banana---
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.
"after many years of singularity, i'm still searching on the event horizon"
Advertisement
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?
you have to use the code tag for displaying your, well, code.
William Reiach - Human Extrodinaire

Marlene and Me


There should be a comma after HWND_DESKTOP and before the NULL in the CreateWindow function call.
You''ve also spelt nWinMode wrong in the declaration of WinMain

No sense being pessimistic. It wouldn''t work anyway.
===========================There are 10 types of people in the world. Those that understand binary and those that don't.( My views in no way reflect the views of my employer. )

This topic is closed to new replies.

Advertisement