Why Messagebox display twice It's Urgent
-
below is my code.i m using CIPAddressCtrl contorl of vc++(mfc).problem is that we thia case statement is execatuted messagebox is dispaly twice.I wont understand .Plz anyone has idea about this help me to solve my problem.. void CServerIPAddress::OnIpnFieldchangedServerIpaddress(NMHDR *pNMHDR, LRESULT *pResult) { LPNMIPADDRESS pIPAddr = reinterpret_cast<LPNMIPADDRESS>(pNMHDR); *pResult = 0; int nFieldIndex = pIPAddr->iField; int nValue = pIPAddr->iValue; CString csValueFormat; switch(nFieldIndex) { case 0: { if(nValue < 1 || nValue > 223) { csValueFormat.Format(_T("%d Is not a valid entry."),nValue); csValueFormat.Append(_T("Please specify a value between 1 and 223")); AfxMessageBox(csValueFormat); } } break; default:break; } }
-
below is my code.i m using CIPAddressCtrl contorl of vc++(mfc).problem is that we thia case statement is execatuted messagebox is dispaly twice.I wont understand .Plz anyone has idea about this help me to solve my problem.. void CServerIPAddress::OnIpnFieldchangedServerIpaddress(NMHDR *pNMHDR, LRESULT *pResult) { LPNMIPADDRESS pIPAddr = reinterpret_cast<LPNMIPADDRESS>(pNMHDR); *pResult = 0; int nFieldIndex = pIPAddr->iField; int nValue = pIPAddr->iValue; CString csValueFormat; switch(nFieldIndex) { case 0: { if(nValue < 1 || nValue > 223) { csValueFormat.Format(_T("%d Is not a valid entry."),nValue); csValueFormat.Append(_T("Please specify a value between 1 and 223")); AfxMessageBox(csValueFormat); } } break; default:break; } }
jadhavjitendrar wrote:
Why Messagebox display twice It's Urgent
It shows two times because it's urgent. :rolleyes: BTW:
- reposting isn't good.
- urgentz requests go automatically into the recycle bin.
- your code snippet is not properly formatted.
- you may modify you original post, adding more details (for instance is your application multithreaded?).
Please read the forum guidelines [^], before posting. :) [added] 'Mr.Univoter The Coward' beware: "the spiderman is having you for dinner tonight"! :laugh: [/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Wednesday, September 23, 2009 6:36 AM
-
below is my code.i m using CIPAddressCtrl contorl of vc++(mfc).problem is that we thia case statement is execatuted messagebox is dispaly twice.I wont understand .Plz anyone has idea about this help me to solve my problem.. void CServerIPAddress::OnIpnFieldchangedServerIpaddress(NMHDR *pNMHDR, LRESULT *pResult) { LPNMIPADDRESS pIPAddr = reinterpret_cast<LPNMIPADDRESS>(pNMHDR); *pResult = 0; int nFieldIndex = pIPAddr->iField; int nValue = pIPAddr->iValue; CString csValueFormat; switch(nFieldIndex) { case 0: { if(nValue < 1 || nValue > 223) { csValueFormat.Format(_T("%d Is not a valid entry."),nValue); csValueFormat.Append(_T("Please specify a value between 1 and 223")); AfxMessageBox(csValueFormat); } } break; default:break; } }
As Cpallini said, you should have added to your previous message instead of posting a new message. anyway, you didnt answer my earlier query i.e. whether by any chance OnNotify is called twice? I dont know why i feel i had this stupid problem of a piece of code executing twice inside some windows message handler. and the problem in my case was that windows was sending the message to my control as well as to its parent also and parent was forwarding the message to its child. So, in effect, child was receiving the same message twice. You are suggested to put breakpoints at *all possible places* :sigh: and check if your message handler is being called twice. Happy programming.
-
below is my code.i m using CIPAddressCtrl contorl of vc++(mfc).problem is that we thia case statement is execatuted messagebox is dispaly twice.I wont understand .Plz anyone has idea about this help me to solve my problem.. void CServerIPAddress::OnIpnFieldchangedServerIpaddress(NMHDR *pNMHDR, LRESULT *pResult) { LPNMIPADDRESS pIPAddr = reinterpret_cast<LPNMIPADDRESS>(pNMHDR); *pResult = 0; int nFieldIndex = pIPAddr->iField; int nValue = pIPAddr->iValue; CString csValueFormat; switch(nFieldIndex) { case 0: { if(nValue < 1 || nValue > 223) { csValueFormat.Format(_T("%d Is not a valid entry."),nValue); csValueFormat.Append(_T("Please specify a value between 1 and 223")); AfxMessageBox(csValueFormat); } } break; default:break; } }
If you consider that the SysIPAddress32 control is comprised of four Edit controls, those edit controls are sending
EN_CHANGE
andEN_UPDATE
notifications. That may not be an exact answer to your question, but it should give you enough to plow through Spy++ to see exactly what is going on."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons