Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

This problem is little bit weird or may be genuine but i don't know the solution.
I am using MFC and I just created a sample project in which three dialog created

1. DLG_MAIN
2. DLG_DADDY (class included/implemented CDaddy)
3. DLG_SON (class included/implemented CSon)

In DLG_MAIN one button added say CALL_BTN_DADDY
In DLG_DADDY one button added say CALL_BTN_SON

Now in Code and execution steps
Note: Parent has been Passed accordingly to class.
1. When user click on CALL_BTN_DADDY button DLG_DADDY will popup.
2. Now in DLG_DADDY if user click CALL_BTN_SON then DLG_SON will appear.
3. In CSon::OnintDialog() please write AfxMessageBox(_T("hi"))

Result
Note: MessageBox is working fine so my requirment is to use only AfxmessageBox
1. Message will appear before dialog popup. Well it is my requirement too.
2. After clicking OK the DLG_SON become MODELLESS. i mean i can close DLG_DADDY with out closing DLG_SON.


what i googled got only to use messagebox instead of afxmessagebox. But that is not my requrment.

Do you have the solution or suggestion.

thanks in advance
Posted

Stick a breakpoint on your AfxMessageBox call and trace the code through. You'll see it does loads of things before getting down to the nitty-gritty of calling MessageBox - including setting the HWND used in the MessageBox call to the current window so it can re-enable that window when the AfxMessageBox call finishes.

So as you don't want this behaviour you've got a bunch of choices:

- reimplement that bit of MFC. Ouch.
- maul the state of the MFC application object so you can call AfxMessageBox without the side effects then put everything back in place afterwards. Not so ouch but still painful.
- use MessageBox with NULL for HWND and sidestep the whole sorry issue.
 
Share this answer
 
You could also post a WM_USER message for the son-dialog in its OnInitDialog(),
as its reaction for the message would open the message box :)
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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