Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

messagemapping cbutton

Status
Not open for further replies.

Horrid

Programmer
May 20, 1999
373
I have a class for a token object, when a token object is created it draws information about the token on the screen along with a button. Is it possible to set a message map for this button so it works? Every example I can find assumes I created the cbutton object in my dialog class, I can't find any examples of how to deal with a button that is a member of class.


The very basics are

.h

#define Button_Id someId
class cTokenObject{
public:
cTokenObject(int TokenId);
protected:
afx_msg void OnButtonInterface( );
DECLARE_MESSAGE_MAP()
private:
CButton* cButton

}


.cpp

cTokenObject::cTokenObject(int TokenId){
cButton = new CButton;
cButton->Create(buttoncreationcode, someId);
}

// I think this part is very wrong
BEGIN_MESSAGE_MAP(cTokenObject, cTokenObject)
ON_BN_CLICKED(someId, OnButtonInterface)
END_MESSAGE_MAP()

void cTokenObject::OnButtonInterface(){
// whatever my code here is
}
Is it possible to do this? Am I even half way on the correct track. Not looking for how to do it, just if I can and if I am on the correct track.
 
Subclass the button: then you can route it to your own window proc to do whatever you want.
 
very cool, thanks for the help.
 
in your case is recommended not subclassing but adding a handler for WM_COMMAND

Ion Filipski
1c.bmp
 
Thinks Ion, I'll take a look into that. Very much trying to cram too much information into my head in a short amount of time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top