Click to See Complete Forum and Search --> : Borland C++


Ipsec Espah
05-17-2003, 07:57 PM
I know this probably isn't the right forum to be asking a Windows question but as of yet i don't know of any good Windows programming forums...

I just installed Borland C++ Professional and i can't figure out where the heck i start writing the code. Heres the default code on the screen.


//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------


I looked in the manual for some examples but theres just examples of code with the default code edited out so i don't know where the heck to put it. I looked in this C++ Primer book i have but it doesn't seem to have anything to do with Borland. I put the code i copied at the end and it seemed to compile but no text shows up on the form...

#include <iostream>
using namespace std;
int main()
{
cout << "Testing.";
cout << "\n";
return 0;
}

Ipsec Espah
05-17-2003, 10:54 PM
I just tried opening some examples and running them and i'm getting the same problem. Everything seems to be compiling fine without any errors but once its done the Form screen comes up and its just completely blank :mad:

bwkaz
05-18-2003, 01:17 PM
You need to add components to your form before you'll be able to see them. ;)

In Windows programming, you don't use main(), either -- you use WinMain. That function will be defined already by the Borland framework, but you can change it.

zdude255
05-18-2003, 01:25 PM
Go to www.cprogramming.com they have a decent forum there. Same vBulletin system as here.

michaelk
05-18-2003, 01:38 PM
Like bwkaz says you add components on the form and then add code to those components handlers.

Hello example:
On the top panel you see tabs for the components. Click on standard and then the A character. Move the cursor to the form and left click to place the component which is a label.

Then look at the left of your screen and you will notice a box called the object inspector. Scroll down until you see a box called caption. Click on the right side which should say something like Lable1. Change that to Hello World.

Now compile and run the program.

Hmm... the program examples should not be displaying a blank form.

I find the manuls and online help somewhat frustrating. But the get starting guide should explain how the IDE works.

You can use also use C++ builder to compile command line programs.

Ipsec Espah
05-18-2003, 03:54 PM
Alright i've created a console project and deleted the default code it puts up in the Unit.cpp and added this


#include <iostream>

int main()
{
std::cout<<"A message."<<std::endl;

std::cin.get(); // Save the window!
}


When i run it i get this in the bottom window

[Linker Error] Unresolved external '__InitVCL' referenced from D:\PROGRAM FIELS\BORLAND\CBUILDER6\LIB\CP32MTI.LIB|crtlvcl
[Linker Error] Unresolved external '__ExitVCL' referenced from D:\PROGRAM FIELS\BORLAND\CBUILDER6\LIB\CP32MTI.LIB|crtlvcl


For some reason now the example programs are opening and i can see the code and all the stuff on they have on the form but when i run it, nothing seems to happen. Its not doing what it should but its better than before when i was just getting a blank Form window. Maybe its because i'm trying different examples now...

Ipsec Espah
05-18-2003, 05:19 PM
Nevermind, i was supposed to fit the code inside the default code. It works in both windows and DOS now. :cool: