Post reply

The message has the following error or errors that must be corrected before continuing:
Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

Name:
Email:
Subject:
Message icon:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview

Topic Summary

Posted by sukishan
 - Jul 12, 2009, 11:08 PM
Command Messages

Definition

One of the main features of a graphical application is to present Windows controls and resources that allow the user to interact with the machine. Examples of controls that we will learn are buttons, list boxes, combo boxes, etc. One type of resource we introduced in the previous lesson is the menu. Such controls and resources can initiate their own messages when the user clicks them. A message that emanates from a Windows control or a resource is called a command message.

Creating a Command Message.
You can start by declaring a framework method. Here is an example:

afx_msg void OnLetItGo();Then you can define the method as you see fit:

void CMainFrame::OnLetItGo()
{
    // Something to do here
}
The framework allows you to associate a member function to a command message. This is done using the ON_COMMAND macro. Its syntax:

ON_COMMAND(IDentifier, MethodName);The first argument, IDentifier, of this macro must be the identifier of the menu item or Windows control you want to associate with a method. The second argument, MethodName, must be the name of the member function that will implement the action of the menu item or Windows control such as a button. Imagine you have a menu item Identified as ID_ACTION_LETITGO that you want to associate with the above OnLetItGo() method. You can use the ON_COMMAND macro as follows:

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
    ON_COMMAND(ID_ACTION_LETITGO, OnLetItGo)
END_MESSAGE_MAP()In the same way, you can create as many command messages as necessary.
IT Acumens Web Designing Chennai | GinGly :: Build your Personal Website | CineBuzz :: Cinema News | My Kids Diary :: Gift your Kids Memories :: Book Website @ 349 Rs monthly
Copyright 2005 - 2021 :: IT Acumens :: All Rights Reserved. :: XML Sitemap
ITAcumens Discussion Forum with 2 lakhs post running for 15 years - Powered by IT Acumens Pro Dedicated Server

My Kids Diary