SlideShare a Scribd company logo
1 of 57
Download to read offline
C++.NET
Windows Forms Course
L03 – Controls Part 2

Mohammad Shaker
mohammadshakergtr.wordpress.com
C++.NET Windows Forms Course
@ZGTRShaker
Switching Between Forms
It’s another form..
Switching between forms
Switching to a another forms
• Let’s consider that we want to have two forms and we want
to switch between them
– #1: First of all we add a new “second” form to out project
• Add > new item > form

– #2: include its header in first form header file
– ( “Form1.h” file )
#include "Form2.h"
– #3: pointing to the other form
Form2 ^f= gcnew Form2;
– #4: and start playing with it :D
f->Show();
Switching Back to Form1
• In “Form2.h”
namespace MyTestPro {
ref class Form1;
public: Form1 ^FPtr;
Form2(Form1 ^f)
{
InitializeComponent();
FPtr= f;
}
Switching Back to Form1
• In “Form2.cpp”
#include "StdAfx.h"
#include "Form2.h"
#include "Form1.h”
namespace MyTestPro {
System::Void Form2::Form2_Load(System::Object^
System::EventArgs^ e)
{
FPtr->Text= “New Form1 Text!";
}
}

sender,
Peak on Drawing Class
Point & Size
Peak on Drawing::Point
• What will happen now?

private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
button1->Location= 30,120;
}
Peak on Drawing::Point
Peak on Drawing::Point
• What will happen now?
private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
Drawing::Point P;
P.X= 2;
P.Y= 23;
button1->Location= P;
}

sender,
Drawing::Point
Helpers
Helpers

So, what should
we do?
Point and Size
• Can we do this? Yes!
private: System::Void button1_Click_1(System::Object^
System::EventArgs^ e)
{
Drawing::Size S;
S.Height= 200;
S.Width= 300;
this->Size= S;
}

sender,
Point and Size
• Can we do this?
private: System::Void button1_Click_1(System::Object^
System::EventArgs^ e)
{
Drawing::Size ^S;
S->Height= 200;
S->Width= 300;
this->Size= S;
}

sender,

Compile error
Error
1
error C2664: 'void
System::Windows::Forms::Control::Size::set(System::Drawing::Size)':
cannot convert parameter 1 from 'System::Drawing::Size ^' to
'System::Drawing::Size'
c:userszgtrdocumentsvisual studio
2008projectsdotnet4dotnet4Form1.h 129
dotNet4
Helpers
Point and Size
private: System::Void button1_Click_1(System::Object^
sender, System::EventArgs^ e)
{
this->Size= Drawing::Size(200,300);
}
Works!
Helpers
Point and Size
Label
Label
• Properties:
Name, Text, Font, image, Location, Size, TabStop, TabIndex,
Visible, BackColor

• Event:
MouseClick, MouseDown, MouseLeave, Resize, SizeChange,
TextChanged, VisibleChanged, KeyUp, KeyDown, DragDrop
TextBox
TextBox
• Properties:
Name, Text, Font, image, Location, Size, TabStop, TabIndex,
Visible, BackColor, MultiLine, ScrollBar

• Event:
MouseClick, MouseDown, MouseLeave, Resize, SizeChange,
TextChanged, VisibleChanged, KeyUp, KeyDown, DragDrop
Panel
Panel
• Properties:
Name, Text, Font, image, Location, Size, TabStop, TabIndex,
Visible, BackColor, Border Style, AutoSize

• Event:
MouseClick, MouseDown, MouseLeave, Resize, SizeChange,
TextChanged, VisibleChanged, KeyUp, KeyDown, DragDrop
TrackBar
TrackBar
TrackBar
TrackBar

Keyboard keys (Arrows)
Number of ticks between tick
marks
position
TrackBar
• What will happen now?
private: System::Void trackBar1_Scroll(System::Object^
System::EventArgs^ e)
{
textBox1->Text= trackBar1->Value.ToString();
}

sender,
TrackBar
ProgressBar
ProgressBar
ProgressBar
ProgressBar
ProgressBar
• Increment the progressBar and perform the “performStep()”
• What will happen when pressing the button?
private: System::Void button1_Click_4(System::Object^
System::EventArgs^ e)
{
progressBar1->PerformStep();
}

sender,
ProgressBar
• What will happen now when pressing the button, repeatedly?
private: System::Void button1_Click_4(System::Object^ sender,
System::EventArgs^ e)
{
progressBar1->PerformStep();
textBox1->Text= progressBar1->Value.ToString();
}
ProgressBar

Before clicking button1

After clicking button1 for 1st time

After clicking button1 for 2nd time
ProgressBar
• Another example:
– The following code example uses a ProgressBar control to display the
progress of a file copy operation. The example uses
the Minimum and Maximum properties to specify a range for
the ProgressBar that is equivalent to the number of files to copy. The
code also uses the Step property with the PerformStep method to
increment the value of theProgressBar as a file is copied. This example
requires that you have a ProgressBar control created called pBar1 that
is created within a Form and that there is a method created
called CopyFile (that returns a Boolean value indicating the file copy
operation was completed successfully) that performs the file copy
operation. The code also requires that an array of strings containing
the files to copy is created and passed to
the CopyWithProgress method defined in the example and that the
method is called from another method or event in the Form.
private:
void CopyWithProgress( array<String^>^filenames )
{
// Display the ProgressBar control.
pBar1->Visible= true;
// Set Minimum to 1 to represent the first file being copied.
pBar1->Minimum= 1;
// Set Maximum to the total number of files to copy.
pBar1->Maximum= filenames->Length;
// Set the initial value of the ProgressBar.
pBar1->Value= 1;
// Set the Step property to a value of 1 to represent each file being
copied.
pBar1->Step= 1;
// Loop through all files to copy.
for ( int x= 1; x <= filenames->Length; x++ )
{
// Copy the file and increment the ProgressBar if successful.
if ( CopyFile( filenames[ x - 1 ] )== true )
{
// Perform the increment on the ProgressBar.
pBar1->PerformStep();
}
}
}
NumericUpDown
NumericUpDown properties
The interval

Starting value
NumericUpDown - coding
• Text property
private: System::Void button1_Click_1(System::Object^
System::EventArgs^ e)
{
textBox1->Text= numericUpDown1->Text;
}

sender,
NumericUpDown - coding
• Everything ok?

private: System::Void textBox1_TextChanged(System::Object^
System::EventArgs^ e)
{
numericUpDown1->Value=

textBox1->Text;

}
Compiler error. String assigned to int

sender,
NumericUpDown - coding
• As always, we can change anything at runtime

private: System::Void textBox1_TextChanged(System::Object^
System::EventArgs^ e)
{
numericUpDown1->Value=
}

int::Parse(textBox1->Text);

sender,
NumericUpDown - coding
• As always, we can change anything at runtime
private: System::Void textBox1_TextChanged(System::Object^
System::EventArgs^ e)

sender,

{
int i =int::TryParse(textBox1->Text, numericUpDown1->Value);
}
NumericUpDown - coding
• As always, we can change anything at runtime

private: System::Void textBox1_TextChanged(System::Object^
System::EventArgs^ e)
{
numericUpDown1->Text=
}

textBox1->Text;

sender,
PictureBox
PictureBox
• Very important for drawing!
PictureBox
PictureBox
PictureBox
PictureBox
PictureBox
PictureBox .gif
That’s it for today!

More Related Content

What's hot

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
 
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
 
C# console programms
C# console programmsC# console programms
C# console programmsYasir Khan
 
Pattern printing programs
Pattern printing programsPattern printing programs
Pattern printing programsMukesh Tekwani
 
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
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring ClojurescriptLuke Donnet
 
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
 
Inventory management
Inventory managementInventory management
Inventory managementRajeev Sharan
 
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
 
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
 
Python 3.6 Features 20161207
Python 3.6 Features 20161207Python 3.6 Features 20161207
Python 3.6 Features 20161207Jay Coskey
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180Mahmoud Samir Fayed
 

What's hot (20)

VB Dot net
VB Dot net VB Dot net
VB Dot net
 
.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
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
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
 
C# console programms
C# console programmsC# console programms
C# console programms
 
Pattern printing programs
Pattern printing programsPattern printing programs
Pattern printing programs
 
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#
C#C#
C#
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
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
 
Inventory management
Inventory managementInventory management
Inventory management
 
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
 
Calculator code
Calculator codeCalculator code
Calculator code
 
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
 
Ete programs
Ete programsEte programs
Ete programs
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
Python 3.6 Features 20161207
Python 3.6 Features 20161207Python 3.6 Features 20161207
Python 3.6 Features 20161207
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180
 

Similar to C++ Windows Forms L03 - Controls P2

JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object ModelWebStackAcademy
 
TEMPLATES IN JAVA
TEMPLATES IN JAVATEMPLATES IN JAVA
TEMPLATES IN JAVAMuskanSony
 
Electronic Grading of Paper Assessments
Electronic Grading of Paper AssessmentsElectronic Grading of Paper Assessments
Electronic Grading of Paper AssessmentsMatthew Leingang
 
Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...
Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...
Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...Rainer Stropek
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84Mahmoud Samir Fayed
 
Python advanced 3.the python std lib by example – system related modules
Python advanced 3.the python std lib by example – system related modulesPython advanced 3.the python std lib by example – system related modules
Python advanced 3.the python std lib by example – system related modulesJohn(Qiang) Zhang
 
Python Programming for ArcGIS: Part II
Python Programming for ArcGIS: Part IIPython Programming for ArcGIS: Part II
Python Programming for ArcGIS: Part IIDUSPviz
 
ITPROceed 2016 - The Art of PowerShell Toolmaking
ITPROceed 2016 - The Art of PowerShell ToolmakingITPROceed 2016 - The Art of PowerShell Toolmaking
ITPROceed 2016 - The Art of PowerShell ToolmakingKurt Roggen [BE]
 
Net beans
Net beansNet beans
Net beansRiya Ch
 
Unit iii vb_study_materials
Unit iii vb_study_materialsUnit iii vb_study_materials
Unit iii vb_study_materialsgayaramesh
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsRobert MacLean
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on PythonSumit Raj
 

Similar to C++ Windows Forms L03 - Controls P2 (20)

Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 
Rstudio ide-cheatsheet
Rstudio ide-cheatsheetRstudio ide-cheatsheet
Rstudio ide-cheatsheet
 
Rstudio ide-cheatsheet
Rstudio ide-cheatsheetRstudio ide-cheatsheet
Rstudio ide-cheatsheet
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
TEMPLATES IN JAVA
TEMPLATES IN JAVATEMPLATES IN JAVA
TEMPLATES IN JAVA
 
Electronic Grading of Paper Assessments
Electronic Grading of Paper AssessmentsElectronic Grading of Paper Assessments
Electronic Grading of Paper Assessments
 
Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...
Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...
Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...
 
ASP DOT NET
ASP DOT NETASP DOT NET
ASP DOT NET
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
 
Python advanced 3.the python std lib by example – system related modules
Python advanced 3.the python std lib by example – system related modulesPython advanced 3.the python std lib by example – system related modules
Python advanced 3.the python std lib by example – system related modules
 
Python Programming for ArcGIS: Part II
Python Programming for ArcGIS: Part IIPython Programming for ArcGIS: Part II
Python Programming for ArcGIS: Part II
 
ITPROceed 2016 - The Art of PowerShell Toolmaking
ITPROceed 2016 - The Art of PowerShell ToolmakingITPROceed 2016 - The Art of PowerShell Toolmaking
ITPROceed 2016 - The Art of PowerShell Toolmaking
 
Net beans
Net beansNet beans
Net beans
 
Unit iii vb_study_materials
Unit iii vb_study_materialsUnit iii vb_study_materials
Unit iii vb_study_materials
 
Controls events
Controls eventsControls events
Controls events
 
19csharp
19csharp19csharp
19csharp
 
19c
19c19c
19c
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 Enhancements
 
C# p3
C# p3C# p3
C# p3
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on Python
 

More from 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
 

More from 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
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
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
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
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
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

C++ Windows Forms L03 - Controls P2

  • 1. C++.NET Windows Forms Course L03 – Controls Part 2 Mohammad Shaker mohammadshakergtr.wordpress.com C++.NET Windows Forms Course @ZGTRShaker
  • 5. Switching to a another forms • Let’s consider that we want to have two forms and we want to switch between them – #1: First of all we add a new “second” form to out project • Add > new item > form – #2: include its header in first form header file – ( “Form1.h” file ) #include "Form2.h" – #3: pointing to the other form Form2 ^f= gcnew Form2; – #4: and start playing with it :D f->Show();
  • 6. Switching Back to Form1 • In “Form2.h” namespace MyTestPro { ref class Form1; public: Form1 ^FPtr; Form2(Form1 ^f) { InitializeComponent(); FPtr= f; }
  • 7. Switching Back to Form1 • In “Form2.cpp” #include "StdAfx.h" #include "Form2.h" #include "Form1.h” namespace MyTestPro { System::Void Form2::Form2_Load(System::Object^ System::EventArgs^ e) { FPtr->Text= “New Form1 Text!"; } } sender,
  • 8. Peak on Drawing Class Point & Size
  • 9. Peak on Drawing::Point • What will happen now? private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { button1->Location= 30,120; }
  • 11. Peak on Drawing::Point • What will happen now? private: System::Void button1_Click(System::Object^ System::EventArgs^ e) { Drawing::Point P; P.X= 2; P.Y= 23; button1->Location= P; } sender,
  • 15. Point and Size • Can we do this? Yes! private: System::Void button1_Click_1(System::Object^ System::EventArgs^ e) { Drawing::Size S; S.Height= 200; S.Width= 300; this->Size= S; } sender,
  • 16. Point and Size • Can we do this? private: System::Void button1_Click_1(System::Object^ System::EventArgs^ e) { Drawing::Size ^S; S->Height= 200; S->Width= 300; this->Size= S; } sender, Compile error Error 1 error C2664: 'void System::Windows::Forms::Control::Size::set(System::Drawing::Size)': cannot convert parameter 1 from 'System::Drawing::Size ^' to 'System::Drawing::Size' c:userszgtrdocumentsvisual studio 2008projectsdotnet4dotnet4Form1.h 129 dotNet4
  • 18. Point and Size private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { this->Size= Drawing::Size(200,300); } Works!
  • 21. Label
  • 22. Label • Properties: Name, Text, Font, image, Location, Size, TabStop, TabIndex, Visible, BackColor • Event: MouseClick, MouseDown, MouseLeave, Resize, SizeChange, TextChanged, VisibleChanged, KeyUp, KeyDown, DragDrop
  • 24. TextBox • Properties: Name, Text, Font, image, Location, Size, TabStop, TabIndex, Visible, BackColor, MultiLine, ScrollBar • Event: MouseClick, MouseDown, MouseLeave, Resize, SizeChange, TextChanged, VisibleChanged, KeyUp, KeyDown, DragDrop
  • 25. Panel
  • 26. Panel • Properties: Name, Text, Font, image, Location, Size, TabStop, TabIndex, Visible, BackColor, Border Style, AutoSize • Event: MouseClick, MouseDown, MouseLeave, Resize, SizeChange, TextChanged, VisibleChanged, KeyUp, KeyDown, DragDrop
  • 30. TrackBar Keyboard keys (Arrows) Number of ticks between tick marks position
  • 31. TrackBar • What will happen now? private: System::Void trackBar1_Scroll(System::Object^ System::EventArgs^ e) { textBox1->Text= trackBar1->Value.ToString(); } sender,
  • 37. ProgressBar • Increment the progressBar and perform the “performStep()” • What will happen when pressing the button? private: System::Void button1_Click_4(System::Object^ System::EventArgs^ e) { progressBar1->PerformStep(); } sender,
  • 38. ProgressBar • What will happen now when pressing the button, repeatedly? private: System::Void button1_Click_4(System::Object^ sender, System::EventArgs^ e) { progressBar1->PerformStep(); textBox1->Text= progressBar1->Value.ToString(); }
  • 39. ProgressBar Before clicking button1 After clicking button1 for 1st time After clicking button1 for 2nd time
  • 40. ProgressBar • Another example: – The following code example uses a ProgressBar control to display the progress of a file copy operation. The example uses the Minimum and Maximum properties to specify a range for the ProgressBar that is equivalent to the number of files to copy. The code also uses the Step property with the PerformStep method to increment the value of theProgressBar as a file is copied. This example requires that you have a ProgressBar control created called pBar1 that is created within a Form and that there is a method created called CopyFile (that returns a Boolean value indicating the file copy operation was completed successfully) that performs the file copy operation. The code also requires that an array of strings containing the files to copy is created and passed to the CopyWithProgress method defined in the example and that the method is called from another method or event in the Form.
  • 41. private: void CopyWithProgress( array<String^>^filenames ) { // Display the ProgressBar control. pBar1->Visible= true; // Set Minimum to 1 to represent the first file being copied. pBar1->Minimum= 1; // Set Maximum to the total number of files to copy. pBar1->Maximum= filenames->Length; // Set the initial value of the ProgressBar. pBar1->Value= 1; // Set the Step property to a value of 1 to represent each file being copied. pBar1->Step= 1; // Loop through all files to copy. for ( int x= 1; x <= filenames->Length; x++ ) { // Copy the file and increment the ProgressBar if successful. if ( CopyFile( filenames[ x - 1 ] )== true ) { // Perform the increment on the ProgressBar. pBar1->PerformStep(); } } }
  • 44. NumericUpDown - coding • Text property private: System::Void button1_Click_1(System::Object^ System::EventArgs^ e) { textBox1->Text= numericUpDown1->Text; } sender,
  • 45. NumericUpDown - coding • Everything ok? private: System::Void textBox1_TextChanged(System::Object^ System::EventArgs^ e) { numericUpDown1->Value= textBox1->Text; } Compiler error. String assigned to int sender,
  • 46. NumericUpDown - coding • As always, we can change anything at runtime private: System::Void textBox1_TextChanged(System::Object^ System::EventArgs^ e) { numericUpDown1->Value= } int::Parse(textBox1->Text); sender,
  • 47. NumericUpDown - coding • As always, we can change anything at runtime private: System::Void textBox1_TextChanged(System::Object^ System::EventArgs^ e) sender, { int i =int::TryParse(textBox1->Text, numericUpDown1->Value); }
  • 48. NumericUpDown - coding • As always, we can change anything at runtime private: System::Void textBox1_TextChanged(System::Object^ System::EventArgs^ e) { numericUpDown1->Text= } textBox1->Text; sender,
  • 57. That’s it for today!