Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using message box in vc++ console application, in that how to know which button i clicked YES or NO?.
Here is the piece of code i am pasting, which i did please check once and anyone can suggest me whats the wrong??

C#
if(MessageBox(HWND_DESKTOP, L"License Failed", L"Get License",  MB_YESNO) == IDYES)
        {
            return;// even i am clicking on YES or NO whatever button am i pressing, its not entering inside this block
        }


As per my requirement if i press YES I need to enter inside.
Please guide me, whats wrong.

Note: i checked the same thing by replacing HWND_DESKTOP with NULL, still not working.
Posted
Comments
CPallini 5-Aug-14 9:01am    
Your code works fine on my system (MessageBox returns 6 on button 'Yes' click).
Satya Chamakuri 6-Aug-14 0:14am    
thank you for your reply,
Yes in my system also its returning 6 only. but not entering the block at all. I am using console application in Visual C++ 12.
enhzflep 5-Aug-14 9:42am    
return isn't the first statement inside that block is it? (return will exit the function immediately)
Satya Chamakuri 6-Aug-14 0:16am    
No, return is not a first statement, but its not at all entering the block even its success also, don't know why.
Thank you
enhzflep 6-Aug-14 1:16am    
Glad to see you resolved your problem. :)

what does it return:
int rc = MessageBox(HWND_DESKTOP, L"License Failed", L"Get License",  MB_YESNO);

Have you redefined MB_YESNO, IDYES or is MessageBox user func in your scope? (Don't do it!!!)
Read the MessageBox documentation.

Write what was wrong.
 
Share this answer
 
Comments
Satya Chamakuri 6-Aug-14 0:18am    
no , i have not redefined anything.
KarstenK 6-Aug-14 3:35am    
what is the return code of the MessageBox() ???
Satya Chamakuri 6-Aug-14 4:16am    
6
I got it whats the wrong i made.

actually i am returning from the block in which i am using the MessageBox, not from the the main application. So i added that MessageBox verification in main application instead in sub function.

Thank you all for your suggestions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900