5,442,984 members and growing! (18,600 online)
Email Password   helpLost your password?
Desktop Development » Dialogs and Windows » Dialogs     Intermediate

Create a modeless dialog box as child window

By Thomas Blenkers

Simple step by step article explaining how to create a modeless dialog box as child window.
VC6, C++Windows, NT4, Win2K, MFC, VS6, Visual Studio, Dev

Posted: 9 Nov 2000
Updated: 9 Nov 2000
Views: 170,237
Bookmarked: 23 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
19 votes for this Article.
Popularity: 4.71 Rating: 3.68 out of 5
1 vote, 11.1%
1
1 vote, 11.1%
2
1 vote, 11.1%
3
0 votes, 0.0%
4
6 votes, 66.7%
5

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
      
          if (!m_pModeless)
              m_pModeless = new CDropDialog;
      
          if (!::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()
    {
        if (m_pModeless)
        {
            if (::IsWindow(m_pModeless->GetSafeHwnd()))
                m_pModeless->EndDialog(IDCANCEL);
            delete 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


    PhD Chemist,
    programming with MSVC & MFC since 1996
    Occupation: Web Developer
    Location: Germany Germany

    Other popular Dialogs and Windows articles:

    Article Top
    Sign Up to vote for this article
    You must Sign In to use this message board.
    FAQ FAQ Noise ToleranceSearch Search Messages 
     Layout  Per page   
     Msgs 1 to 25 of 31 (Total in Forum: 31) (Refresh)FirstPrevNext
    Subject  Author Date 
    QuestionModeless Dialog boxesmemberksrikant8320:42 2 Jul '08  
    Generalare you suppose to be able to type data in text box??memberdoctorrie9:30 23 May '05  
    GeneralRe: are you suppose to be able to type data in text box??membercristitomi5:32 22 Mar '07  
    GeneralControls on child dialog are not enabled - Solution!memberStephen_Hosking17:15 29 Mar '05  
    GeneralIf this doesn't work for you...memberSteve (Stephen Hosking)17:24 29 Mar '05  
    Generaldialog style as Child but always disabledsusswondermind13:20 13 Oct '04  
    GeneralSee "Solution", 30 March 2005. ntmemberSteve (Stephen Hosking)17:19 29 Mar '05  
    GeneralRe: dialog style as Child but always disabledmembercristitomi5:33 22 Mar '07  
    GeneralModeless dialogemembersohcher@harandiha.com11:20 26 Feb '04  
    Generalusing databasemembervishalbhatara0:49 5 May '03  
    GeneralHow 2 call a dialog using a buttonmemberBiswakalyan0:05 17 Jun '02  
    GeneralRe: How 2 call a dialog using a buttonsussAnonymous6:07 2 Nov '02  
    Generalfront windowmembertammari22:20 8 May '02  
    GeneralRe: front windowmemberwalker0:19 13 May '02  
    GeneralRe: front windowmemberDarkCloud1412:39 9 Dec '03  
    GeneralDetected memory leaks!!memberAnonymous23:11 8 Apr '02  
    GeneralJumping between several dialogsmemberMIG2913:57 29 Jul '01  
    GeneralHEELLLPPPPPmemberAnonymous10:14 10 Jul '01  
    GeneralRe: HEELLLPPPPPmemberAnonymous10:44 10 Jul '01  
    GeneralHELP!! SAME PROBLEM HERE TOOsusswondermind10:32 13 Oct '04  
    GeneralIf I set the dialog style to Child, it is not enabledmemberDavid Fleming23:15 14 Jun '01  
    GeneralRe: If I set the dialog style to Child, it is not enabledmemberNice Özgürce13:09 18 Jan '05  
    GeneralOnModelessmemberJulien12:35 4 Jan '01  
    GeneralRe: OnModelessmemberJulien12:46 4 Jan '01  
    GeneralEndDialog()?... must be DestroyWindow().membergon(junggon Kim)21:22 15 Nov '00  

    General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    PermaLink | Privacy | Terms of Use
    Last Updated: 9 Nov 2000
    Editor: Chris Maunder
    Copyright 2000 by Thomas Blenkers
    Everything else Copyright © CodeProject, 1999-2008
    Web11 | Advertise on the Code Project