Mega Code Archive

 
Categories / Delphi / Ide Indy
 

Delphi From The Ground Up Part II Basics

Title: Delphi From The Ground Up - Part II : Basics Question: A Delphi tutorial written by a user for users, in plain-simple english Answer: Volume : Delphi From The Ground Up Title : Part II - Basics Author : James Booker Contact : booker@ntlworld.com Welcome Back Well, I know it's been a while guys, but exams at college, personal stuff as well have kept me away from Delphi for a while, but i intend to carry on where I left off and make it a more regular thing this time. So, without further Ado..... I left you last time... I left last time proimising I would explain all those acronyms I gave out, and so here I go: RAD: Rapid Application Development - Aiming to make the application design/implementation process as quick as possible by cuttin all of the mundane coding tasks out, such as all the code to create forms, components on the form etc. Delphi does all this for you, all you do is drag-n-drop! IDE: Integrated Development Environment - Basically the software that you use to make the applications you create. Delphi is in fact one of these itself, and not a language as is commonly thought - Object Pascal is the language. Using an IDE saves the user from using a command-line compiler directly, instead (s)he uses the IDE to call the compiler for him/her. VCL: Visual Component Library - The basic controls you see while using Windows, such as buttons, Edit boxes and radiolists can be found here. They're already programmed in and ready to go, all you have to do is drag them onto a form, and format them how you like. Instead of writing the code for the actual object itself, you just write the code for what you want it to do. Let me at it... I'm guessing if you've skipped straight to this article, all you want to do is create a basic application? Well, ok let's create the obligatory Hello World application. I will explain what to do in nice easy steps. First thing to do is create a fresh project. Click the File menu, then New Project. Next, add a TButton component to the form. Click the Standard VCL tab (in the delphi main window, middle-right, there is a set of tabs, that's the VCL ;) and look for a small picture of a button with OK written inside it. Double click the image of the button to add it to the middle of the form. Next, two buttons left of the Button icon, there's an button who's hint will be "Edit". Double-click that one and add it to the form. Now, both of these look boring, and so we'll make them look more interesting. Click once on the button, and the object inspector (window on the left, if not visible choose View|Object Inspector) should change slightly to reveal properties of the button. Change the Caption property to "Greet Me" (don't type the quotes.) And change the Edit control's Text property to "Type Name Here". Now, here comes your first bit of code, so be careful. Double-click the button, and you should have a procedure like this: procedure TForm1.Button1Click(Sender: TObject); begin end; in that procedure, type this line of code: ShowMessage('Hello' + Edit1.Text); so you end up with procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage('Hello' + Edit1.Text); end; Ok, now press F9 to run your application. Type your name in the edit box and click the button, and watch your application say hello to you! See? Easy as pie! Ok, so it wasn't EXACTLY a hello world app, but it was near enough Next time, we'll learn some more about the Object Inspector, Explore the VCL a bit more, as well as expanding our application further. Goodbye for now, and have fun Regards, James Booker