SlideShare ist ein Scribd-Unternehmen logo
1 von 53
Downloaden Sie, um offline zu lesen
Intro to Event-driven Programming
and Forms with Delphi
L04 – Controls P2

Mohammad Shaker
mohammadshakergtr.wordpress.com
Intro to Event-driven Programming and Forms with Delphi
@ZGTRShaker
2010, 2011, 2012
Memo
• It’s a standard Windows multiline “edit” control.
• That’s it :D
• Difference to “Edit”:
– Memo allow the user to enter more than one line of text.

• necessary for “input” or “output” lengthy information.
• The most used “component” to deal with “file”s
Memo Prop.
• Lines (String):
– Manipulate text in “Memo” control on a “line-by-line” basis.
(Manipulate individual lines of text)
– Counting lines in the text.
– Adding new lines.
– Deleting lines.
– Replacing lines with new text “String”.
Memo Prop.
• ScrollBars:
– None, Horizontal, Vertical, Both

• Text:
– Dealing with all text at once

• MaxLength:
– “Get” or “Set” maximum numbers of characters that a “Memo” can
contain.

• Count:
– Numbers of current used lines.
Memo functions
– Memo1.Lines.add(//String);
– Memo1.Lines[i]:= //String;
– Memo1.Lines.Clear;
Memo functions
• Let’s test the following:
–
–
–
–

Memo1.Lines.IndexOf(Const s:string): integer;
Memo1.Lines.Insert(Index:integer, Const s:string);
Memo1.Lines.Delete(Index:integer);
Memo1.Lines.AddStrings(Strings:TStrings);
Memo functions
// add to last position in memo
Memo1.Lines.add(‘heeeeeheeeeeeeI am adding to Memo ’);
// add OR modify to specific position (line) in the memo
Memo1.Lines[0]:=‘heeeeeheeeeeeeI am adding to Memo ’;

//Initializing
for I:= 0 to 4 do
Memo1.lines.add('');
//filing memo with its values
Memo1.Lines[0]:=‘heeeeeheeeeeeeI
Memo1.Lines[1]:=‘heeeeeheeeeeeeI
Memo1.Lines[2]:=‘heeeeeheeeeeeeI
Memo1.Lines[3]:=‘heeeeeheeeeeeeI
Memo1.Lines[4]:=‘heeeeeheeeeeeeI

When Multi
lines,
Initialize
FIRST
am
am
am
am
am

adding
adding
adding
adding
adding

to
to
to
to
to

Memo
Memo
Memo
Memo
Memo

’;
’;
’;
’;
’;
Memo functions
//counting number of character in memo
x:=Memo1.Lines.Count;
//printing integer variables into memo
Memo1.lines.add(inttostr(x));
//clearing all memo
Memo1.Lines.Clear;
Exercise
Memo Notepad
Notepad MeMo
• Additional functions for “Notepad”.
– Load all info form a “Specific file” to “Memo”:

Memo1.lines.LoadFromFile(Const FileName:String);

– Save all info from “Memo” to a “Specific file”:

Memo1.lines.SaveToFile(Const FileName:String);
StringGrid
StringGrid
• “StringGrid” Contains “String”s
StringGrid Prop.
• ScrollBars:
– None, Horizontal, Vertical, Both

• Fixed RowCol:
– FixesCol: number of “fixed Column”s.
– FixesRows: number of “fixed Row”s.

• Indexes:
– ColCount: number of “column”s.
– RowCount: number of “Row”s.

• Cells[i,j]:
– returns the “String” in index [i,j]

// Run Time
StringGrid Prop.
• Option:
– all “Boolean”s
• GoRowSizing, GoColSizing, default “false”.
• GoRowMoving, GoColMoving, default “false”.
• Most Imprtant: GoEditing “true”, default “false”. (INPUT)
StringGrid
• Output
– Cells[i,j]

• Input:
– GoEditing “True”.
MainMenu
MainMenu
• U gonna like it, believe me:D
• Designing Time:
MainMenu
• Executing Time:
MainMenu Prop.
• Items: nice & easy
• That’s it, Test it live!
Image
Image
• Properties:
–
–
–
–
–
–

Picture
Stretch
Autosize
Width, Height
Visible, Enabled
Top, Left
Shape
Shape Prop.
• Most used for illustrating “Graphics”.
• Properties:
–
–
–
–
–
–

Shape: rectangle, circle .
Brush: Color
Pen
Width, Height
Visible, Enabled
Top, Left
Shape most used Events
• Most Important
– Create: can be used to “Auto-Create” shapes in “Runtime” using
“Pointer”s
– Destroy: can be used to “Auto-Destroy” shapes at “Runtime” using
“Pointer”s
– Hide
– Refresh
– Repaint

• “Pen, Brush, Enabledetc” properties can all be changed at
“Runtime” AS USUAL.
Panel
• BevelIn, BevelOut
• Cutting & pasting problem
• Test it
Parent Property
Parent Property
• Every component has sth called “Parent”
– like a “Button” in a “Panel”
• So, the “Panel” is the “Parent” of the “Button”

– like a “Button” in a “Form”
• So, the “Form” is the “Parent” of the “Button”

• Some Controls have no “Parent”
– Form’s parent It’s “NIL”
procedure TForm1.Button2Click(Sender: TObject);
begin
Button2.Parent:= Panel2;
end;
Debugging
• Form our Menu > Run > Step Over
• Form our Menu > Run > Trace into
– Step Over : F8
– Trace into : F7
What’s for today?
•
•
•
•
•

Timer
Sleep
TrackBar
ProgressBar
StatusBar
Timer
Timer
• Properties:
– Enabled : default “true”.
– Interval : 1 “second” = 1000 “milli-seconds”

• Events:
– OnTimer
Timer
• In design time “Enabled” Prop. is: “false”.
• At Runtime:
procedure TForm11.Button1Click(Sender: TObject);
Begin
Timer1.Enabled:=True;
end;

procedure TForm11.Timer1Timer(Sender: TObject);
Begin
if (strtoint(Label1.Caption)> 0) then
Label1.Caption:=inttostr(strtoint(label1.Caption)-1);
end;
Sleep - Refresh
• Sleep: “Stall” s the program.
Sleep(100);
// here the program executing will be stopped for
// 0.1 sec

• Refresh:
– To solve the “Sleep” problem, we use the “Refresh” method.
– Most used for:
Form1.Refresh;
// Here the form will be refreshed
Shape1.Refresh;
// Here the shape will be refreshed
Sleep - Refresh
• Test it live as this example:
– We’ll do a simulation on one shape like Hanoi towers
– Let’s have a shape “Rectangle”
– Now, we want to move it upward
• WE NEED TO SEE THE MOVEMENT
Time Machine :P
We can control time with: “Timer” or “Sleep”
Time Machine :P
Test it live!
TrackBar
TrackBar
• Properties:
–
–
–
–

Max
: Maximum value (100).
Min
: Minimum value (0).
Position: Where the “Slider” stands (1).
Orientation:
• “Vertical” or “Horizontal”

– SliderVisible:
• “Boolean” for showinghiding the “Slider”.

• Events:
– Most important: OnChange
TrackBar

procedure TForm11.TrackBar1Change(Sender: TObject);
Begin
Label1.caption:=inttostr(TrackBar1.Position);
end;
ProgressBar
ProgressBar
• Properties:
– Max
– Min
– Position

: Maximum value (100).
: Minimum value (0).
:

• How much “filled” the ProgressBar is (0).
• This is showed just in “Run Time”.

– Orientation:
• “Vertical” or “Horizontal”
• if changed:
– you have to resize your “ProgressBar”, this’s a crazy thing:D

– Step (integer):
• Determines how much the “one” step will be
ProgressBar Example
procedure TForm1.Timer1Timer(Sender: TObject);
begin
ProgressBar1.Position:= ProgressBar1.Position + 1;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
ProgressBar1.StepIt;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
ProgressBar1.StepBy(50);
end;
StatusBar
StatusBar
• The one that at the bottom to indicate the form’s “status”.
StatusBar Prop.
• SimplePanel:
– Boolean: enables the “StatusBar” when “true”, default false.
– Show the “text” when “true”.

• SimpleText:
– String: The “StatusBar” text.

• Visible, Enabled, Fontetc. as usual.
StatusBar notes
• Note:
– We can change the “SimpleText” in runtime by writing the proper code
that match the form’s STATUS.
– A “Written SimpleText” without “SimplePanel” is true will not show
anything. This’s like “Hint” & “ShowHint”
StatusBar Example
Uses unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
form2.show();
StatusBar1.SimpleText:='Form2 is running';
end;
StatusBar Example
Before clicking “Button1”

After clicking “Button1”
Timer – Shape Example
See you!

Weitere ähnliche Inhalte

Ähnlich wie Intro to Event-driven Programming and Forms with Delphi L04 - Controls P2

2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++kinan keshkeh
 
Web development basics (Part-3)
Web development basics (Part-3)Web development basics (Part-3)
Web development basics (Part-3)Rajat Pratap Singh
 
The Ring programming language version 1.5.1 book - Part 10 of 180
The Ring programming language version 1.5.1 book - Part 10 of 180The Ring programming language version 1.5.1 book - Part 10 of 180
The Ring programming language version 1.5.1 book - Part 10 of 180Mahmoud Samir Fayed
 
An Introduction to Go
An Introduction to GoAn Introduction to Go
An Introduction to GoCloudflare
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP PerspectiveBarry Jones
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIDirk Ginader
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDLWingston
 
40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.xHo Kim
 
St. Louis Days of .NET 2013: Visual Studio Tips and Tricks
St. Louis Days of .NET 2013: Visual Studio Tips and TricksSt. Louis Days of .NET 2013: Visual Studio Tips and Tricks
St. Louis Days of .NET 2013: Visual Studio Tips and TricksKevin Grossnicklaus
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introductionstn_tkiller
 
Introduction to programming - class 2
Introduction to programming - class 2Introduction to programming - class 2
Introduction to programming - class 2Paul Brebner
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without InterferenceTony Tam
 
How to create a project dashboard using share point lists
How to create a project dashboard using share point listsHow to create a project dashboard using share point lists
How to create a project dashboard using share point listsGavin Bollard
 
Coding Flash : ActionScript(3.0) Tutorial
Coding Flash :  ActionScript(3.0) TutorialCoding Flash :  ActionScript(3.0) Tutorial
Coding Flash : ActionScript(3.0) TutorialPEI-YAO HUNG
 

Ähnlich wie Intro to Event-driven Programming and Forms with Delphi L04 - Controls P2 (20)

2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++
 
Vim Basics
Vim BasicsVim Basics
Vim Basics
 
Web development basics (Part-3)
Web development basics (Part-3)Web development basics (Part-3)
Web development basics (Part-3)
 
The Ring programming language version 1.5.1 book - Part 10 of 180
The Ring programming language version 1.5.1 book - Part 10 of 180The Ring programming language version 1.5.1 book - Part 10 of 180
The Ring programming language version 1.5.1 book - Part 10 of 180
 
An Introduction to Go
An Introduction to GoAn Introduction to Go
An Introduction to Go
 
Elm @ DublinJS
Elm @ DublinJSElm @ DublinJS
Elm @ DublinJS
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP Perspective
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp III
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
 
JS Essence
JS EssenceJS Essence
JS Essence
 
Delphi L01 Intro
Delphi L01 IntroDelphi L01 Intro
Delphi L01 Intro
 
40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x
 
St. Louis Days of .NET 2013: Visual Studio Tips and Tricks
St. Louis Days of .NET 2013: Visual Studio Tips and TricksSt. Louis Days of .NET 2013: Visual Studio Tips and Tricks
St. Louis Days of .NET 2013: Visual Studio Tips and Tricks
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introduction
 
MATLAB & Image Processing
MATLAB & Image ProcessingMATLAB & Image Processing
MATLAB & Image Processing
 
Introduction to programming - class 2
Introduction to programming - class 2Introduction to programming - class 2
Introduction to programming - class 2
 
Introduction to MapBasic
Introduction to MapBasicIntroduction to MapBasic
Introduction to MapBasic
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
How to create a project dashboard using share point lists
How to create a project dashboard using share point listsHow to create a project dashboard using share point lists
How to create a project dashboard using share point lists
 
Coding Flash : ActionScript(3.0) Tutorial
Coding Flash :  ActionScript(3.0) TutorialCoding Flash :  ActionScript(3.0) Tutorial
Coding Flash : ActionScript(3.0) Tutorial
 

Mehr von Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian GraduateMohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Mohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyMohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015Mohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game DevelopmentMohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesMohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - ColorMohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - TypographyMohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingMohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and ThreadingMohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSMohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsMohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsMohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and GamingMohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / ParseMohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesMohammad Shaker
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes Mohammad Shaker
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and AdaptersMohammad Shaker
 

Mehr von Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 

Kürzlich hochgeladen

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Kürzlich hochgeladen (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Intro to Event-driven Programming and Forms with Delphi L04 - Controls P2

  • 1. Intro to Event-driven Programming and Forms with Delphi L04 – Controls P2 Mohammad Shaker mohammadshakergtr.wordpress.com Intro to Event-driven Programming and Forms with Delphi @ZGTRShaker 2010, 2011, 2012
  • 2.
  • 3. Memo • It’s a standard Windows multiline “edit” control. • That’s it :D • Difference to “Edit”: – Memo allow the user to enter more than one line of text. • necessary for “input” or “output” lengthy information. • The most used “component” to deal with “file”s
  • 4. Memo Prop. • Lines (String): – Manipulate text in “Memo” control on a “line-by-line” basis. (Manipulate individual lines of text) – Counting lines in the text. – Adding new lines. – Deleting lines. – Replacing lines with new text “String”.
  • 5. Memo Prop. • ScrollBars: – None, Horizontal, Vertical, Both • Text: – Dealing with all text at once • MaxLength: – “Get” or “Set” maximum numbers of characters that a “Memo” can contain. • Count: – Numbers of current used lines.
  • 6. Memo functions – Memo1.Lines.add(//String); – Memo1.Lines[i]:= //String; – Memo1.Lines.Clear;
  • 7. Memo functions • Let’s test the following: – – – – Memo1.Lines.IndexOf(Const s:string): integer; Memo1.Lines.Insert(Index:integer, Const s:string); Memo1.Lines.Delete(Index:integer); Memo1.Lines.AddStrings(Strings:TStrings);
  • 8. Memo functions // add to last position in memo Memo1.Lines.add(‘heeeeeheeeeeeeI am adding to Memo ’); // add OR modify to specific position (line) in the memo Memo1.Lines[0]:=‘heeeeeheeeeeeeI am adding to Memo ’; //Initializing for I:= 0 to 4 do Memo1.lines.add(''); //filing memo with its values Memo1.Lines[0]:=‘heeeeeheeeeeeeI Memo1.Lines[1]:=‘heeeeeheeeeeeeI Memo1.Lines[2]:=‘heeeeeheeeeeeeI Memo1.Lines[3]:=‘heeeeeheeeeeeeI Memo1.Lines[4]:=‘heeeeeheeeeeeeI When Multi lines, Initialize FIRST am am am am am adding adding adding adding adding to to to to to Memo Memo Memo Memo Memo ’; ’; ’; ’; ’;
  • 9. Memo functions //counting number of character in memo x:=Memo1.Lines.Count; //printing integer variables into memo Memo1.lines.add(inttostr(x)); //clearing all memo Memo1.Lines.Clear;
  • 10.
  • 12. Notepad MeMo • Additional functions for “Notepad”. – Load all info form a “Specific file” to “Memo”: Memo1.lines.LoadFromFile(Const FileName:String); – Save all info from “Memo” to a “Specific file”: Memo1.lines.SaveToFile(Const FileName:String);
  • 15. StringGrid Prop. • ScrollBars: – None, Horizontal, Vertical, Both • Fixed RowCol: – FixesCol: number of “fixed Column”s. – FixesRows: number of “fixed Row”s. • Indexes: – ColCount: number of “column”s. – RowCount: number of “Row”s. • Cells[i,j]: – returns the “String” in index [i,j] // Run Time
  • 16. StringGrid Prop. • Option: – all “Boolean”s • GoRowSizing, GoColSizing, default “false”. • GoRowMoving, GoColMoving, default “false”. • Most Imprtant: GoEditing “true”, default “false”. (INPUT)
  • 17. StringGrid • Output – Cells[i,j] • Input: – GoEditing “True”.
  • 19. MainMenu • U gonna like it, believe me:D • Designing Time:
  • 21. MainMenu Prop. • Items: nice & easy • That’s it, Test it live!
  • 22. Image
  • 24. Shape
  • 25. Shape Prop. • Most used for illustrating “Graphics”. • Properties: – – – – – – Shape: rectangle, circle . Brush: Color Pen Width, Height Visible, Enabled Top, Left
  • 26. Shape most used Events • Most Important – Create: can be used to “Auto-Create” shapes in “Runtime” using “Pointer”s – Destroy: can be used to “Auto-Destroy” shapes at “Runtime” using “Pointer”s – Hide – Refresh – Repaint • “Pen, Brush, Enabledetc” properties can all be changed at “Runtime” AS USUAL.
  • 27. Panel • BevelIn, BevelOut • Cutting & pasting problem • Test it
  • 29. Parent Property • Every component has sth called “Parent” – like a “Button” in a “Panel” • So, the “Panel” is the “Parent” of the “Button” – like a “Button” in a “Form” • So, the “Form” is the “Parent” of the “Button” • Some Controls have no “Parent” – Form’s parent It’s “NIL” procedure TForm1.Button2Click(Sender: TObject); begin Button2.Parent:= Panel2; end;
  • 30. Debugging • Form our Menu > Run > Step Over • Form our Menu > Run > Trace into – Step Over : F8 – Trace into : F7
  • 31.
  • 33. Timer
  • 34. Timer • Properties: – Enabled : default “true”. – Interval : 1 “second” = 1000 “milli-seconds” • Events: – OnTimer
  • 35. Timer • In design time “Enabled” Prop. is: “false”. • At Runtime: procedure TForm11.Button1Click(Sender: TObject); Begin Timer1.Enabled:=True; end; procedure TForm11.Timer1Timer(Sender: TObject); Begin if (strtoint(Label1.Caption)> 0) then Label1.Caption:=inttostr(strtoint(label1.Caption)-1); end;
  • 36. Sleep - Refresh • Sleep: “Stall” s the program. Sleep(100); // here the program executing will be stopped for // 0.1 sec • Refresh: – To solve the “Sleep” problem, we use the “Refresh” method. – Most used for: Form1.Refresh; // Here the form will be refreshed Shape1.Refresh; // Here the shape will be refreshed
  • 37. Sleep - Refresh • Test it live as this example: – We’ll do a simulation on one shape like Hanoi towers – Let’s have a shape “Rectangle” – Now, we want to move it upward • WE NEED TO SEE THE MOVEMENT
  • 38. Time Machine :P We can control time with: “Timer” or “Sleep”
  • 41. TrackBar • Properties: – – – – Max : Maximum value (100). Min : Minimum value (0). Position: Where the “Slider” stands (1). Orientation: • “Vertical” or “Horizontal” – SliderVisible: • “Boolean” for showinghiding the “Slider”. • Events: – Most important: OnChange
  • 44. ProgressBar • Properties: – Max – Min – Position : Maximum value (100). : Minimum value (0). : • How much “filled” the ProgressBar is (0). • This is showed just in “Run Time”. – Orientation: • “Vertical” or “Horizontal” • if changed: – you have to resize your “ProgressBar”, this’s a crazy thing:D – Step (integer): • Determines how much the “one” step will be
  • 45. ProgressBar Example procedure TForm1.Timer1Timer(Sender: TObject); begin ProgressBar1.Position:= ProgressBar1.Position + 1; end; procedure TForm1.Timer1Timer(Sender: TObject); begin ProgressBar1.StepIt; end; procedure TForm1.Timer1Timer(Sender: TObject); begin ProgressBar1.StepBy(50); end;
  • 47. StatusBar • The one that at the bottom to indicate the form’s “status”.
  • 48. StatusBar Prop. • SimplePanel: – Boolean: enables the “StatusBar” when “true”, default false. – Show the “text” when “true”. • SimpleText: – String: The “StatusBar” text. • Visible, Enabled, Fontetc. as usual.
  • 49. StatusBar notes • Note: – We can change the “SimpleText” in runtime by writing the proper code that match the form’s STATUS. – A “Written SimpleText” without “SimplePanel” is true will not show anything. This’s like “Hint” & “ShowHint”
  • 50. StatusBar Example Uses unit2; procedure TForm1.Button1Click(Sender: TObject); begin form2.show(); StatusBar1.SimpleText:='Form2 is running'; end;
  • 51. StatusBar Example Before clicking “Button1” After clicking “Button1”
  • 52. Timer – Shape Example