Delphi L01 Intro
-
Upload
mohammad-shaker -
Category
Technology
-
view
802 -
download
1
Transcript of Delphi L01 Intro
![Page 1: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/1.jpg)
Mohammad Shakermohammadshakergtr.wordpress.com
Intro to Event-driven Programming and Forms with Delphi@ZGTRShaker
2010, 2011, 2012
Intro to Event-driven Programming and Forms with Delphi
L01 - Introduction
![Page 2: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/2.jpg)
![Page 3: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/3.jpg)
About the Course
• Delphi 2007-2009• How to think like a programmer• Test Questions• You need to try your self, otherwise it won’t work out with
you (practice, practice, practice)
![Page 4: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/4.jpg)
Course plan
• Introduction to Delphi• Introduction to IDE & Event Driven Programming• Start\Save\Open a project• Form design (design\runtime )• Delphi Components • Input Handling• Event handling• Files • Drawing (Canvas, Timer, etc.)• Instantiate Controls at Runtime
![Page 5: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/5.jpg)
Delphi History• ‘ALGOL’* the first high-level language • ‘ALGOL’* > Pascal ‘Niklaus Wirth’**• the original definition of Pascal was published in 1971. • Pascal becomes the ‘FORMAL’ programming language.• Turbo Pascal 1.0 (November 1983) • Delphi in 1995 Was introduced for ‘Visual Programming’
• *ALGOL: Algorithmic language• ** Niklaus Wirth: (b. February 15, 1934) is a Swiss computer scientist, best
known for designing Pascal programming language, and for pioneering several classic topics in software engineering. In 1984 he won the Turing Award for developing a sequence of innovative computer languages.
![Page 6: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/6.jpg)
Delphi History
• Pascal > Delphi• Borland > Pascal > Compiler > Delphi
![Page 7: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/7.jpg)
Differences
• Interface: from “Console” to “Visual”.• All Applications need Visual Interaction.• IDE: (Integrated Development Environment)
![Page 8: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/8.jpg)
Delphi Preferences & features
• OOP (Object Oriented Programming)• Applications: are build in the form of ‘forms’.• Components • Api functions ‘in Windows’.• 10 times faster compiler in comparison to other programming
languages.– Executive building files (exe) forms.– No DLL libraries like other programming languages (Dynamic Link
Library)– Database compatibility.
![Page 9: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/9.jpg)
Now, let’s sneak peek
![Page 10: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/10.jpg)
InstallCodeGear Delphi
![Page 11: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/11.jpg)
What’s for today?
• Design time\Execution time (runtime)• Event-Driven Programming• Your first Project• Forms, Buttons• ShowMessage
![Page 12: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/12.jpg)
Design time\Executing time
![Page 13: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/13.jpg)
Programs executing
• Procedural Programming:– Sequential
• “Event-Driven” Programming:– Event
![Page 14: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/14.jpg)
File Menu
• New > VCL forms Applications • open • Save
![Page 15: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/15.jpg)
![Page 16: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/16.jpg)
![Page 17: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/17.jpg)
Open\Save a Project
• When saved.– first, “UNIT” is being saved – Then, the “PROJECT”
• File > Save as (Pas file is saved)• File > Save project as (dpr is saved)• “exe.” file is formed in running time.
![Page 18: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/18.jpg)
![Page 19: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/19.jpg)
Object inspector
![Page 20: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/20.jpg)
Object inspector
• Properties: like width, color, etc.• Events: like pressing buttons, moving mouse, etc.
![Page 21: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/21.jpg)
Properties
![Page 22: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/22.jpg)
Events
![Page 23: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/23.jpg)
Common Properties for all components
• Width, Height.• Top, left.• ‘Hint’ adding & showhint.• Visible.• Enabled.• Font.• Color.
![Page 24: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/24.jpg)
Common Events for all components
• Onclick• OnDoubleClick• OnMouseMove• OnDragDrop• OnCreate • OnClose• Rest of them
![Page 25: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/25.jpg)
Note that
• All the above properties & events can be modified at design time or runtime.
![Page 26: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/26.jpg)
Event Handling Live Example
![Page 27: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/27.jpg)
Tool palette.. components
![Page 28: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/28.jpg)
Tabs
![Page 29: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/29.jpg)
FormsWindows Applications forms
Every “form” has a corresponding “unit”
![Page 30: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/30.jpg)
Forms properties
• All the following properties are ‘boolean’s:– BiSystemMenu:
• All three buttons disappear.
– BiMinimize: • to taskbar minimization.
– BiMaximize: • resize button.
– BiHelp: • ’?’ button.
• Position: the place the form will appear on the screen. • Icon: the style of the form’s icon.
– You can browse it from your PC images & pics.
![Page 31: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/31.jpg)
Forms events
• OnClose• OnMouseClick• OnHold• OnCreate• OnResize• OnMouseWheelUp
![Page 32: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/32.jpg)
Buttons
• Adding a button to our project
![Page 33: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/33.jpg)
Button properties• Name: the one we use in code (we can’t write in Arabic here.) • Caption: the “Visual” name that will appear to the client. (we can
write in Arabic here) *• Top\left: parametric variables indicate the position of the
component in the form.• Fonts: color\volume & type of the written “Caption” design.• Hint: showing a ‘hint’ when the cursor (mouse) stop on the ‘button’.• Show Hint: shows the written hint above. • Visible Enabled• Tab Order• etc._________________________________*Delphi is Arabic compatible
![Page 34: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/34.jpg)
Button Events
• OnClick• OnMouseMove• OnKeyPress• etc.
![Page 35: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/35.jpg)
Button Events
• Let’s have a quick sneak on the code• Create a new form• Place a “Button” named “KeKe” in it.:D• Double click on the button• See where you are now • Test it
![Page 36: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/36.jpg)
ShowMessageCtrl + Space
![Page 37: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/37.jpg)
Button Events
Events + Properties
![Page 38: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/38.jpg)
![Page 39: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/39.jpg)
![Page 40: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/40.jpg)
Test it
Before Clicking After Clicking
![Page 41: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/41.jpg)
ShowMessage
• The name of the application's executable file appears as the “caption” of the message box.
• Msg parameter is the message string that appears in the message box.
• Code example:
Var worked:boolean;
If (not(Worked)) thenShowMessage (‘Cmon Work ’);
![Page 42: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/42.jpg)
![Page 43: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/43.jpg)
ShowMessage
procedure TForm1.Button1Click(Sender: TObject);
var b: boolean;
begin
b:= false;
if (not(b)) then
begin
ShowMessage('Hi There ');
end;
end;
![Page 44: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/44.jpg)
ShowMessage
After clicking the button
![Page 45: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/45.jpg)
References
• ‘Delphi’ Help • Delphibasics.co.uk• Delphi Books
![Page 46: Delphi L01 Intro](https://reader033.fdocuments.net/reader033/viewer/2022052304/559344bd1a28abca728b4693/html5/thumbnails/46.jpg)
See you!