SlideShare a Scribd company logo
Event-based Programming
Roger Crawfis
Window-based
programming
• Most modern desktop systems are
window-based.
Non-window based environment
Window based environment
What location do I use to set this pixel?
Event-based Programming
• Window-based GUI’s are typically
comprised of many independent
processes.
• These processes sit and wait for the
user to do something, to which it can
respond.
• Moreover, a simple application may
be waiting for any of a number of
things.
Event-based Programming
• Sample main programs:
– C# / managed C++
static void Main()
{
Application.Run( new Form1());
}
– C++ (MFC Document/View architecture)
There isn’t one!!
– GLUT
void main(int argc, char** argv)
{
myInit();
glutMainLoop();
}
Programming forms
 Procedural programming
 code is executed in sequential order.
 Event-driven programming
 code is executed upon activation of events.
statement 1
statement 2
statement 3
--------
--------
statement n
method 1
method 2
method 3
--------
--------
method n
Do
method 1
then
method 3
Do
method 2
then
method 1
then
method 3
Procedural programming
• Up to now, our control flow model has been
pretty straight-forward.
• Execution starts at main() and executes
statement sequentially branching with if,for,and
while statement, and occasional method calls.
• When we need user input we call read() on the
console stream which waits (blocks) until the
user types something, then returns.
• One problem with this model is: How do we wait
for and respond to input from more than one
source (eg keyboard and mouse). If we block
on either waiting for input, we may miss input
from the other.
Event-driven programming
• the system waits for user input
events, and these events trigger
program methods
• Event-based programming
addresses the two problems:
– How to wait on multiple input sources
(input events)
– How to decide what to do on each
type of input event
General form of event-
driven programming
• The operating system and window
system process input events from
devices (mouse movement, mouse
clicks, key presses etc)
• The window system decides which
window, and hence which frame and
program, each input event belongs to.
General form of event-driven
programming
• A data structure describing the event is
produced and placed on an event queue.
Events are added to one end of the
queue by the window system. Events are
removed from the queue and processed
by the program. These event data
structures hold information including:
– Which of the program's windows this event
belongs to.
– The type of event (mouse click, key press,
etc.)
– Any event-specific data (mouse position, key
code, etc.)
Event loop
• main(){
• ...set up application data structures...
• ...set up GUI....
• // enter event loop
• while(true){
• Event e = get_event();
• process_event(e); // event dispatch routine } }
• the event loop is usually hidden from
programmer, he/she provides just a
process_event() method
AWT Applications - Frame
• Frame is a container for components
Frame with
normal window
controls
Optional
Menu
Three
containers in
Frame with
Border Layout
UI-components
inside
containers each
with own layout
Understanding the GUI
• UI-containers
– have list of
UI-components
• Each UI-component
– is a class
– with paint method
– & lists of
Event listeners
{Frame}
{label}
{textfield}
{button}
components
Understanding .NET UI
Components
• Overview
– Replacement for VB Forms and MFC
• Fully integrated with the .NET framework
• Web Service aware
• Data (ADO.NET and XML) aware
• Secure code and Licensing
– A framework for building Windows application
• “No touch” deployment
– No registration, Versionable, Smart caching
– A RAD environment in Visual Studio .NET
• Windows Form Designer, Property Browser
Overview (cont)
– Rich set of controls
• Standard controls - Label, Button, TextBox, etc.
• Common controls - ProgressBar, StatusBar, etc.
• Data aware controls - ListBox, DataGrid, etc.
• Common dialogs
– ActiveX Interoperability
• Can host ActiveX controls / author ActiveX controls
– Printing Support
– Visual inheritance
• Create a form based on another form by using
inheritance
– Advanced layout
• Anchoring and docking
Basic Terms
• Component
– Timer, DB Connection
• Control (User Control)
– Windows Forms
• Menu
• Button
• etc
– Web Forms
• ASP.NET specific
Using VS.NET
• Adding Components and Controls
– Just drag component from the toolbox
• Editing properties
– Edit directly in the properties editor
• Registering for events
– Also in the properties editor
What actually happens?
• Data members for components
• For example, after placing timer:
public class FunnyButton :
System.Windows.Forms.Button
{
private System.Windows.Forms.Timer
timer1;
What actually happens?
• Attributes for the properties
• For example, after changing Text
property:
private void InitializeComponent()
{
…
this.Text = "ADO Example";
What actually happens?
• Delegates for events
– Special type event in .NET (special delegate)
private void InitializeComponent()
{
…
this->MouseEnter += new
System.EventHandler(this.UserControl1_MouseEnter
);
…
}
…
private void UserControl1_MouseEnter(object sender,
System.EventArgs e) {}
Names everyone should
know
• Properties
– Name – data member name
– Text – text shown by control (was
Caption)
– ForeColor – current text color
– Dock – docking to the parent
– Enabled – active or not
• Events
– Click – mouse click on the control
– SizeChanged - resize
InitializeComponent()
method
• This method is created by VS.NET
• Code generated there represents all the
changes done in the design view
• Note: if you remove event handler or
data member added by VS.NET
manually, do not forget to clean the code
that uses it from InitializeComponent().
• Doing this from the design view is easier!
Ad

More Related Content

Similar to 5809566 programming concepts in vasters (20)

Advanced Coded UI Testing
Advanced Coded UI TestingAdvanced Coded UI Testing
Advanced Coded UI Testing
Shai Raiten
 
c programming 1-1.pptx
c programming 1-1.pptxc programming 1-1.pptx
c programming 1-1.pptx
CHERUKURIYUVARAJU209
 
Implementation
ImplementationImplementation
Implementation
hcicourse
 
codeduiws-130507074566782958-phpapp02.pdf
codeduiws-130507074566782958-phpapp02.pdfcodeduiws-130507074566782958-phpapp02.pdf
codeduiws-130507074566782958-phpapp02.pdf
Patiento Del Mar
 
Lesson 2 - Understanding Operating System Configurations
Lesson 2 - Understanding Operating System ConfigurationsLesson 2 - Understanding Operating System Configurations
Lesson 2 - Understanding Operating System Configurations
Gene Carboni
 
Gui
GuiGui
Gui
Sardar Alam
 
Windows programming ppt
Windows programming pptWindows programming ppt
Windows programming ppt
SAMIR CHANDRA
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
PERKYTORIALS
 
Presentation acme sys999tems Ragini 1.pptx
Presentation acme sys999tems Ragini 1.pptxPresentation acme sys999tems Ragini 1.pptx
Presentation acme sys999tems Ragini 1.pptx
Ragini153088
 
A look behind the scenes: Windows 8 background processing
A look behind the scenes: Windows 8 background processingA look behind the scenes: Windows 8 background processing
A look behind the scenes: Windows 8 background processing
Matt Lacey
 
3 App Compat Win7
3 App Compat Win73 App Compat Win7
3 App Compat Win7
llangit
 
Visual basic
Visual basic Visual basic
Visual basic
Shabista Imam
 
2310 b 05
2310 b 052310 b 05
2310 b 05
Krazy Koder
 
Event driven theory
Event driven theoryEvent driven theory
Event driven theory
nickywalters
 
Introduction to embedded system
Introduction to embedded systemIntroduction to embedded system
Introduction to embedded system
ajitsaraf123
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
fpatton
 
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Codit
 
Suncoast Credit Union and Armwood High School - UiPath automation developer s...
Suncoast Credit Union and Armwood High School - UiPath automation developer s...Suncoast Credit Union and Armwood High School - UiPath automation developer s...
Suncoast Credit Union and Armwood High School - UiPath automation developer s...
DianaGray10
 
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Debugging IE Performance Issues with xperf, ETW and NavigationTimingDebugging IE Performance Issues with xperf, ETW and NavigationTiming
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Nicholas Jansma
 
ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017
Lucas Jellema
 
Advanced Coded UI Testing
Advanced Coded UI TestingAdvanced Coded UI Testing
Advanced Coded UI Testing
Shai Raiten
 
Implementation
ImplementationImplementation
Implementation
hcicourse
 
codeduiws-130507074566782958-phpapp02.pdf
codeduiws-130507074566782958-phpapp02.pdfcodeduiws-130507074566782958-phpapp02.pdf
codeduiws-130507074566782958-phpapp02.pdf
Patiento Del Mar
 
Lesson 2 - Understanding Operating System Configurations
Lesson 2 - Understanding Operating System ConfigurationsLesson 2 - Understanding Operating System Configurations
Lesson 2 - Understanding Operating System Configurations
Gene Carboni
 
Windows programming ppt
Windows programming pptWindows programming ppt
Windows programming ppt
SAMIR CHANDRA
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
PERKYTORIALS
 
Presentation acme sys999tems Ragini 1.pptx
Presentation acme sys999tems Ragini 1.pptxPresentation acme sys999tems Ragini 1.pptx
Presentation acme sys999tems Ragini 1.pptx
Ragini153088
 
A look behind the scenes: Windows 8 background processing
A look behind the scenes: Windows 8 background processingA look behind the scenes: Windows 8 background processing
A look behind the scenes: Windows 8 background processing
Matt Lacey
 
3 App Compat Win7
3 App Compat Win73 App Compat Win7
3 App Compat Win7
llangit
 
Event driven theory
Event driven theoryEvent driven theory
Event driven theory
nickywalters
 
Introduction to embedded system
Introduction to embedded systemIntroduction to embedded system
Introduction to embedded system
ajitsaraf123
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
fpatton
 
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Codit
 
Suncoast Credit Union and Armwood High School - UiPath automation developer s...
Suncoast Credit Union and Armwood High School - UiPath automation developer s...Suncoast Credit Union and Armwood High School - UiPath automation developer s...
Suncoast Credit Union and Armwood High School - UiPath automation developer s...
DianaGray10
 
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Debugging IE Performance Issues with xperf, ETW and NavigationTimingDebugging IE Performance Issues with xperf, ETW and NavigationTiming
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Nicholas Jansma
 
ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017
Lucas Jellema
 

More from ag3777499 (11)

Information Security Imp +Past Paper.pdf
Information Security Imp +Past Paper.pdfInformation Security Imp +Past Paper.pdf
Information Security Imp +Past Paper.pdf
ag3777499
 
ch04 all about software project managen
ch04 all about  software project managench04 all about  software project managen
ch04 all about software project managen
ag3777499
 
Introduction to event driven programming
Introduction to event driven programmingIntroduction to event driven programming
Introduction to event driven programming
ag3777499
 
Chapter1 of programming object orienteds
Chapter1 of programming object orientedsChapter1 of programming object orienteds
Chapter1 of programming object orienteds
ag3777499
 
lecture 4bw_210 css preparation in extra
lecture 4bw_210 css preparation in extralecture 4bw_210 css preparation in extra
lecture 4bw_210 css preparation in extra
ag3777499
 
organizations real estate to maake unity
organizations real estate to maake unityorganizations real estate to maake unity
organizations real estate to maake unity
ag3777499
 
Europe history for current affair of css
Europe history for current affair of cssEurope history for current affair of css
Europe history for current affair of css
ag3777499
 
Programming_Style with modern blend mode
Programming_Style with modern blend modeProgramming_Style with modern blend mode
Programming_Style with modern blend mode
ag3777499
 
first aid for intermediate class to common
first aid for intermediate class  to commonfirst aid for intermediate class  to common
first aid for intermediate class to common
ag3777499
 
Sociology Class Lecture all for sociology notes class
Sociology Class Lecture all for sociology notes classSociology Class Lecture all for sociology notes class
Sociology Class Lecture all for sociology notes class
ag3777499
 
geography for pakistanStudies essays and other
geography for pakistanStudies essays and othergeography for pakistanStudies essays and other
geography for pakistanStudies essays and other
ag3777499
 
Information Security Imp +Past Paper.pdf
Information Security Imp +Past Paper.pdfInformation Security Imp +Past Paper.pdf
Information Security Imp +Past Paper.pdf
ag3777499
 
ch04 all about software project managen
ch04 all about  software project managench04 all about  software project managen
ch04 all about software project managen
ag3777499
 
Introduction to event driven programming
Introduction to event driven programmingIntroduction to event driven programming
Introduction to event driven programming
ag3777499
 
Chapter1 of programming object orienteds
Chapter1 of programming object orientedsChapter1 of programming object orienteds
Chapter1 of programming object orienteds
ag3777499
 
lecture 4bw_210 css preparation in extra
lecture 4bw_210 css preparation in extralecture 4bw_210 css preparation in extra
lecture 4bw_210 css preparation in extra
ag3777499
 
organizations real estate to maake unity
organizations real estate to maake unityorganizations real estate to maake unity
organizations real estate to maake unity
ag3777499
 
Europe history for current affair of css
Europe history for current affair of cssEurope history for current affair of css
Europe history for current affair of css
ag3777499
 
Programming_Style with modern blend mode
Programming_Style with modern blend modeProgramming_Style with modern blend mode
Programming_Style with modern blend mode
ag3777499
 
first aid for intermediate class to common
first aid for intermediate class  to commonfirst aid for intermediate class  to common
first aid for intermediate class to common
ag3777499
 
Sociology Class Lecture all for sociology notes class
Sociology Class Lecture all for sociology notes classSociology Class Lecture all for sociology notes class
Sociology Class Lecture all for sociology notes class
ag3777499
 
geography for pakistanStudies essays and other
geography for pakistanStudies essays and othergeography for pakistanStudies essays and other
geography for pakistanStudies essays and other
ag3777499
 
Ad

Recently uploaded (20)

LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Ad

5809566 programming concepts in vasters

  • 2. Window-based programming • Most modern desktop systems are window-based. Non-window based environment Window based environment What location do I use to set this pixel?
  • 3. Event-based Programming • Window-based GUI’s are typically comprised of many independent processes. • These processes sit and wait for the user to do something, to which it can respond. • Moreover, a simple application may be waiting for any of a number of things.
  • 4. Event-based Programming • Sample main programs: – C# / managed C++ static void Main() { Application.Run( new Form1()); } – C++ (MFC Document/View architecture) There isn’t one!! – GLUT void main(int argc, char** argv) { myInit(); glutMainLoop(); }
  • 5. Programming forms  Procedural programming  code is executed in sequential order.  Event-driven programming  code is executed upon activation of events. statement 1 statement 2 statement 3 -------- -------- statement n method 1 method 2 method 3 -------- -------- method n Do method 1 then method 3 Do method 2 then method 1 then method 3
  • 6. Procedural programming • Up to now, our control flow model has been pretty straight-forward. • Execution starts at main() and executes statement sequentially branching with if,for,and while statement, and occasional method calls. • When we need user input we call read() on the console stream which waits (blocks) until the user types something, then returns. • One problem with this model is: How do we wait for and respond to input from more than one source (eg keyboard and mouse). If we block on either waiting for input, we may miss input from the other.
  • 7. Event-driven programming • the system waits for user input events, and these events trigger program methods • Event-based programming addresses the two problems: – How to wait on multiple input sources (input events) – How to decide what to do on each type of input event
  • 8. General form of event- driven programming • The operating system and window system process input events from devices (mouse movement, mouse clicks, key presses etc) • The window system decides which window, and hence which frame and program, each input event belongs to.
  • 9. General form of event-driven programming • A data structure describing the event is produced and placed on an event queue. Events are added to one end of the queue by the window system. Events are removed from the queue and processed by the program. These event data structures hold information including: – Which of the program's windows this event belongs to. – The type of event (mouse click, key press, etc.) – Any event-specific data (mouse position, key code, etc.)
  • 10. Event loop • main(){ • ...set up application data structures... • ...set up GUI.... • // enter event loop • while(true){ • Event e = get_event(); • process_event(e); // event dispatch routine } } • the event loop is usually hidden from programmer, he/she provides just a process_event() method
  • 11. AWT Applications - Frame • Frame is a container for components Frame with normal window controls Optional Menu Three containers in Frame with Border Layout UI-components inside containers each with own layout
  • 12. Understanding the GUI • UI-containers – have list of UI-components • Each UI-component – is a class – with paint method – & lists of Event listeners {Frame} {label} {textfield} {button} components
  • 13. Understanding .NET UI Components • Overview – Replacement for VB Forms and MFC • Fully integrated with the .NET framework • Web Service aware • Data (ADO.NET and XML) aware • Secure code and Licensing – A framework for building Windows application • “No touch” deployment – No registration, Versionable, Smart caching – A RAD environment in Visual Studio .NET • Windows Form Designer, Property Browser
  • 14. Overview (cont) – Rich set of controls • Standard controls - Label, Button, TextBox, etc. • Common controls - ProgressBar, StatusBar, etc. • Data aware controls - ListBox, DataGrid, etc. • Common dialogs – ActiveX Interoperability • Can host ActiveX controls / author ActiveX controls – Printing Support – Visual inheritance • Create a form based on another form by using inheritance – Advanced layout • Anchoring and docking
  • 15. Basic Terms • Component – Timer, DB Connection • Control (User Control) – Windows Forms • Menu • Button • etc – Web Forms • ASP.NET specific
  • 16. Using VS.NET • Adding Components and Controls – Just drag component from the toolbox • Editing properties – Edit directly in the properties editor • Registering for events – Also in the properties editor
  • 17. What actually happens? • Data members for components • For example, after placing timer: public class FunnyButton : System.Windows.Forms.Button { private System.Windows.Forms.Timer timer1;
  • 18. What actually happens? • Attributes for the properties • For example, after changing Text property: private void InitializeComponent() { … this.Text = "ADO Example";
  • 19. What actually happens? • Delegates for events – Special type event in .NET (special delegate) private void InitializeComponent() { … this->MouseEnter += new System.EventHandler(this.UserControl1_MouseEnter ); … } … private void UserControl1_MouseEnter(object sender, System.EventArgs e) {}
  • 20. Names everyone should know • Properties – Name – data member name – Text – text shown by control (was Caption) – ForeColor – current text color – Dock – docking to the parent – Enabled – active or not • Events – Click – mouse click on the control – SizeChanged - resize
  • 21. InitializeComponent() method • This method is created by VS.NET • Code generated there represents all the changes done in the design view • Note: if you remove event handler or data member added by VS.NET manually, do not forget to clean the code that uses it from InitializeComponent(). • Doing this from the design view is easier!

Editor's Notes

  • #12: System calls paint method whenever it needs to display on screen (as may be necessary when restoring minimised window or one previously covered by another window.) Painting is an example of polymorphism in action. Note: components generally repaint themselves when properties (such as text label or colour) changed, but if you are extending one, eg. Frame, then you may sometimes need to explicitly tell it to repaint itself.
  翻译: