SlideShare a Scribd company logo
MFC(Microsoft Foundation Class
Library) Message Handling
Janani A
10 Oct 2011
Agenda
• Win32 application
• MFC
• Macros
• Message mapping
A Windows program
InitApplication()
Windows Program (contd…)
InitInstance()
Run()
Message Handler
MFC - Overview
• An "application framework" for programming in Microsoft
Windows.
• It's easy to extend or override the basic functionality that MFC
provides.
• Object Linking and Embedding (OLE), Data Access Objects
(DAO) and Open Database Connectivity (ODBC) etc
Execution begins here…
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
ASSERT(hPrevInstance == NULL);
int nReturnCode = -1;
CWinApp* pApp = AfxGetApp();
// AFX internal initialization
if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
goto InitFailure;
// App global initializations (rare)
ASSERT_VALID(pApp);
if (pApp != NULL && !pApp->InitApplication())
goto InitFailure;
ASSERT_VALID(pApp);
// Perform specific initializations
if (!pApp->InitInstance())
{
if (pApp->m_pMainWnd != NULL)
{
TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWndn");
pApp->m_pMainWnd->DestroyWindow();
}
nReturnCode = pApp->ExitInstance();
goto InitFailure;
}
ASSERT_VALID(pApp);
nReturnCode = pApp->Run();
ASSERT_VALID(pApp);
InitFailure:
AfxWinTerm();
return nReturnCode;
}
The Windows program using MFC
class MyApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};
class MyWnd : public CFrameWnd
{
public:
MyWnd()
{
Create (NULL, "My Application");
}
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(MyWnd, CFrameWnd)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
void MyWnd:: OnLButtonDown(UINT nFlags, CPoint point)
{
MessageBox(TEXT("Left mouse button pressed..."),NULL,MB_OK);
}
BOOL MyApp:: InitInstance()
{
m_pMainWnd = new MyWnd();
m_pMainWnd -> ShowWindow(m_nCmdShow);
m_pMainWnd -> UpdateWindow();
return TRUE;
}
MyApp intApp;
Macros
//DECLARE_MESSAGE_MAP()
#define DECLARE_MESSAGE_MAP() 
private :
static const AFX_MSGMAP_ENTRY _messageEntries[];
protected:
static const AFX_MSGMAP messageMap;
virtual const AFX_MSGMAP* GetMessageMap() const;
//BEGIN_MESSAGE_MAP()
#define BEGIN_MESSAGE_MAP(theClass, baseClass) 
const AFX_MSGMAP* theClass::GetMessageMap() const 
{ return &theClass::messageMap; } 
AFX_DATADEF const AFX_MSGMAP theClass::messageMap = 
{ &baseClass::messageMap, &theClass::_messageEntries[0] }; 
const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = 
{ 
#define END_MESSAGE_MAP() 
{0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } 
};
#define ON_WM_LBUTTONDOWN() 
{ WM_LBUTTONDOWN, 0, 0, 0, AfxSig_vwp, 
(AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(UINT, CPoint))&OnLButtonDown },
After Pre-processing
class MyApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};
class MyWnd : public CFrameWnd
{
public:
MyWnd()
{
Create (NULL, "My Application");
}
afx_msg void snFlags, CPoint point);
private :
static const AFX_MSGMAP_ENTRY
_messageEntries[];
protected:
static const AFX_MSGMAP messageMap;
virtual const AFX_MSGMAP* GetMessageMap()
const;
};
const AFX_MSGMAP* MyWnd::GetMessageMap() const
{ return & MyWnd::messageMap; }
AFX_DATADEF const AFX_MSGMAP MyWnd::messageMap =
{ &CFrameWnd::messageMap, & MyWnd::_messageEntries[0] };
const AFX_MSGMAP_ENTRY MyWnd::_messageEntries[] =
{
{ WM_LBUTTONDOWN, 0, 0, 0, AfxSig_vwp,
(AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL
CWnd::*)(UINT, CPoint))&OnLButtonDown },
{0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 }
};
void MyWnd:: OnLButtonDown(UINT nFlags, CPoint point)
{
MessageBox(TEXT("Left mouse button pressed..."),
NULL,MB_OK);
}
BOOL MyApp:: InitInstance()
{
m_pMainWnd = new MyWnd();
m_pMainWnd -> ShowWindow(m_nCmdShow);
m_pMainWnd -> UpdateWindow();
return TRUE;
}
MyApp intApp;
Message map structures
Message Handling
• The CCmdTarget class: Base class for CFrameWnd,
CView, CWinApp, CDocument, CWnd with functions/
handlers for polymorphism. Override base functions
for custom behavior.
• Message Maps: Map the message codes to handlers
(CCmdTarget). Declare with
DECLARE_MESSAGE_MAP
References
• http://msdn.microsoft.com/en-us/library/d06h2x6e(v=vs.80).aspx
• http://www.functionx.com/visualc/
• MFC Internals- Inside The Microsoft Foundation Class, George Shepherd
and Scot Wingo
• http://home.arcor.de/it-
solution/cpp/books/Professional%20MFC/CH03_7.HTM
• afxmsg_.h
THANK YOU

More Related Content

What's hot

Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
C# programming language
C# programming languageC# programming language
C# programming language
swarnapatil
 
Introduction to c#
Introduction to c#Introduction to c#
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
Jafar Nesargi
 
Windows programming ppt
Windows programming pptWindows programming ppt
Windows programming ppt
SAMIR CHANDRA
 
Java features
Java featuresJava features
Java features
Prashant Gajendra
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
Laxman Puri
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Java Lover
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
Vishwa Mohan
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
Sangharsh agarwal
 
Event Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdfEvent Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdf
AliEndris3
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
Google
 
Kotlin
KotlinKotlin
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
Aneega
 
Hibernate
HibernateHibernate
Hibernate
Ajay K
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Features of java
Features of javaFeatures of java
Features of java
WILLFREDJOSE W
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
SAMIR BHOGAYTA
 

What's hot (20)

Interface in java
Interface in javaInterface in java
Interface in java
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
C# programming language
C# programming languageC# programming language
C# programming language
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 
Windows programming ppt
Windows programming pptWindows programming ppt
Windows programming ppt
 
Java features
Java featuresJava features
Java features
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
Event Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdfEvent Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdf
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Kotlin
KotlinKotlin
Kotlin
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Hibernate
HibernateHibernate
Hibernate
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
Features of java
Features of javaFeatures of java
Features of java
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 

Viewers also liked

C++ idioms.pptx
C++ idioms.pptxC++ idioms.pptx
C++ idioms.pptx
Janani Anbarasan
 
Multi-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile RobotsMulti-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile Robots
Jun Kato
 
Giáo trình lập trình GDI+
Giáo trình lập trình GDI+Giáo trình lập trình GDI+
Giáo trình lập trình GDI+
Sự Phạm Thành
 
Photography planning
Photography planningPhotography planning
Photography planning
EmilyPlenty
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
Terry Yoast
 
Vc++ 3
Vc++ 3Vc++ 3
Vc++ 3
Raman Rv
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
Ali Aminian
 
Handling Exceptions In C & C++[Part A]
Handling Exceptions In C & C++[Part A]Handling Exceptions In C & C++[Part A]
Handling Exceptions In C & C++[Part A]
ppd1961
 
COM
COMCOM
Tema exhausted tot energiek
Tema  exhausted tot energiekTema  exhausted tot energiek
Tema exhausted tot energiek
AGS Lofoord Upington
 
Ecuador | Jan-17 | Taller Comunidad Resiliente
Ecuador | Jan-17 | Taller Comunidad ResilienteEcuador | Jan-17 | Taller Comunidad Resiliente
Ecuador | Jan-17 | Taller Comunidad Resiliente
Smart Villages
 
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL
 
Active x control
Active x controlActive x control
Active x control
Amandeep Kaur
 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
BABAVALI S
 
про зміни ат. ком. 2017
про зміни ат. ком. 2017про зміни ат. ком. 2017
про зміни ат. ком. 2017
solom_nmc
 
Bitmap and Vector Images: Make Sure You Know the Differences
Bitmap and Vector Images: Make Sure You Know the DifferencesBitmap and Vector Images: Make Sure You Know the Differences
Bitmap and Vector Images: Make Sure You Know the Differences
Davina and Caroline
 
VC++ Fundamentals
VC++ FundamentalsVC++ Fundamentals
VC++ Fundamentals
ranigiyer
 

Viewers also liked (17)

C++ idioms.pptx
C++ idioms.pptxC++ idioms.pptx
C++ idioms.pptx
 
Multi-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile RobotsMulti-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile Robots
 
Giáo trình lập trình GDI+
Giáo trình lập trình GDI+Giáo trình lập trình GDI+
Giáo trình lập trình GDI+
 
Photography planning
Photography planningPhotography planning
Photography planning
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
Vc++ 3
Vc++ 3Vc++ 3
Vc++ 3
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
 
Handling Exceptions In C & C++[Part A]
Handling Exceptions In C & C++[Part A]Handling Exceptions In C & C++[Part A]
Handling Exceptions In C & C++[Part A]
 
COM
COMCOM
COM
 
Tema exhausted tot energiek
Tema  exhausted tot energiekTema  exhausted tot energiek
Tema exhausted tot energiek
 
Ecuador | Jan-17 | Taller Comunidad Resiliente
Ecuador | Jan-17 | Taller Comunidad ResilienteEcuador | Jan-17 | Taller Comunidad Resiliente
Ecuador | Jan-17 | Taller Comunidad Resiliente
 
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
 
Active x control
Active x controlActive x control
Active x control
 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
 
про зміни ат. ком. 2017
про зміни ат. ком. 2017про зміни ат. ком. 2017
про зміни ат. ком. 2017
 
Bitmap and Vector Images: Make Sure You Know the Differences
Bitmap and Vector Images: Make Sure You Know the DifferencesBitmap and Vector Images: Make Sure You Know the Differences
Bitmap and Vector Images: Make Sure You Know the Differences
 
VC++ Fundamentals
VC++ FundamentalsVC++ Fundamentals
VC++ Fundamentals
 

Similar to MFC Message Handling

Borland star team to tfs simple migration
Borland star team to tfs simple migrationBorland star team to tfs simple migration
Borland star team to tfs simple migration
Shreesha Rao
 
The ProblemUsing C programming language write a program that simul.pdf
The ProblemUsing C programming language write a program that simul.pdfThe ProblemUsing C programming language write a program that simul.pdf
The ProblemUsing C programming language write a program that simul.pdf
federaleyecare
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
Max Kleiner
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Vincenzo Iozzo
 
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
InfluxData
 
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksBeginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeks
JinTaek Seo
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
Jeetendra singh
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
Michiel Borkent
 
Lab 2
Lab 2Lab 2
T-121-5300 (2008) User Interface Design 10 - UIML
T-121-5300 (2008) User Interface Design 10 - UIMLT-121-5300 (2008) User Interface Design 10 - UIML
T-121-5300 (2008) User Interface Design 10 - UIML
mniemi
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2
Max Kleiner
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
WSO2
 
Help Needed!UNIX Shell and History Feature This project consists.pdf
Help Needed!UNIX Shell and History Feature This project consists.pdfHelp Needed!UNIX Shell and History Feature This project consists.pdf
Help Needed!UNIX Shell and History Feature This project consists.pdf
mohdjakirfb
 
21 -windows
21  -windows21  -windows
21 -windows
Hector Garzo
 
©️ One of my PROJECTS for MICROSOFT Retail Logistics - Part B
©️ One of my PROJECTS for MICROSOFT Retail Logistics - Part B©️ One of my PROJECTS for MICROSOFT Retail Logistics - Part B
©️ One of my PROJECTS for MICROSOFT Retail Logistics - Part Bnone
 
MPI
MPIMPI
Implementing New Web
Implementing New WebImplementing New Web
Implementing New Web
Julian Viereck
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIs
Julian Viereck
 
Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)
Lifeparticle
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
Mickaël Rémond
 

Similar to MFC Message Handling (20)

Borland star team to tfs simple migration
Borland star team to tfs simple migrationBorland star team to tfs simple migration
Borland star team to tfs simple migration
 
The ProblemUsing C programming language write a program that simul.pdf
The ProblemUsing C programming language write a program that simul.pdfThe ProblemUsing C programming language write a program that simul.pdf
The ProblemUsing C programming language write a program that simul.pdf
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
 
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksBeginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeks
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
Lab 2
Lab 2Lab 2
Lab 2
 
T-121-5300 (2008) User Interface Design 10 - UIML
T-121-5300 (2008) User Interface Design 10 - UIMLT-121-5300 (2008) User Interface Design 10 - UIML
T-121-5300 (2008) User Interface Design 10 - UIML
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
 
Help Needed!UNIX Shell and History Feature This project consists.pdf
Help Needed!UNIX Shell and History Feature This project consists.pdfHelp Needed!UNIX Shell and History Feature This project consists.pdf
Help Needed!UNIX Shell and History Feature This project consists.pdf
 
21 -windows
21  -windows21  -windows
21 -windows
 
©️ One of my PROJECTS for MICROSOFT Retail Logistics - Part B
©️ One of my PROJECTS for MICROSOFT Retail Logistics - Part B©️ One of my PROJECTS for MICROSOFT Retail Logistics - Part B
©️ One of my PROJECTS for MICROSOFT Retail Logistics - Part B
 
MPI
MPIMPI
MPI
 
Implementing New Web
Implementing New WebImplementing New Web
Implementing New Web
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIs
 
Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 

Recently uploaded

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 

Recently uploaded (20)

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 

MFC Message Handling

  • 1. MFC(Microsoft Foundation Class Library) Message Handling Janani A 10 Oct 2011
  • 2. Agenda • Win32 application • MFC • Macros • Message mapping
  • 5. MFC - Overview • An "application framework" for programming in Microsoft Windows. • It's easy to extend or override the basic functionality that MFC provides. • Object Linking and Embedding (OLE), Data Access Objects (DAO) and Open Database Connectivity (ODBC) etc
  • 6. Execution begins here… int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { ASSERT(hPrevInstance == NULL); int nReturnCode = -1; CWinApp* pApp = AfxGetApp(); // AFX internal initialization if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) goto InitFailure; // App global initializations (rare) ASSERT_VALID(pApp); if (pApp != NULL && !pApp->InitApplication()) goto InitFailure; ASSERT_VALID(pApp); // Perform specific initializations if (!pApp->InitInstance()) { if (pApp->m_pMainWnd != NULL) { TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWndn"); pApp->m_pMainWnd->DestroyWindow(); } nReturnCode = pApp->ExitInstance(); goto InitFailure; } ASSERT_VALID(pApp); nReturnCode = pApp->Run(); ASSERT_VALID(pApp); InitFailure: AfxWinTerm(); return nReturnCode; }
  • 7. The Windows program using MFC class MyApp : public CWinApp { public: virtual BOOL InitInstance(); }; class MyWnd : public CFrameWnd { public: MyWnd() { Create (NULL, "My Application"); } afx_msg void OnLButtonDown(UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(MyWnd, CFrameWnd) ON_WM_LBUTTONDOWN() END_MESSAGE_MAP() void MyWnd:: OnLButtonDown(UINT nFlags, CPoint point) { MessageBox(TEXT("Left mouse button pressed..."),NULL,MB_OK); } BOOL MyApp:: InitInstance() { m_pMainWnd = new MyWnd(); m_pMainWnd -> ShowWindow(m_nCmdShow); m_pMainWnd -> UpdateWindow(); return TRUE; } MyApp intApp;
  • 8. Macros //DECLARE_MESSAGE_MAP() #define DECLARE_MESSAGE_MAP() private : static const AFX_MSGMAP_ENTRY _messageEntries[]; protected: static const AFX_MSGMAP messageMap; virtual const AFX_MSGMAP* GetMessageMap() const; //BEGIN_MESSAGE_MAP() #define BEGIN_MESSAGE_MAP(theClass, baseClass) const AFX_MSGMAP* theClass::GetMessageMap() const { return &theClass::messageMap; } AFX_DATADEF const AFX_MSGMAP theClass::messageMap = { &baseClass::messageMap, &theClass::_messageEntries[0] }; const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = { #define END_MESSAGE_MAP() {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } }; #define ON_WM_LBUTTONDOWN() { WM_LBUTTONDOWN, 0, 0, 0, AfxSig_vwp, (AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(UINT, CPoint))&OnLButtonDown },
  • 9. After Pre-processing class MyApp : public CWinApp { public: virtual BOOL InitInstance(); }; class MyWnd : public CFrameWnd { public: MyWnd() { Create (NULL, "My Application"); } afx_msg void snFlags, CPoint point); private : static const AFX_MSGMAP_ENTRY _messageEntries[]; protected: static const AFX_MSGMAP messageMap; virtual const AFX_MSGMAP* GetMessageMap() const; }; const AFX_MSGMAP* MyWnd::GetMessageMap() const { return & MyWnd::messageMap; } AFX_DATADEF const AFX_MSGMAP MyWnd::messageMap = { &CFrameWnd::messageMap, & MyWnd::_messageEntries[0] }; const AFX_MSGMAP_ENTRY MyWnd::_messageEntries[] = { { WM_LBUTTONDOWN, 0, 0, 0, AfxSig_vwp, (AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(UINT, CPoint))&OnLButtonDown }, {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } }; void MyWnd:: OnLButtonDown(UINT nFlags, CPoint point) { MessageBox(TEXT("Left mouse button pressed..."), NULL,MB_OK); } BOOL MyApp:: InitInstance() { m_pMainWnd = new MyWnd(); m_pMainWnd -> ShowWindow(m_nCmdShow); m_pMainWnd -> UpdateWindow(); return TRUE; } MyApp intApp;
  • 11. Message Handling • The CCmdTarget class: Base class for CFrameWnd, CView, CWinApp, CDocument, CWnd with functions/ handlers for polymorphism. Override base functions for custom behavior. • Message Maps: Map the message codes to handlers (CCmdTarget). Declare with DECLARE_MESSAGE_MAP
  • 12. References • http://msdn.microsoft.com/en-us/library/d06h2x6e(v=vs.80).aspx • http://www.functionx.com/visualc/ • MFC Internals- Inside The Microsoft Foundation Class, George Shepherd and Scot Wingo • http://home.arcor.de/it- solution/cpp/books/Professional%20MFC/CH03_7.HTM • afxmsg_.h