SlideShare uma empresa Scribd logo
1 de 71
Baixar para ler offline
C++.NET
Windows Forms Course
L02 – Controls Part 1

Mohammad Shaker
mohammadshakergtr.wordpress.com
C++.NET Windows Forms Course
@ZGTRShaker
Controls
•
•
•
•
•
•
•
•

Form
Button
CheckBox
CheckedListBox
ComboBox
Label
ListBox
PictureBox

•
•
•
•
•
•
•

ProgressBar
RadioButton
TextBox
Panel
TabControl
DataGridView
Timer
Windows Forms
Form’s Properties
Form’s Events

The Form is selected
Control Properties and Events
• Applications :
– Design Time VS runtime

• Controls :
– Properties
• Width , color .. etc

– Events
• MouseClick , MouseHover , DragDrop .. etc
Your First Form: Form1
Form’s Properties
– Properties :
•
•
•
•
•
•
•

BackColor
AutoSize
Font
Location
Opacity
Size (width , Height )
Text
Form’s Events
– Event :
•
•
•
•
•
•
•
•
•

Load
Click
KeyUp  down  ….
MouseOver  Down  leave  …
ResizeBegin  End
TextChange
Validation
FormClosing
Form Closed

(imp.)
Form at Design Time
With Form1 being selected
Form at Design Time
With Form1 being selected
.ico extension
Forms Live Testing
Changing Properties at runtime through Events
Button
23
Button
– Properties :

– Name , Text , Font , image , Location , Size , TabStop , TabIndex ,
Visible , BackColor
– Event :

– MouseClick , MouseDown , MouseLeave , Resize , SizeChange ,
TextChanged , VisibleChanged , KeyUp , KeyDown , DragDrop
Changing properties at runtime
• Considering we have the following design (at design time)
Changing properties at runtime
• Adding the following button event

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
button1 -> Text="I'm button1!!";
}

Control

Property

Valid value
Changing properties at runtime
• Adding the following button event

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
button1 -> Text="I'm button1!!";
}

Object (intsance)
Reference button by
its name

Data Member

Valid value
Changing properties at runtime

After clicking the button
Changing properties at runtime

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
Form1 -> Text=" Hello World ”;
}

Member

Valid value
Changing properties at runtime

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
Form1 -> Text=" Hello World ”;
}

Member

Valid value
Changing properties at runtime
• Now , let’s change the “Form”’s Text property .

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
Form1 -> Text=" Hello World ”;
}

Member

Valid value
Changing properties at runtime

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
this -> Text="Hello World";
}

Object at runtime
(reference to Form1)
Since we are inside
the Form1 class

Member

Value
Changing properties at runtime

After Clicking the Button
Changing properties at runtime
• Now , let’s change the “Form”’s Opacity property .

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
this -> Opacity=20;
}

Class

Member

Valid value
Changing properties at runtime
• Now , let’s change the “Form”’s Opacity property .

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
this -> Opacity=20;
}

Class

Member

Valid value
Changing properties at runtime
• Now , let’s change the “Form”’s Opacity property .

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
this -> Opacity=0.2;
}

Class

Member

Valid value
Changing properties at runtime

After Clicking the Button
Message Box
MessageBox
private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
MessageBox::Show("Hello!!!");
}
Let the .NET write for you.
Intellisense is ready to help you!
(Problem in 2010 and afterward)
21 Overload!
Form
Hide() vs Close()
Form Hide() vs Close()
What’s the difference between these two:

private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
this->Hide();
}

sender,

private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
this->Close();
}

sender,
Form – Hide problem!
Consider that we have only one form and we write the
following code:
private: System::Void Form1_Load(System::Object^
sender, System::EventArgs^ e)
{
this->Hide();
}

The form won’t be hidden on loading!
Form – Hide problem!
What happens now when breaking the project and run it again?

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
this->Hide();
}

It won’t compile! When hiding the form , the project is still processed!!!
So we should terminate its process first from task manager
Opacity Problem , too!
The applications are hidden but
not closed. All the memory
allocated by each hidden
application is still there
Application class
Application class
• Hierarchy :
– System.Windows.Forms

• Methods :
– Run
– Exit
Application class – Exit Method
• Informs all message pumps that they must terminate, and
then closes all application windows after the messages have
been processed.
Application::Exit();
Application class – Exit Method
• What will happen now?
The whole application (with all forms) will simply close and
the resources will be freed.
private: System::Void Form1_Load(System::Object^
System::EventArgs^ e)
{
Application::Exit();
}

sender,
Exit() vs Close()
• What’s the difference?
Application::Exit();
this->Close();
Managed vs Un-Managed
CODE
Managed VS Un-Managed
• Usually …
– Managed : .NET
– Un-Managed : C++

• gcnew
– Garbage collector
Managed VS Un-Managed
• Usually …
– Managed : .NET
– Un-Managed : C++

• gcnew
– Garbage collector
Managed VS Un-Managed
• Stack  heap “Un-Managed heap”  managed heap
int MyVar=10;

 stack

int *Ptr=new int;

 Un-Managed heap

int ^Ptr=gcnew int;  managed heap

• What’s the problem then?!!
Managed VS Un-Managed
• Let’s have the following, anything wrong?

int *Ptr=new int;
Ptr=NULL;

 Un-Managed heap

It’s a leaking in memory!

int ^Ptr=gcnew int;  managed heap
Ptr=NULL;
Not a leak anymore!
Managed VS Un-Managed
• Let’s have the following, anything wrong?
int *Ptr=new int;
Ptr=NULL;

 Un-Managed heap

It’s a leaking in memory!

int ^Ptr=gcnew int;  managed heap
Ptr=NULL;
Not a leak anymore!
Which one of these works?
private: System::Void button1_Click_1(System::Object^ sender,
System::EventArgs^ e)
{
Drawing::Size *S;
S->Height=200;
S->Width=300;
this->Size=*S;
}
there’s no new  unmanaged
private: System::Void button1_Click_1(System::Object^ sender,
System::EventArgs^ e)
{
Drawing::Size *S=gcnew Drawing::Size;
S->Height=200;
S->Width=300;
this->Size=*S;
gcnew with *  unmanaged with managed
}
private: System::Void button1_Click_1(System::Object^ sender,
System::EventArgs^ e)
{
Drawing::Size *S=new Drawing::Size;
S->Height=200;
S->Width=300;
this->Size=*S;
WORKS!  unmanaged
}
Which one of these works?
private: System::Void button1_Click_1(System::Object^ sender,
System::EventArgs^ e)
{
Drawing::Size *S=new Size;
S->Height=200;
S->Width=300;
this->Size=*S;
Un-Known Size identifier “3’laza :D”
}
private: System::Void button1_Click_1(System::Object^ sender,
System::EventArgs^ e)
{
Drawing::Size ^S=gcnew Drawing::Size;
S->Height=200;
S->Width=300;
this->Size=*S;
}
Works!  managed
private: System::Void button1_Click_1(System::Object^ sender,
System::EventArgs^ e)
{
Drawing::Size ^S=gcnew Drawing::Size;
S->Height=200;
S->Width=300;
this->Size=^S;
}
Compiler error .. No such
Which one of these works?
private: System::Void button1_Click_1(System::Object^
System::EventArgs^ e)
{
Drawing::Size ^S;
S->Height=200;
S->Width=300;
this->S=^S;
}
Error .. ^

sender,

private: System::Void button1_Click_1(System::Object^ sender,
System::EventArgs^ e)
{
Drawing::Size ^S=new Drawing::Size;
S->Height=200;
S->Width=300;
this->Size=^S;
}
Should be gcnew , not new
Which one of these works?

private: System::Void button1_Click_1(System::Object^
sender, System::EventArgs^ e)
{
this->Size=Drawing::Size(200,300);
}
Works!
Which one of these works?

private: System::Void button1_Click_1(System::Object^
sender, System::EventArgs^ e)
{
this->Size=Drawing::Size(200,300);
}
Works!
References
msdn Awesome library
C++ , C# , VB.NET , ASP.NET , XNA , XML ... etc
http://msdn.microsoft.com/en-us/library/default.aspx
That’s it for today!

Mais conteúdo relacionado

Mais procurados

C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 Mohammad Shaker
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202Mahmoud Samir Fayed
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Kuldeep Jain
 
The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181Mahmoud Samir Fayed
 
Chat Room System using Java Swing
Chat Room System using Java SwingChat Room System using Java Swing
Chat Room System using Java SwingTejas Garodia
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88Mahmoud Samir Fayed
 
C# Starter L07-Objects Cloning
C# Starter L07-Objects CloningC# Starter L07-Objects Cloning
C# Starter L07-Objects CloningMohammad Shaker
 
The Ring programming language version 1.5.1 book - Part 6 of 180
The Ring programming language version 1.5.1 book - Part 6 of 180The Ring programming language version 1.5.1 book - Part 6 of 180
The Ring programming language version 1.5.1 book - Part 6 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 7 of 184
The Ring programming language version 1.5.3 book - Part 7 of 184The Ring programming language version 1.5.3 book - Part 7 of 184
The Ring programming language version 1.5.3 book - Part 7 of 184Mahmoud Samir Fayed
 
DOM-based Test Adequacy Criteria for Web Applications
DOM-based Test Adequacy Criteria for Web ApplicationsDOM-based Test Adequacy Criteria for Web Applications
DOM-based Test Adequacy Criteria for Web ApplicationsSALT Lab @ UBC
 
Noguera jesus
Noguera jesusNoguera jesus
Noguera jesusgabo2200
 
The Ring programming language version 1.5.4 book - Part 7 of 185
The Ring programming language version 1.5.4 book - Part 7 of 185The Ring programming language version 1.5.4 book - Part 7 of 185
The Ring programming language version 1.5.4 book - Part 7 of 185Mahmoud Samir Fayed
 
Java programs
Java programsJava programs
Java programsjojeph
 
Aplikasi rawat-inap-vbnet
Aplikasi rawat-inap-vbnetAplikasi rawat-inap-vbnet
Aplikasi rawat-inap-vbnetDiaz Alfahrezy
 
The Ring programming language version 1.7 book - Part 7 of 196
The Ring programming language version 1.7 book - Part 7 of 196The Ring programming language version 1.7 book - Part 7 of 196
The Ring programming language version 1.7 book - Part 7 of 196Mahmoud Samir Fayed
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional ProgrammingDmitry Buzdin
 
C# Delegates, Events, Lambda
C# Delegates, Events, LambdaC# Delegates, Events, Lambda
C# Delegates, Events, LambdaJussi Pohjolainen
 

Mais procurados (20)

C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202
 
Bot builder v4 HOL
Bot builder v4 HOLBot builder v4 HOL
Bot builder v4 HOL
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.
 
The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181
 
VB Dot net
VB Dot net VB Dot net
VB Dot net
 
Chat Room System using Java Swing
Chat Room System using Java SwingChat Room System using Java Swing
Chat Room System using Java Swing
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
C# Starter L07-Objects Cloning
C# Starter L07-Objects CloningC# Starter L07-Objects Cloning
C# Starter L07-Objects Cloning
 
The Ring programming language version 1.5.1 book - Part 6 of 180
The Ring programming language version 1.5.1 book - Part 6 of 180The Ring programming language version 1.5.1 book - Part 6 of 180
The Ring programming language version 1.5.1 book - Part 6 of 180
 
The Ring programming language version 1.5.3 book - Part 7 of 184
The Ring programming language version 1.5.3 book - Part 7 of 184The Ring programming language version 1.5.3 book - Part 7 of 184
The Ring programming language version 1.5.3 book - Part 7 of 184
 
DOM-based Test Adequacy Criteria for Web Applications
DOM-based Test Adequacy Criteria for Web ApplicationsDOM-based Test Adequacy Criteria for Web Applications
DOM-based Test Adequacy Criteria for Web Applications
 
Noguera jesus
Noguera jesusNoguera jesus
Noguera jesus
 
The Ring programming language version 1.5.4 book - Part 7 of 185
The Ring programming language version 1.5.4 book - Part 7 of 185The Ring programming language version 1.5.4 book - Part 7 of 185
The Ring programming language version 1.5.4 book - Part 7 of 185
 
Java programs
Java programsJava programs
Java programs
 
Aplikasi rawat-inap-vbnet
Aplikasi rawat-inap-vbnetAplikasi rawat-inap-vbnet
Aplikasi rawat-inap-vbnet
 
The Ring programming language version 1.7 book - Part 7 of 196
The Ring programming language version 1.7 book - Part 7 of 196The Ring programming language version 1.7 book - Part 7 of 196
The Ring programming language version 1.7 book - Part 7 of 196
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
C# Delegates, Events, Lambda
C# Delegates, Events, LambdaC# Delegates, Events, Lambda
C# Delegates, Events, Lambda
 

Semelhante a C++ Windows Forms L02 - Controls P1

cse581_03_EventProgramming.ppt
cse581_03_EventProgramming.pptcse581_03_EventProgramming.ppt
cse581_03_EventProgramming.ppttadudemise
 
2006 - Basta!: Advanced server controls
2006 - Basta!: Advanced server controls2006 - Basta!: Advanced server controls
2006 - Basta!: Advanced server controlsDaniel Fisher
 
BSides MCR 2016: From CSV to CMD to qwerty
BSides MCR 2016: From CSV to CMD to qwertyBSides MCR 2016: From CSV to CMD to qwerty
BSides MCR 2016: From CSV to CMD to qwertyJerome Smith
 
06 win forms
06 win forms06 win forms
06 win formsmrjw
 
Understanding JavaScript Event-based Interactions
Understanding JavaScript Event-based InteractionsUnderstanding JavaScript Event-based Interactions
Understanding JavaScript Event-based InteractionsSALT Lab @ UBC
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Fwdays
 
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...Terrance Cohen
 
Junit in mule
Junit in muleJunit in mule
Junit in muleF K
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo javeed_mhd
 
CS101- Introduction to Computing- Lecture 32
CS101- Introduction to Computing- Lecture 32CS101- Introduction to Computing- Lecture 32
CS101- Introduction to Computing- Lecture 32Bilal Ahmed
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsFabian Jakobs
 
javascript Event Handling and introduction to event.ppt
javascript Event Handling and introduction to event.pptjavascript Event Handling and introduction to event.ppt
javascript Event Handling and introduction to event.pptLalith86
 
12 High Level UI Event Handling
12 High Level UI Event Handling12 High Level UI Event Handling
12 High Level UI Event Handlingcorneliuskoo
 

Semelhante a C++ Windows Forms L02 - Controls P1 (20)

cse581_03_EventProgramming.ppt
cse581_03_EventProgramming.pptcse581_03_EventProgramming.ppt
cse581_03_EventProgramming.ppt
 
44c
44c44c
44c
 
2006 - Basta!: Advanced server controls
2006 - Basta!: Advanced server controls2006 - Basta!: Advanced server controls
2006 - Basta!: Advanced server controls
 
BSides MCR 2016: From CSV to CMD to qwerty
BSides MCR 2016: From CSV to CMD to qwertyBSides MCR 2016: From CSV to CMD to qwerty
BSides MCR 2016: From CSV to CMD to qwerty
 
06 win forms
06 win forms06 win forms
06 win forms
 
Understanding JavaScript Event-based Interactions
Understanding JavaScript Event-based InteractionsUnderstanding JavaScript Event-based Interactions
Understanding JavaScript Event-based Interactions
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 
35c
35c35c
35c
 
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
17javascript.ppt
17javascript.ppt17javascript.ppt
17javascript.ppt
 
17javascript.ppt
17javascript.ppt17javascript.ppt
17javascript.ppt
 
CS101- Introduction to Computing- Lecture 32
CS101- Introduction to Computing- Lecture 32CS101- Introduction to Computing- Lecture 32
CS101- Introduction to Computing- Lecture 32
 
Session 5#
Session 5#Session 5#
Session 5#
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 
javascript Event Handling and introduction to event.ppt
javascript Event Handling and introduction to event.pptjavascript Event Handling and introduction to event.ppt
javascript Event Handling and introduction to event.ppt
 
12 High Level UI Event Handling
12 High Level UI Event Handling12 High Level UI Event Handling
12 High Level UI Event Handling
 

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

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 Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

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 Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

C++ Windows Forms L02 - Controls P1

  • 1. C++.NET Windows Forms Course L02 – Controls Part 1 Mohammad Shaker mohammadshakergtr.wordpress.com C++.NET Windows Forms Course @ZGTRShaker
  • 2.
  • 4.
  • 5.
  • 6.
  • 7.
  • 10.
  • 11. Control Properties and Events • Applications : – Design Time VS runtime • Controls : – Properties • Width , color .. etc – Events • MouseClick , MouseHover , DragDrop .. etc
  • 13. Form’s Properties – Properties : • • • • • • • BackColor AutoSize Font Location Opacity Size (width , Height ) Text
  • 14. Form’s Events – Event : • • • • • • • • • Load Click KeyUp down …. MouseOver Down leave … ResizeBegin End TextChange Validation FormClosing Form Closed (imp.)
  • 15. Form at Design Time With Form1 being selected
  • 16. Form at Design Time With Form1 being selected
  • 18.
  • 19.
  • 20. Forms Live Testing Changing Properties at runtime through Events
  • 22.
  • 23. 23
  • 24.
  • 25. Button – Properties : – Name , Text , Font , image , Location , Size , TabStop , TabIndex , Visible , BackColor – Event : – MouseClick , MouseDown , MouseLeave , Resize , SizeChange , TextChanged , VisibleChanged , KeyUp , KeyDown , DragDrop
  • 26. Changing properties at runtime • Considering we have the following design (at design time)
  • 27. Changing properties at runtime • Adding the following button event private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { button1 -> Text="I'm button1!!"; } Control Property Valid value
  • 28. Changing properties at runtime • Adding the following button event private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { button1 -> Text="I'm button1!!"; } Object (intsance) Reference button by its name Data Member Valid value
  • 29. Changing properties at runtime After clicking the button
  • 30. Changing properties at runtime private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form1 -> Text=" Hello World ”; } Member Valid value
  • 31. Changing properties at runtime private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form1 -> Text=" Hello World ”; } Member Valid value
  • 32. Changing properties at runtime • Now , let’s change the “Form”’s Text property . private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form1 -> Text=" Hello World ”; } Member Valid value
  • 33. Changing properties at runtime private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { this -> Text="Hello World"; } Object at runtime (reference to Form1) Since we are inside the Form1 class Member Value
  • 34. Changing properties at runtime After Clicking the Button
  • 35. Changing properties at runtime • Now , let’s change the “Form”’s Opacity property . private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { this -> Opacity=20; } Class Member Valid value
  • 36. Changing properties at runtime • Now , let’s change the “Form”’s Opacity property . private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { this -> Opacity=20; } Class Member Valid value
  • 37. Changing properties at runtime • Now , let’s change the “Form”’s Opacity property . private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { this -> Opacity=0.2; } Class Member Valid value
  • 38. Changing properties at runtime After Clicking the Button
  • 40. MessageBox private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { MessageBox::Show("Hello!!!"); }
  • 41. Let the .NET write for you. Intellisense is ready to help you! (Problem in 2010 and afterward)
  • 42.
  • 43.
  • 44.
  • 45.
  • 48. Form Hide() vs Close() What’s the difference between these two: private: System::Void button1_Click(System::Object^ System::EventArgs^ e) { this->Hide(); } sender, private: System::Void button1_Click(System::Object^ System::EventArgs^ e) { this->Close(); } sender,
  • 49. Form – Hide problem! Consider that we have only one form and we write the following code: private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { this->Hide(); } The form won’t be hidden on loading!
  • 50. Form – Hide problem! What happens now when breaking the project and run it again? private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { this->Hide(); } It won’t compile! When hiding the form , the project is still processed!!! So we should terminate its process first from task manager
  • 52. The applications are hidden but not closed. All the memory allocated by each hidden application is still there
  • 54. Application class • Hierarchy : – System.Windows.Forms • Methods : – Run – Exit
  • 55.
  • 56. Application class – Exit Method • Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed. Application::Exit();
  • 57. Application class – Exit Method • What will happen now? The whole application (with all forms) will simply close and the resources will be freed. private: System::Void Form1_Load(System::Object^ System::EventArgs^ e) { Application::Exit(); } sender,
  • 58. Exit() vs Close() • What’s the difference? Application::Exit(); this->Close();
  • 60. Managed VS Un-Managed • Usually … – Managed : .NET – Un-Managed : C++ • gcnew – Garbage collector
  • 61. Managed VS Un-Managed • Usually … – Managed : .NET – Un-Managed : C++ • gcnew – Garbage collector
  • 62. Managed VS Un-Managed • Stack heap “Un-Managed heap” managed heap int MyVar=10; stack int *Ptr=new int; Un-Managed heap int ^Ptr=gcnew int; managed heap • What’s the problem then?!!
  • 63. Managed VS Un-Managed • Let’s have the following, anything wrong? int *Ptr=new int; Ptr=NULL; Un-Managed heap It’s a leaking in memory! int ^Ptr=gcnew int; managed heap Ptr=NULL; Not a leak anymore!
  • 64. Managed VS Un-Managed • Let’s have the following, anything wrong? int *Ptr=new int; Ptr=NULL; Un-Managed heap It’s a leaking in memory! int ^Ptr=gcnew int; managed heap Ptr=NULL; Not a leak anymore!
  • 65. Which one of these works? private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { Drawing::Size *S; S->Height=200; S->Width=300; this->Size=*S; } there’s no new unmanaged private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { Drawing::Size *S=gcnew Drawing::Size; S->Height=200; S->Width=300; this->Size=*S; gcnew with * unmanaged with managed } private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { Drawing::Size *S=new Drawing::Size; S->Height=200; S->Width=300; this->Size=*S; WORKS! unmanaged }
  • 66. Which one of these works? private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { Drawing::Size *S=new Size; S->Height=200; S->Width=300; this->Size=*S; Un-Known Size identifier “3’laza :D” } private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { Drawing::Size ^S=gcnew Drawing::Size; S->Height=200; S->Width=300; this->Size=*S; } Works! managed private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { Drawing::Size ^S=gcnew Drawing::Size; S->Height=200; S->Width=300; this->Size=^S; } Compiler error .. No such
  • 67. Which one of these works? private: System::Void button1_Click_1(System::Object^ System::EventArgs^ e) { Drawing::Size ^S; S->Height=200; S->Width=300; this->S=^S; } Error .. ^ sender, private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { Drawing::Size ^S=new Drawing::Size; S->Height=200; S->Width=300; this->Size=^S; } Should be gcnew , not new
  • 68. Which one of these works? private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { this->Size=Drawing::Size(200,300); } Works!
  • 69. Which one of these works? private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { this->Size=Drawing::Size(200,300); } Works!
  • 70. References msdn Awesome library C++ , C# , VB.NET , ASP.NET , XNA , XML ... etc http://msdn.microsoft.com/en-us/library/default.aspx
  • 71. That’s it for today!