Your SlideShare is downloading. ×
0
Intro to Event-driven Programming
and Forms with Delphi
L01 - Introduction

Mohammad Shaker
mohammadshakergtr.wordpress.co...
About the Course
•
•
•
•

Delphi 2007-2009
How to think like a programmer
Test Questions
You need to try your self, otherw...
Course plan
•
•
•
•
•
•
•
•
•
•

Introduction to Delphi
Introduction to IDE & Event Driven Programming
StartSaveOpen a pro...
Delphi History
•
•
•
•
•
•

‘ALGOL’* the first high-level language
‘ALGOL’* > Pascal ‘Niklaus Wirth’**
the original defini...
Delphi History
• Pascal > Delphi
• Borland > Pascal > Compiler > Delphi
Differences
• Interface: from “Console” to “Visual”.
• All Applications need Visual Interaction.
• IDE: (Integrated Develo...
Delphi Preferences & features
•
•
•
•
•

OOP (Object Oriented Programming)
Applications: are build in the form of ‘forms’....
Now, let’s sneak peek
Install
CodeGear Delphi
What’s for today?
•
•
•
•
•

Design timeExecution time (runtime)
Event-Driven Programming
Your first Project
Forms, Button...
Design timeExecuting time
Programs executing
• Procedural Programming:
– Sequential

• “Event-Driven” Programming:
– Event
File Menu
• New > VCL forms Applications
• open
• Save
OpenSave a Project
• When saved.
– first, “UNIT” is being saved
– Then, the “PROJECT”

• File > Save as
(Pas file is saved...
Object inspector
Object inspector
• Properties: like width, color, etc.
• Events: like pressing buttons, moving mouse, etc.
Properties
Events
Common Properties for all components
•
•
•
•
•
•
•

Width, Height.
Top, left.
‘Hint’ adding & showhint.
Visible.
Enabled.
...
Common Events for all components
•
•
•
•
•
•
•

Onclick
OnDoubleClick
OnMouseMove
OnDragDrop
OnCreate
OnClose
Rest of them
Note that
• All the above properties & events can be modified at design
time or runtime.
Event Handling
Live Example
Tool palette.. components
Tabs
Forms
Windows Applications  forms
Every “form” has a corresponding “unit”
Forms properties
• All the following properties are ‘boolean’s:
– BiSystemMenu:
• All three buttons disappear.

– BiMinimi...
Forms events
•
•
•
•
•
•

OnClose
OnMouseClick
OnHold
OnCreate
OnResize
OnMouseWheelUp
Buttons
• Adding a button to our project
Button properties
• Name: the one we use in code (we can’t write in Arabic here.)
• Caption: the “Visual” name that will a...
Button Events
•
•
•
•

OnClick
OnMouseMove
OnKeyPress
etc.
Button Events
•
•
•
•
•
•

Let’s have a quick sneak on the code
Create a new form
Place a “Button” named “KeKe” in it.:D
D...
ShowMessage
Ctrl + Space
Button Events

Events + Properties
Test it

Before Clicking

After Clicking
ShowMessage
• The name of the application's executable file appears as the
“caption” of the message box.
• Msg parameter i...
ShowMessage
procedure TForm1.Button1Click(Sender: TObject);
var b: boolean;
begin
b:= false;
if (not(b)) then
begin
ShowMe...
ShowMessage

After clicking the button
References
• ‘Delphi’ Help
• Delphibasics.co.uk
• Delphi Books
See you!
Delphi L01 Intro
Delphi L01 Intro
Delphi L01 Intro
Delphi L01 Intro
Delphi L01 Intro
Delphi L01 Intro
Delphi L01 Intro
Upcoming SlideShare
Loading in...5
×

Delphi L01 Intro

785

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
785
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
16
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Delphi L01 Intro"

  1. 1. Intro to Event-driven Programming and Forms with Delphi L01 - Introduction Mohammad Shaker mohammadshakergtr.wordpress.com Intro to Event-driven Programming and Forms with Delphi @ZGTRShaker 2010, 2011, 2012
  2. 2. 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)
  3. 3. Course plan • • • • • • • • • • Introduction to Delphi Introduction to IDE & Event Driven Programming StartSaveOpen a project Form design (designruntime ) Delphi Components Input Handling Event handling Files Drawing (Canvas, Timer, etc.) Instantiate Controls at Runtime
  4. 4. 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.
  5. 5. Delphi History • Pascal > Delphi • Borland > Pascal > Compiler > Delphi
  6. 6. Differences • Interface: from “Console” to “Visual”. • All Applications need Visual Interaction. • IDE: (Integrated Development Environment)
  7. 7. 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.
  8. 8. Now, let’s sneak peek
  9. 9. Install CodeGear Delphi
  10. 10. What’s for today? • • • • • Design timeExecution time (runtime) Event-Driven Programming Your first Project Forms, Buttons ShowMessage
  11. 11. Design timeExecuting time
  12. 12. Programs executing • Procedural Programming: – Sequential • “Event-Driven” Programming: – Event
  13. 13. File Menu • New > VCL forms Applications • open • Save
  14. 14. OpenSave 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.
  15. 15. Object inspector
  16. 16. Object inspector • Properties: like width, color, etc. • Events: like pressing buttons, moving mouse, etc.
  17. 17. Properties
  18. 18. Events
  19. 19. Common Properties for all components • • • • • • • Width, Height. Top, left. ‘Hint’ adding & showhint. Visible. Enabled. Font. Color.
  20. 20. Common Events for all components • • • • • • • Onclick OnDoubleClick OnMouseMove OnDragDrop OnCreate OnClose Rest of them
  21. 21. Note that • All the above properties & events can be modified at design time or runtime.
  22. 22. Event Handling Live Example
  23. 23. Tool palette.. components
  24. 24. Tabs
  25. 25. Forms Windows Applications  forms Every “form” has a corresponding “unit”
  26. 26. 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.
  27. 27. Forms events • • • • • • OnClose OnMouseClick OnHold OnCreate OnResize OnMouseWheelUp
  28. 28. Buttons • Adding a button to our project
  29. 29. 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) * • Topleft: parametric variables indicate the position of the component in the form. • Fonts: colorvolume & 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
  30. 30. Button Events • • • • OnClick OnMouseMove OnKeyPress etc.
  31. 31. 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
  32. 32. ShowMessage Ctrl + Space
  33. 33. Button Events Events + Properties
  34. 34. Test it Before Clicking After Clicking
  35. 35. 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)) then ShowMessage (‘Cmon Work ’);
  36. 36. ShowMessage procedure TForm1.Button1Click(Sender: TObject); var b: boolean; begin b:= false; if (not(b)) then begin ShowMessage('Hi There '); end; end;
  37. 37. ShowMessage After clicking the button
  38. 38. References • ‘Delphi’ Help • Delphibasics.co.uk • Delphi Books
  39. 39. See you!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×