Click here to Skip to main content
Licence 
First Posted 9 Nov 2000
Views 227,116
Bookmarked 34 times

Create a modeless dialog box as child window

By Thomas Blenkers | 9 Nov 2000
Simple step by step article explaining how to create a modeless dialog box as child window.
1 vote, 11.1%
1
1 vote, 11.1%
2
1 vote, 11.1%
3

4
6 votes, 66.7%
5
3.68/5 - 19 votes
μ 3.68, σa 2.77 [?]

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->
    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

    About the Author

    Thomas Blenkers

    Web Developer

    Germany Germany

    Member
    PhD Chemist,
    programming with MSVC & MFC since 1996

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    QuestionModeless Dialog boxes Pinmemberksrikant8320:42 2 Jul '08  
    AnswerRe: Modeless Dialog boxes PinmemberPandele Florin4:01 18 Jan '11  
    Questionare you suppose to be able to type data in text box?? Pinmemberdoctorrie9:30 23 May '05  
    AnswerRe: are you suppose to be able to type data in text box?? Pinmembercristitomi5:32 22 Mar '07  
    GeneralControls on child dialog are not enabled - Solution! PinmemberStephen_Hosking17:15 29 Mar '05  
    GeneralIf this doesn't work for you... PinmemberSteve (Stephen Hosking)17:24 29 Mar '05  
    Generaldialog style as Child but always disabled Pinsusswondermind13:20 13 Oct '04  

    I've created a dialog box intended it to be a part of my main window so i set its style to Child. But once the program is running all the buttons on my dialog is disabled. It is as if the dialog box is always inactivated. I don't know how to fix this.. help =(! Or is there another way that I can attach my dialog box to my main window without having it as a child window?
    GeneralSee "Solution", 30 March 2005. nt PinmemberSteve (Stephen Hosking)17:19 29 Mar '05  
    GeneralRe: dialog style as Child but always disabled Pinmembercristitomi5:33 22 Mar '07  
    GeneralModeless dialoge Pinmembersohcher@harandiha.com11:20 26 Feb '04  
    Generalusing database Pinmembervishalbhatara0:49 5 May '03  
    QuestionHow 2 call a dialog using a button PinmemberBiswakalyan0:05 17 Jun '02  
    AnswerRe: How 2 call a dialog using a button PinsussAnonymous6:07 2 Nov '02  
    Generalfront window Pinmembertammari22:20 8 May '02  
    GeneralRe: front window Pinmemberwalker0:19 13 May '02  
    GeneralRe: front window PinmemberDarkCloud1412:39 9 Dec '03  
    GeneralDetected memory leaks!! PinmemberAnonymous23:11 8 Apr '02  
    GeneralJumping between several dialogs PinmemberMIG2913:57 29 Jul '01  
    GeneralHEELLLPPPPP PinmemberAnonymous10:14 10 Jul '01  
    GeneralRe: HEELLLPPPPP PinmemberAnonymous10:44 10 Jul '01  
    GeneralHELP!! SAME PROBLEM HERE TOO Pinsusswondermind10:32 13 Oct '04  
    GeneralIf I set the dialog style to Child, it is not enabled PinmemberDavid Fleming23:15 14 Jun '01  
    GeneralRe: If I set the dialog style to Child, it is not enabled PinmemberNice Özgürce13:09 18 Jan '05  
    GeneralOnModeless PinmemberJulien12:35 4 Jan '01  
    GeneralRe: OnModeless PinmemberJulien12:46 4 Jan '01  

    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.

    Permalink | Advertise | Privacy | Mobile
    Web01 | 2.5.120210.1 | Last Updated 10 Nov 2000
    Article Copyright 2000 by Thomas Blenkers
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid