SlideShare uma empresa Scribd logo
1 de 53
Baixar para ler offline
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!

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 

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