Sizable dialogs at its easiest

Introduction:

Q: What is the difference between the following two dialogs ?

 small dialogbig dialog

A: There is no difference !

The cdxCSizingDialog class is a class derived from CDialog making it very easy to implement sizable dialogs. I really missed that feature in VC++ (and IMHO it's a shame to the MFC that it doesn't provide an easy to use way to solve this problem).
However, now it is possible to make your dialogs sizable - you can add this to an existing dialog in three steps !

In addition to cdxCSizingDialog, you will even find both cdxCSizingPropSheet and cdxCSizingPropPage in the two files that are part of the zip, but these are considered to be in beta stadium for now (they seem to work ... I only have problems with the sizing icon).

The most important features of cdxCSizingDialog are:

  • Easy to add even to already existing dialog classes.
  • Several ways controls may react on window size changes, from a simple nothing to a percentage-value;
  • Automatic creation of a standard-windows sizing icon (as used by the explorer's windows) in the lower right corner of your dialog.
  • Support to load/store window position to the registry.

Requirements:

  • Tested and used with Visual C++ 5.0.

Files:

  • cdxCSizingDialog.h (header; can be found in the archive)
  • cdxCSizingDialog.cpp (implementation; can be found in the archive)
  • Sample application (includes a documentation; see sub-directory "doc" in the archive)

How to use:

    Make your dialog sizable in 3 steps !!

  1. Every control on our dialog needs a DDX value of class control (use Class Wizard in the resource editor).
  2. In both the header and implementation file, replace all strings "CDialog" by "cdxCSizingDialog" and insert an #include "cdxCSizingDialog.h" to your header file.
  3. In OnInitDialog(), make a call to AddSzControl() for each control you want to resize/reposition if the dialog's size changes.
  4. Additional features might be used... see the documentation.

    A simple tutorial is included in the documentation that might be found here



Comments

  • hum....

    Posted by Legacy on 03/07/2003 12:00am

    Originally posted by: kim jyeong hyeon

    Cannot open include file: 'ResizableDialog.h': No such file or directory....

    downloaded file doesn't have a header file(ResizableDialog.h)....

    ....

    Reply
  • Problems with OCX

    Posted by Legacy on 07/17/2002 12:00am

    Originally posted by: Olaf Oelsner

    I tried to use an OCX the dialog, but
    it won't be resized.

    Does anybody have an idea ?

    Thanks

    Reply
  • GREAT WORK!

    Posted by Legacy on 10/19/2001 12:00am

    Originally posted by: abscess

    You just saved me (estimating) days of frustrated coding this month alone!

    Reply
  • latest version is HERE

    Posted by Legacy on 08/13/2000 12:00am

    Originally posted by: oeschtle

    hi there,

    i contacted the author. he told me the latest version is over there:
    http://www.datamekanix.com/

    look for the article 'dynamic child window positioning'.

    it includes DYNAMIC:
    - Dialog
    - ChildDlg
    - FormView
    - PropSheet
    - PropPage

    a couple of changes and improvements.

    enjoy,

    oeschtle

    Reply
  • Problems with MoveWindow

    Posted by Legacy on 04/12/2000 12:00am

    Originally posted by: Takki

    This class is good, but still has some bugs...
    A very cruel bug is that whenever I try to move one of my controls with MoveWindow I get an error (assertion failed). I tried the MoveWindow at several positions (OnInitDialog, OnSize etc.), but it's always the same. I looked into the MFC code and saw that my controls aren't valid hwnds (::IsWindow(m_hWnd) fails). I tried to contact the author, but both emails aren't working. Has anyone a solution for this problem?

    Reply
  • Problems with MoveWindow

    Posted by Legacy on 04/12/2000 12:00am

    Originally posted by: Takki

    This class is good, but still has some bugs...
    A very cruel bug is that whenever I try to move one of my controls with MoveWindow I get an error (assertion failed). I tried the MoveWindow at several positions (OnInitDialog, OnSize etc.), but it's always the same. I looked into the MFC code and saw that my controls aren't valid hwnds (::IsWindow(m_hWnd) fails). I tried to contact the author, but both emails aren't working. Has anyone a solution for this problem?

    Reply
  • RE: You don't need DDX control - just NOT in this case

    Posted by Legacy on 02/15/2000 12:00am

    Originally posted by: Dmitry Zemskov

    The MFC documentation on CWnd::GetDlgItem() states that
    
    "The returned pointer may be temporary and should not be
    stored for later use". Because AddSzControl() stores
    reference to CWnd obtained from GetDlgItem() for later use,
    the CWnd object must exist as long as cdxCSizingDialog
    object does. That means we can not use CWnd::GetDlgItem()
    method in this case.

    Reply
  • Problems with Splitter in a Sizable Dialog

    Posted by Legacy on 10/04/1999 12:00am

    Originally posted by: Joern Engmann

    If someone have to put two (or more) elements, separated by a Splitter (like in the Explorer) in a sizable Dialog he will get some Problems.
    When I does this the Dialog was much bigger at starting Time as I wanted and the Splitterelement was overridden by Element on it's left side. When I make the left Element mdNone in x-direction then all works.
    I need a hint to get the left Side resizable.

    Reply
  • You don't need DDX control

    Posted by Legacy on 07/28/1999 12:00am

    Originally posted by: Scott Coursin

    This is a really great class!
    
    

    I just wanted to point out that there is an alternative to adding control member variables to your dialog class. You can use the GetDlgItem() API call to get a CWnd pointer to a control. You do have to derefcerence the pointer in the call to AddSzControl() since it is expecting a reference, not a pointer.

    [ccode]
    CWnd* pWnd = GetDlgItem(IDC_HEADER);
    AddSzControl(*pWnd, mdRelative, mdRelative);
    [\ccode]

    Scott

    Reply
  • Very Cool

    Posted by Legacy on 07/21/1999 12:00am

    Originally posted by: Johnathan James

    I knew I would find something cool on CodeGuru to do this, but I thought I would try on my own first.. after about 2 hours trying to get those controls to resize correctly, I came to CodeGuru and saw this code. Not 10 minutes later, I had the dialog just like I wanted it.

    This code is excellent! Thanks a lot!

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • Webinar on September 23, 2014, 2 p.m. ET / 11 a.m. PT Mobile commerce presents an array of opportunities for any business -- from connecting with your customers through mobile apps to enriching operations with mobile enterprise solutions. Join guest speaker, Michael Facemire, Forrester Research, Inc. Principal Analyst, as he discusses the new demands of mobile engagement and how application program interfaces (APIs) play a crucial role. Check out this upcoming webinar to learn about the new set of …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds