From: Woody on 4 May 2010 13:16 MFC dialog A invokes dialog B, and dialog B creates modeless dialog M. When the focus is in M and user types Enter, I want the dialog M to be destroyed and dialog B exited, as if user had typed Enter while focus was in B. I'm catching Enter in M (by overriding OnOK), and executing OnOK in the parent, B. This closes B, but does not redraw A. How can I accomplish the effect I am looking for?
From: Joseph M. Newcomer on 4 May 2010 14:47 For a modeless dialoog, you must override OnOk and OnCancel to call DestroyWindow and NOT call the superclass OnOK and OnCancel handlers. This is important, because if you do, or you fail to override them, you will get serious malfunctions. Note that if you fail to override OnCancel, hitting <ESC> will cause problems. If you don;t want <ESC> to do anything, have an empty body for OnCancel. PostMessage a WM_COMMAND:IDOK message to the dialog you want closed. You should transfer a pointer to the desired dialog in a variable of the modeless dialog; don't use GetParent() because it will give you the wrong pointer for a modeless dialog. joe On Tue, 4 May 2010 10:16:15 -0700 (PDT), Woody <ols6000(a)sbcglobal.net> wrote: >MFC dialog A invokes dialog B, and dialog B creates modeless dialog M. >When the focus is in M and user types Enter, I want the dialog M to be >destroyed and dialog B exited, as if user had typed Enter while focus >was in B. > >I'm catching Enter in M (by overriding OnOK), and executing OnOK in >the parent, B. This closes B, but does not redraw A. > >How can I accomplish the effect I am looking for? Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Woody on 4 May 2010 15:59 On May 4, 11:47 am, Joseph M. Newcomer <newco...(a)flounder.com> wrote: > For a modeless dialoog, you must override OnOk and OnCancel to call DestroyWindow I had not called DestroyWindow, but I have now added that. > Note that if you fail to override OnCancel, hitting <ESC> will cause problems. If you > don;t want <ESC> to do anything, have an empty body for OnCancel. Since I have gotten burned by this one before, I did remember to do that. > PostMessage a WM_COMMAND:IDOK message to the dialog you want closed. This seems to work fine. Tnx for the prompt reply.
|
Pages: 1 Prev: MFC80 and MSVCR80 file versions Next: Microsoft ending newsgroup support |