Click here to Skip to main content
11,436,179 members (62,999 online)
Click here to Skip to main content

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);
      
          m_pModeless->ShowWindow(SW_SHOW); 
      }
    In the destructor of the parent window, proof if the dialog has been closed and release the memory:
    CInterfaceView::~CInterfaceView()
    {
        <FONT color=#000080>if</FONT> (m_pModeless)
        {
            <FONT color=#000080>if </FONT>(::IsWindow(m_pModeless->GetSafeHwnd()))
                m_pModeless->EndDialog(IDCANCEL);
            <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

    Share

    About the Author

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

    Comments and Discussions

     
    QuestionModeless Dialog boxes Pin
    ksrikant832-Jul-08 20:42
    memberksrikant832-Jul-08 20:42 
    AnswerRe: Modeless Dialog boxes Pin
    Pandele Florin18-Jan-11 4:01
    memberPandele Florin18-Jan-11 4:01 
    Questionare you suppose to be able to type data in text box?? Pin
    doctorrie23-May-05 9:30
    memberdoctorrie23-May-05 9:30 
    AnswerRe: are you suppose to be able to type data in text box?? Pin
    cristitomi22-Mar-07 5:32
    membercristitomi22-Mar-07 5:32 
    GeneralControls on child dialog are not enabled - Solution! Pin
    Stephen_Hosking29-Mar-05 17:15
    memberStephen_Hosking29-Mar-05 17:15 
    GeneralIf this doesn't work for you... Pin
    Steve (Stephen Hosking)29-Mar-05 17:24
    memberSteve (Stephen Hosking)29-Mar-05 17:24 
    Generaldialog style as Child but always disabled Pin
    wondermind13-Oct-04 13:20
    susswondermind13-Oct-04 13:20 
    GeneralSee &quot;Solution&quot;, 30 March 2005. nt Pin
    Steve (Stephen Hosking)29-Mar-05 17:19
    memberSteve (Stephen Hosking)29-Mar-05 17:19 
    GeneralRe: dialog style as Child but always disabled Pin
    cristitomi22-Mar-07 5:33
    membercristitomi22-Mar-07 5:33 
    GeneralModeless dialoge Pin
    sohcher@harandiha.com26-Feb-04 11:20
    membersohcher@harandiha.com26-Feb-04 11:20 
    Generalusing database Pin
    vishalbhatara5-May-03 0:49
    membervishalbhatara5-May-03 0:49 
    QuestionHow 2 call a dialog using a button Pin
    Biswakalyan17-Jun-02 0:05
    memberBiswakalyan17-Jun-02 0:05 
    AnswerRe: How 2 call a dialog using a button Pin
    Anonymous2-Nov-02 6:07
    sussAnonymous2-Nov-02 6:07 
    Generalfront window Pin
    tammari8-May-02 22:20
    membertammari8-May-02 22:20 
    GeneralRe: front window Pin
    walker13-May-02 0:19
    memberwalker13-May-02 0:19 
    GeneralRe: front window Pin
    DarkCloud149-Dec-03 12:39
    memberDarkCloud149-Dec-03 12:39 
    GeneralDetected memory leaks!! Pin
    Anonymous8-Apr-02 23:11
    memberAnonymous8-Apr-02 23:11 
    GeneralJumping between several dialogs Pin
    MIG2929-Jul-01 13:57
    memberMIG2929-Jul-01 13:57 
    GeneralHEELLLPPPPP Pin
    Anonymous10-Jul-01 10:14
    memberAnonymous10-Jul-01 10:14 
    GeneralRe: HEELLLPPPPP Pin
    Anonymous10-Jul-01 10:44
    memberAnonymous10-Jul-01 10:44 
    GeneralHELP!! SAME PROBLEM HERE TOO Pin
    wondermind13-Oct-04 10:32
    susswondermind13-Oct-04 10:32 
    GeneralIf I set the dialog style to Child, it is not enabled Pin
    David Fleming14-Jun-01 23:15
    memberDavid Fleming14-Jun-01 23:15 
    GeneralRe: If I set the dialog style to Child, it is not enabled Pin
    Nice Özgürce18-Jan-05 13:09
    memberNice Özgürce18-Jan-05 13:09 
    GeneralOnModeless Pin
    Julien4-Jan-01 12:35
    memberJulien4-Jan-01 12:35 
    GeneralRe: OnModeless Pin
    Julien4-Jan-01 12:46
    memberJulien4-Jan-01 12:46 
    GeneralEndDialog()?... must be DestroyWindow(). Pin
    gon(junggon Kim)15-Nov-00 21:22
    membergon(junggon Kim)15-Nov-00 21:22 
    GeneralRe: EndDialog()?... must be DestroyWindow(). Pin
    Leo Davidson16-Nov-00 1:47
    memberLeo Davidson16-Nov-00 1:47 
    GeneralRe: EndDialog()?... must be DestroyWindow(). Pin
    gon(Junggon Kim)16-Nov-00 18:19
    membergon(Junggon Kim)16-Nov-00 18:19 
    GeneralRe: EndDialog()?... must be DestroyWindow(). Pin
    I_dont_want_no_stinkin_alias29-May-03 6:01
    memberI_dont_want_no_stinkin_alias29-May-03 6:01 
    Questionm_pDlg? Pin
    Some Guy15-Nov-00 0:12
    memberSome Guy15-Nov-00 0:12 
    AnswerRe: m_pDlg? Pin
    KXRM5-Jun-01 23:30
    memberKXRM5-Jun-01 23:30 
    GeneralRe: m_pDlg? Pin
    Anonymous9-Feb-02 10:43
    memberAnonymous9-Feb-02 10:43 

    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 | Terms of Use | Mobile
    Web03 | 2.8.150428.2 | Last Updated 10 Nov 2000
    Article Copyright 2000 by Thomas Blenkers
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid