GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Apr-2004, 22:15
Mjkramer21's Avatar
Mjkramer21 Mjkramer21 is offline
Awaiting Email Confirmation
 
Join Date: Mar 2004
Location: Orem, Ut
Posts: 36
Mjkramer21 is on a distinguished road

Help with windows programming


Appearently my compiler does not like that I don't have a _main in my program, and isnt seeing the winmain() as the main. Ive never tried anything like this in borland before. Whats borlands problem? Here is the error:

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
C:\test.cpp:
Warning W8057 C:\test.cpp 47: Parameter 'hPrevInstance' is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int)
Warning W8057 C:\test.cpp 47: Parameter 'lpCmdLine' is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int)
Warning W8057 C:\test.cpp 47: Parameter 'nCmdShow' is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int)
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\C0X32.OBJ

Tool completed with exit code 1

and here is the code:

CPP / C++ / C Code:
#include <iostream>
using namespace std;

#include <windows>

#include <cstring>


int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine, int nCmdShow)
{

	typedef struct _WNDCLASSEX {
	    UINT    cbSize;
	    UINT    style;
	    WNDPROC lpfnWndProc;
	    int     cbClsExtra;
	    int     cbWndExtra;
	    HANDLE  hInstance;
	    HICON   hIcon;
	    HCURSOR hCursor;
	    HBRUSH  hbrBackground;
	    LPCTSTR lpszMenuName;
	    LPCTSTR lpszClassName;
	    HICON   hIconSm;
	} WNDCLASSEX;

WNDCLASSEX sampleClass;

sampleClass.cbSize =        sizeof(WNDCLASSEX);
sampleClass.style =         CS_DBLCLKS | CS_OWNDC |
                            CS_HREDRAW | CS_VREDRAW;

sampleClass.cbClsExtra =    0;
sampleClass.cbWndExtra =    0;
sampleClass.hInstance =     hinstance;
sampleClass.hIcon =         LoadIcon(NULL, IDI_WINLOGO);
sampleClass.hCursor =       LoadCursor(NULL, IDC_ARROW);
sampleClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
sampleClass.lpszMenuName =  NULL;
sampleClass.lpszClassName = "Sample Class";
sampleClass.hIconSm =       LoadIcon(NULL, IDI_WINLOGO);

return(0);
}


  #2  
Old 14-Apr-2004, 01:35
Mjkramer21's Avatar
Mjkramer21 Mjkramer21 is offline
Awaiting Email Confirmation
 
Join Date: Mar 2004
Location: Orem, Ut
Posts: 36
Mjkramer21 is on a distinguished road
Dang, nobody can help me here? Ive just spent 2 hours researching and www.borland.com's documentation and bulletin was not even the slightest help. In the documentation it said that I had to give a -w parameter to tell it which kind of application to build (it builds console by default, but we all know this i think). The compiler doesnt recognize this -w command that was given by the freakin borland developers themselves. So I type 'bcc32' help and I get something like -tWxxx(or something like that) to build a windows application. So I try that too. The compiler doesnt recognize that either. I really don't want to have to install visual studios. What a pain in my butt. All that microsoft stuff comes with way more overhead than I need. I like doing things manually anyway.
  #3  
Old 14-Apr-2004, 01:58
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
http://winprog.org/tutorial/
__________________
-Aaron
  #4  
Old 14-Apr-2004, 04:50
WaltP's Avatar
WaltP WaltP is online now
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by Mjkramer21
Dang, nobody can help me here?
Give us time. We are volunteers with a life ouside of this board. If you want immediate help, you need to call us on the phone and let us know you're posting a question so we can drop what we're doing to answer it ;-)

Quote:
Originally Posted by Mjkramer21
Ive just spent 2 hours researching and www.borland.com's documentation and bulletin was not even the slightest help. In the documentation it said that I had to give a -w parameter to tell it which kind of application to build (it builds console by default, but we all know this i think). The compiler doesnt recognize this -w command that was given by the freakin borland developers themselves.
-w is to set the compiler's warning level.

Quote:
Originally Posted by Mjkramer21
So I type 'bcc32' help and I get something like -tWxxx(or something like that) to build a windows application. So I try that too. The compiler doesnt recognize that either.
Mine does. Although I've never actually written a program using it

Quote:
Originally Posted by Mjkramer21
I really don't want to have to install visual studios. What a pain in my butt. All that microsoft stuff comes with way more overhead than I need. I like doing things manually anyway.
I'm with you there.

By the way, aaron's link won't help you with the compiler, if you haven't discovered that yet.

Try the info at this google search. OWL is Borland's version of MFC I believe, but doesn't come standard with 5.5. Or simply avoid the winmain() crap and use Windows API's to do your Windowing.

Here's a book that may help http://www.accu.org/bookreviews/publ.../m/m000786.htm
It's for ver 4.1 but most of the info is probably applicable to 5.5
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #5  
Old 14-Apr-2004, 10:52
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
Well, the compiler, no. I saw the code and noticed a few things were missing, so I gave a link to a good website. Although, I really didn't read the post that well, I don't know jack about the Borland compiler interface. As far as making a windows program with borland... I've never been able to do it with WinAPI. The only success I've ever had with that lies in the only other compiler I've used: MSVC 6.

Quote:
Originally Posted by WaltP
Or simply avoid the winmain() crap and use Windows API's to do your Windowing.
WinMain() is WinAPI, isn't it? All windows programs need a WinMain() function, at least.
__________________
-Aaron
  #6  
Old 14-Apr-2004, 13:41
machinated machinated is offline
Regular Member
 
Join Date: Mar 2004
Location: victoria, canada
Posts: 324
machinated has a spectacular aura aboutmachinated has a spectacular aura about
arent u supposed to include <windows.h> i see u've included only <windows> is that an error or on purpose?
  #7  
Old 14-Apr-2004, 16:36
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
Quote:
Originally Posted by machinated
arent u supposed to include <windows.h> i see u've included only <windows> is that an error or on purpose?
Well, I know there's an <iostream>... perhaps he has a <windows>?
__________________
-Aaron
  #8  
Old 14-Apr-2004, 16:38
Mjkramer21's Avatar
Mjkramer21 Mjkramer21 is offline
Awaiting Email Confirmation
 
Join Date: Mar 2004
Location: Orem, Ut
Posts: 36
Mjkramer21 is on a distinguished road
Quote:
Originally Posted by machinated
arent u supposed to include <windows.h> i see u've included only <windows> is that an error or on purpose?

LOL!. I laugh because of the 3 day discussion that question recently instigated. The .h extension was intentionally left out. C++ compilers no longer use the extensions. You can read about it here: http://www.gidforums.com/t-2407.html
  #9  
Old 15-Apr-2004, 19:27
machinated machinated is offline
Regular Member
 
Join Date: Mar 2004
Location: victoria, canada
Posts: 324
machinated has a spectacular aura aboutmachinated has a spectacular aura about
i dunno about that, but even so is ur compiler up to date?
  #10  
Old 15-Apr-2004, 19:45
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Quote:
Originally Posted by aaroncohn
Well, I know there's an <iostream>... perhaps he has a <windows>?


These both refer to iostream.h and windows.h. The h is implicit. And this was covered to death in that other post
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 16:41
Windows 2000 & NT source code leak Garth Farley Computer Software Forum - Windows 3 26-Feb-2004 16:23
· Windows 2003 Server Reseller Special: Unlimited Domains/2 GB Space/for $19.99 contactsonia Web Hosting Advertisements & Offers 0 09-Jan-2004 06:46
Windows 2003 Hosting - 4 Months Free! reinventme Web Hosting Advertisements & Offers 0 05-Dec-2003 19:52
Installing Linux with Windows ME JdS Computer Software Forum - Linux 4 30-Apr-2003 18:47

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:25.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.