This is the third part of the [Borland C++ builder programming series].Here you will learn on how to create,compile & execute windows application.If you are interested in creating console application then red it [here].In this article you will read about the rapid application development approach of borland c++ builder.If you are excited to create win32 program,so read on.
Windows programming can be complex sometime,it becomes difficult while handling large projects.Such complexities are reduced by RAD concept of Borland C++ Builder.This IDE provides “point and click” approach that saves lot of time for both new users & seasoned programmers.That’s why BCB is so popular with C++ programmers under windows environment.After reading this article you will able to build a simple Windows application with help of BCB.This article discusses few components & Object inspector to create simple window application.
Creating a Simple Windows Application
Start Borland C++ Builder,this will open up form & unit1.cpp file.Create a folder for your project files and save the default project files.By saving the blank project, you establish the project’s path to the appropriate folder you created earlier.Make a habit to save your program when you make some noticeable changes.Now you should be looking at a blank form.By default, the form is named Form1.Let’s change the title to Hello World,this will change the window title also.The Object Inspector contains the property settings for the selected object.By default,Form1 is selected.In object inspector find the “Property” caption & then change its value from “Form1” to “Hello World”.
Let’s write something on Form.From the Standard component toolbar,select “Label”.Draw the Label shape into the form,make sure it is selected.From Object Inspector’s Properties Tab Select Caption.The value of this property is shown when the application runs. When a Label component is added to a form, it has a default caption from Label1 up to LabelN for next Label.Change the value of Label1 to “Hello World”.As you modify the caption,BCB will immediately display the results.Now we have to set the Font for the label,so select + Font Menu in left tab of properties.Then select “Size” caption.Set it to 24 or Higher Value.So that you can view it easily.Align the label properly on form,you can set it to the center of the Form.
Now you are all set to take a look at your first program in windows.You can press F9 or RUN.This will push BCB to compile the program,and in few seconds you see the Hello World window.You can add more functionality to this program by adding some more components.Like give your form text entering capability.To do this drop “Memo” from standard components toolbar to form.
Even though this program does nothing,you learned to add and modify the components & their properties.
This way you are creating windows using Forms & Components.Which is merely extension to C++ language introduced by borland.You can create win32 application by writing the code & compiling on BCB.For this follow the steps below :
Start Borland C++ Builder.From the main menu,choose File | New.This will open up the new items dialog box.In the New Items dialog box, click Console Wizard and click OK.In the Console Wizard, make sure that only C++ radio button is selected then Click OK.
You will be given with source code shown below:
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
From the above code given you have to add more code statements to build each & every part of your window.Like changing label of window,background color or changing icon etc.Some people may find it more complex,so they prefer Borland C++ builder.If you have followed the previous articles on borland then you might realised why people like it.
Where to go from here?
You can learn more about creating windows program by reading more about components & examples created with BCB.You can try text editor example from the help file of the BCB this will make you comfortable with most of the components.
In next article,We’ll look at components & how to use them in Borland C++ builder.If you find any error or typos post it in comments.Thank you for reading.Any feedback is welcome.