CIndirectDialogImpl/CMemDlgTemplate - how to set default and default-cancel btns

"domehead100" <[email protected]>
Newsgroups gmane.comp.windows.wtl
Message-ID <[email protected]>
I'm trying to write a MessageBox class that uses CIndirectDialogImpl:

class CMyMessageBox : public CIndirectDialogImpl<CMyMessageBox, CMemDlgTemplate, CDialogImpl<CMyMessagebox>
{
...
}

In the dialog template, I'm placing a rich edit control used for displaying the message with formatting.  That's the extent of the template for now.  In OnInitDialog(), I'm adding buttons based on the standard MessageBox type flags passed in (e.g., MB_OK, MB_YESNO, etc.).  I'm doing this in OnInitDialog by creating the buttons via CButton::Create rather than trying to add them to the template itself.  Then, of course, the dialog is resized to accommodate the formatted message the buttons.

My quandry is how to set the "default" and "cancel" buttons on the dialog?  Since this is a modal dialog, I can't use PreTranslateMessage (just for kicks I tried, and it crashes the test app in the call to _Module.GetMessageLoop()->AddMessageFilter(this)).

If there is a "default" button, I think I could send the dialog a DM_SETDEFID message in OnInitDialog to tell it what the default button is, but I'm not sure if there's any way to set the "cancel" button (that button who's control id is returned if the user presses the Esc key).

The only way I'm coming up with doing this (setting "default" and "cancel" buttons for the dialog) is to build the buttons in the template itself in DoInitTemplate.

I was hoping to avoid this, keep the template simple, and set up everything in OnInitDialog after the dialog has already been created.

Any input is welcome.  Thanks,

~Mike



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.