Displaying Dialog Box On the Main Window 
Author Message
 Displaying Dialog Box On the Main Window

Hello,

  I am very newbie for MFC environment. I am developing a MFC Based
Application. Application main window is a document/view based MDI
window.
I want to do the following things,

* Currently, when i start the application it shows the Main Window and
Control
  goes to the Main Window. Now i need to show a Login Dialog Box  
(Modal) and
  this should get the inputs from users and validate the input and
then finally
  control should go to the Main Window.

Please provide me your idea's.

Thanks in advance.

Bye,
Subramn



Mon, 15 Aug 2005 15:38:13 GMT  
 Displaying Dialog Box On the Main Window
In the InitInstance of your CWinApp-derived class:

After you have created and shown your main window, but before you exit the
InitInstance you can generate a modal dialog box.  Based on the result of
that dialog you can decide to proceed or terminate the application.  This is
loosely based on one of my programs:

// near the end of CMyApp::InitInstance
// finish mainframe activation
 g_pMainFrame->ActivateFrame();
// temporarily disable the mainframe
 g_pMainFrame->EnableWindow(FALSE);

// run the login dialog
 if (!LoginUser())
 {
  // if login fail, terminate application
  return FALSE;
 }
 else
 {
// otherwise, enable the mainframe
  g_pMainFrame->EnableWindow(TRUE);
  return TRUE;
 }

A simplified LoginUser looks something like this:

bool CMyApp::LoginUser()
{
    // assume login failure
    bool LoggedIn = false;
    // our login dialog
    LoginDlg dlg;

    // run the login dialog
    if (dlg.DoModal() == IDOK)
    {
        LoggedIn = true;
    }

    // return the result
    return LoggedIn;

Quote:
}

HTH,

TFM3

Note: Spam-resistant e-mail address


Quote:
> Hello,

>   I am very newbie for MFC environment. I am developing a MFC Based
> Application. Application main window is a document/view based MDI
> window.
> I want to do the following things,

> * Currently, when i start the application it shows the Main Window and
> Control
>   goes to the Main Window. Now i need to show a Login Dialog Box
> (Modal) and
>   this should get the inputs from users and validate the input and
> then finally
>   control should go to the Main Window.

> Please provide me your idea's.

> Thanks in advance.

> Bye,
> Subramn



Mon, 15 Aug 2005 17:33:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. displaying dialog box with my main window..

2. displaying dialog box with my main window..

3. PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

4. Display a dialog window before the main Window

5. Dialog box as a main window in windows 95, using Win32 SDK only (MSVC 5.00)

6. problem with displaying dialogs from dlls in the main window

7. Dialog Box as Main Window/No debugger /4.0

8. How to describe a new main window forcurrent Dialog Box application

9. Dialog Box integrate into a main View Window

10. main dialog window is blocked by second dialog window

11. Help wanted for windows dialog boxes display

12. Displaying window while a dialog box function operates

 

 
Powered by phpBB® Forum Software