Event Handler -Please help me
-
I have created a IP address control dynamically. How to add a event handler for those controls. How to use event handlers with dynamically created control.
Generally, three things to be done; *) decide which exact command to handle *) prepare the handler function [whose prtototype is influenced by the cammand to be handled] *) map the command to the handler As for ip control, I guess you are trying to handle the IPN_FIELDCHANGED notifycation. So you would have a handler like this;
void CMyDialog::OnFieldChangedIpAddress(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMIPADDRESS pIPAddr = reinterpret_cast(pNMHDR);
// your code here ...
*pResult = 0;
}And map it to the notifycation inside BEGIN_MESSAGE_MAP/END_MESSAGE_MAP pair like so;
ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress)
-- ===== Arman
-
Generally, three things to be done; *) decide which exact command to handle *) prepare the handler function [whose prtototype is influenced by the cammand to be handled] *) map the command to the handler As for ip control, I guess you are trying to handle the IPN_FIELDCHANGED notifycation. So you would have a handler like this;
void CMyDialog::OnFieldChangedIpAddress(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMIPADDRESS pIPAddr = reinterpret_cast(pNMHDR);
// your code here ...
*pResult = 0;
}And map it to the notifycation inside BEGIN_MESSAGE_MAP/END_MESSAGE_MAP pair like so;
ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress)
-- ===== Arman
-
ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress) I cant use the control id directly because i created control dynamically. How to add On_notify for dynamically created one
You can and hou have to. The last parameter of CIPAddressCtrl::Create takes the id of the newly creating control. So define an id inside resource.h file and pass it to the Create method. PS. To define an id, go to menu option Edit\Resource Synbols... and then choose New... .
-- ===== Arman
-
ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress) I cant use the control id directly because i created control dynamically. How to add On_notify for dynamically created one
prathuraj wrote:
I cant use the control id
How do you make IP address control ?
CIPAddressCtrl::Create(....,UINT nID);
orCIPAddressCtrl::CreateEx(...,UINT nID);
WhiteSky
-
You can and hou have to. The last parameter of CIPAddressCtrl::Create takes the id of the newly creating control. So define an id inside resource.h file and pass it to the Create method. PS. To define an id, go to menu option Edit\Resource Synbols... and then choose New... .
-- ===== Arman
-
prathuraj wrote:
I cant use the control id
How do you make IP address control ?
CIPAddressCtrl::Create(....,UINT nID);
orCIPAddressCtrl::CreateEx(...,UINT nID);
WhiteSky
-
You used of nID whats problem?
WhiteSky
-
You used of nID whats problem?
WhiteSky