Setting modeless dialog focus - Programmer

This is a discussion on Setting modeless dialog focus - Programmer ; Hi Everyone, I have a modeless dialog box in my app and I am very keen to stop the user from opening more than one of them. Instead of disabling the menu item, I would like to have the code ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Setting modeless dialog focus

  1. Setting modeless dialog focus

    Hi Everyone,

    I have a modeless dialog box in my app and I am very keen to stop the
    user from opening more than one of them. Instead of disabling the
    menu item, I would like to have the code set the focus to the dialog
    if its already open and the user tries to open it twice.

    I have created my dialog according to Knowledge Base Article 103788
    which consists of overriding CDialog::Create() and using a menu event
    along the lines of:

    void CMainFrame::OnModeless() {
    my_dialog = new CModeless;
    my_dialog->Create(IDD_DIALOGMODELESS,this);
    my_dialog->ShowWindow(SW_SHOW):
    }

    where my_dialog is:

    CModeless* my_dialog;

    What I was thinking was I could check my_dialog in OnModeless to see
    if it contains a valid value - if its initialised to zero in the
    constructor, then all I need to is check if its zero and if its not
    then the dialog has already been created. This will work - but should
    I be using some MFC function instead?

  2. Re: Setting modeless dialog focus

    Rodney B. Elliott wrote:
    > What I was thinking was I could check my_dialog in OnModeless to see
    > if it contains a valid value - if its initialised to zero in the
    > constructor, then all I need to is check if its zero and if its not
    > then the dialog has already been created. This will work - but should
    > I be using some MFC function instead?


    No MFC function is needed, your concept is just fine.

    --
    Scott McPhillips [VC++ MVP]


+ Reply to Thread