Click here to Skip to main content
Click here to Skip to main content
Go to top

Create a modeless dialog box as child window

, 9 Nov 2000
Rate this:
Please Sign up or sign in to vote.
Simple step by step article explaining how to create a modeless dialog box as child window.

This article is part of the drag and drop interface samples.

  1. Serializing ASCII Data
  2. Modeless child dialog
  3. Modeless sibling dialog
  4. The drag source
  5. The MFC drop target
  6. The TBTextTarget class

  • Download source files - 44 Kb

    To create the modeless dialog as sibling, follow this link.

    Follow these steps:

    1. Create a new dialog resource and use the Class Wizard for making a new CDialog based class for it; let's call it CDropDialog
    2. In your CFormView-derived class, add a (private) member variable of type CDropDialog* as a container for the modeless dialog class, let's call it m_pModeless. In the constructor of your view, make sure you initialize m_pModeless to NULL
    3. In your appropriate message handler, let's call it OnModeless, do the following:
      void CInterfaceView::OnModeless() 
          // Display the modal dialog box
          <FONT color=#000080>if</FONT> (!m_pModeless)
              m_pModeless = new CDropDialog;
          <FONT color=#000080>if</FONT> (!::IsWindow(m_pModeless->GetSafeHwnd()))
              m_pModeless->Create(IDD_DIALOG1, this);
    In the destructor of the parent window, proof if the dialog has been closed and release the memory:
        <FONT color=#000080>if</FONT> (m_pModeless)
            <FONT color=#000080>if </FONT>(::IsWindow(m_pModeless->GetSafeHwnd()))
            <FONT color=#000080>delete</FONT> m_pModeless;
  • License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Thomas Blenkers
    Web Developer
    Germany Germany
    PhD Chemist,
    programming with MSVC & MFC since 1996

    Comments and Discussions

    QuestionModeless Dialog boxes Pinmemberksrikant832-Jul-08 19:42 
    AnswerRe: Modeless Dialog boxes PinmemberPandele Florin18-Jan-11 3:01 
    Questionare you suppose to be able to type data in text box?? Pinmemberdoctorrie23-May-05 8:30 
    AnswerRe: are you suppose to be able to type data in text box?? Pinmembercristitomi22-Mar-07 4:32 
    GeneralControls on child dialog are not enabled - Solution! PinmemberStephen_Hosking29-Mar-05 16:15 
    GeneralIf this doesn't work for you... PinmemberSteve (Stephen Hosking)29-Mar-05 16:24 
    Generaldialog style as Child but always disabled Pinsusswondermind13-Oct-04 12:20 
    GeneralSee &quot;Solution&quot;, 30 March 2005. nt PinmemberSteve (Stephen Hosking)29-Mar-05 16:19 
    GeneralRe: dialog style as Child but always disabled Pinmembercristitomi22-Mar-07 4:33 
    GeneralModeless dialoge Pinmembersohcher@harandiha.com26-Feb-04 10:20 
    Generalusing database Pinmembervishalbhatara4-May-03 23:49 
    QuestionHow 2 call a dialog using a button PinmemberBiswakalyan16-Jun-02 23:05 
    AnswerRe: How 2 call a dialog using a button PinsussAnonymous2-Nov-02 5:07 
    Generalfront window Pinmembertammari8-May-02 21:20 
    GeneralRe: front window Pinmemberwalker12-May-02 23:19 
    GeneralRe: front window PinmemberDarkCloud149-Dec-03 11:39 
    GeneralDetected memory leaks!! PinmemberAnonymous8-Apr-02 22:11 
    GeneralJumping between several dialogs PinmemberMIG2929-Jul-01 12:57 
    GeneralHEELLLPPPPP PinmemberAnonymous10-Jul-01 9:14 
    GeneralRe: HEELLLPPPPP PinmemberAnonymous10-Jul-01 9:44 
    GeneralHELP!! SAME PROBLEM HERE TOO Pinsusswondermind13-Oct-04 9:32 
    GeneralIf I set the dialog style to Child, it is not enabled PinmemberDavid Fleming14-Jun-01 22:15 
    GeneralRe: If I set the dialog style to Child, it is not enabled PinmemberNice Özgürce18-Jan-05 12:09 
    GeneralOnModeless PinmemberJulien4-Jan-01 11:35 
    GeneralRe: OnModeless PinmemberJulien4-Jan-01 11:46 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Mobile
    Web04 | 2.8.140926.1 | Last Updated 10 Nov 2000
    Article Copyright 2000 by Thomas Blenkers
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid