Click here to Skip to main content
14,768,785 members
Articles » Desktop Development » Dialogs and Windows » General
Posted 22 Feb 2000


97 bookmarked

Dynamic child window positioning

Rate me:
Please Sign up or sign in to vote.
4.97/5 (24 votes)
22 Feb 2000
Describes a method to implement resizable child windows.

This article replaces my former article "Dynamic child window positioning" (cdxCDynamicControlsManager).
See the what's new section to find our whether it's worth changing your code.

What's this article about?

I'll introduce you to some of my code that has will make your windows support automatic repositioning of their child controls. I'll call such windows dynamic (since they don't have a static size and child control ordering but dynamic ones):

cdxCDynamicWnd-small.gif (2466 Byte)=> cdxCDynamicWnd-big.gif (2928 Byte)

What classes are part of this release?

  • cdxCDynamicWnd, cdxCDynamicWndEx
    General base class(es) used to implement dynamic child window repositioning in any CWnd-derived class.

  • cdxCDynamicDialog
    A CDialog replacement that allows you to dynamically move your controls.

  • cdxCDynamicChildDlg
    The same as a dialog base-class for child window dialogs.

  • cdxCDynamicFormView
    A CFormView, now supports the scrollbars, knows its own size perfectly and stuff!

  • cdxCDynamicPropSheet, cdxCDynamicPropPage
    The dynamic CPropertySheet / CPropertyPage replacement.

  • cdxCDynamicBar, cdxCDynamicBarDlg and cdxCDynamicBarT<>
    A controlbar with an embedded dialog that is dynamically moving its childs.
    The bar itself is derived from the CSizingControlBar published at by Cristi Posea.

What's new in contrast to my former cdxCDynamicControlsMananger + associated classes?

  • New and better code :)
    This is why we can not simply replace a cdxCDynamicControlsManager code into a cdxCDynamicWnd code. :(

  • Now works with HWNDs and IDs instead of CWnds.
    Therefore you don't need to explicitely create DDX control variables anymore. *

  • Supports "dynamic maps" - as known from message map macros.
    These maps map IDs to a resizable control. *

  • Now uses ::DeferWindowPos() instead of ::SetWindowPos() to decrease flickering (for all classes). *

  • Anti-Flickering system for cdxCDynamicDialog (looks much better!). *

  • Supports scrolling in CFormView (and any other class, if you enable it by hand). *

  • "Auto-Positioning" feature for dynamic dialogs & property pages. *

  • Support for dialogs that are meant to be "child control dialogs" - if often embedd dialogs and this class helps to make your child controls remain in a suitable place :)

  • A ControlBar solution.

* ~ Suggested by users of my cdxCDynamicControlsManager :)

However, since I rewrote much of the code of the cdxCDynamicControlsManager, you cannot switch from that class to my new cdxCDynamicWnd without further work to be done; converting a cdxCSizingDialog into a cdxCDynamicDialog would need help by you.

A documentation file is included in the sub-directory codex/doc/cdxCDynamicWnd-DOC.html.

Any suggestions & bug-reports are welcome.


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

Hans Bühler
Other JP Morgan Chase
Hong Kong Hong Kong
No Biography provided

Comments and Discussions

QuestionLicense/Permitted Use Pin
TroublesomeQuarry22-Feb-16 13:46
MemberTroublesomeQuarry22-Feb-16 13:46 
AnswerRe: License/Permitted Use Pin
jo.fornefeld22-Jun-16 4:16
Memberjo.fornefeld22-Jun-16 4:16 
GeneralResizeable dialogbar not showing the controls Pin
gbalajimecse16-Apr-10 21:21
Membergbalajimecse16-Apr-10 21:21 
Generalmigrating to VS 2008 Pin
mlchavez2-Feb-10 10:14
Membermlchavez2-Feb-10 10:14 
GeneralRe: migrating to VS 2008 Pin
Hans Bühler3-Feb-10 5:41
MemberHans Bühler3-Feb-10 5:41 
GeneralNits so compiles with warning level 4 Pin
l_d_allan5-Nov-08 8:42
Memberl_d_allan5-Nov-08 8:42 
1. Project file should have "Additional Include Directories" set to ..\codex

2. There are a number of warnings related to "assignment within conditional", including the definition of BEGIN_DYNAMIC_MAP(CLASS,BASECLASS)

It was:
const cdxCDynamicWnd::__dynEntry *CLASS::__getDynMap(const __dynEntry *pLast) const\
{ \
if(pLast == __M_dynEntry) \
return NULL; \
return (pLast = BASECLASS::__getDynMap(pLast)) ? pLast : __M_dynEntry; \
} \
const cdxCDynamicWnd::__dynEntry CLASS::__M_dynEntry[] = {

and to avoid warning, should be:
const cdxCDynamicWnd::__dynEntry *CLASS::__getDynMap(const __dynEntry *pLast) const\
{ \
if(pLast == __M_dynEntry) \
return NULL; \
return (((pLast = BASECLASS::__getDynMap(pLast))) != 0) ? pLast : __M_dynEntry; \
} \
const cdxCDynamicWnd::__dynEntry CLASS::__M_dynEntry[] = {
QuestionFYI small bug? Pin
Jens froslev-nielsen15-May-07 3:36
MemberJens froslev-nielsen15-May-07 3:36 
GeneralProblem with propertysheet multiline TabControl Pin
Dieter Hammer20-Dec-06 0:40
MemberDieter Hammer20-Dec-06 0:40 
QuestionModeless sheet bug? Pin
bioan7-Dec-06 5:31
professionalbioan7-Dec-06 5:31 
QuestionSize problems Pin
mluri23-Nov-06 23:44
Membermluri23-Nov-06 23:44 
Questionhelp me,pls Pin
aiqin20-Oct-06 17:14
Memberaiqin20-Oct-06 17:14 
QuestionRe: help me,pls Pin
aiqin20-Oct-06 17:25
Memberaiqin20-Oct-06 17:25 
GeneralDynamic window Pin
anup_zade11-Jul-05 4:15
Memberanup_zade11-Jul-05 4:15 
GeneralcdxCDynamicFormView in a CSplitterWnd pane Pin
Anonymous24-Feb-05 10:29
MemberAnonymous24-Feb-05 10:29 
GeneralButton of any kind messes up Property Page Pin
tritonesystems14-Jan-05 5:42
Membertritonesystems14-Jan-05 5:42 
GeneralRe: Button of any kind messes up Property Page Pin
tritonesystems17-Jan-05 7:40
Membertritonesystems17-Jan-05 7:40 
GeneralMoving a child window Pin
Arrun6-Jan-05 18:25
MemberArrun6-Jan-05 18:25 
GeneralUrgent!! Problem with win98 Pin
mfc_surfer18-Sep-04 22:15
Membermfc_surfer18-Sep-04 22:15 
GeneralProperty Page Control Resizing Problem Pin
Anonymous18-Jan-04 22:47
MemberAnonymous18-Jan-04 22:47 
GeneralMinimize the dialog window Pin
Jianqi8-Dec-03 10:04
MemberJianqi8-Dec-03 10:04 
GeneralModeless Pin
Chris Losinger28-Nov-03 10:13
professionalChris Losinger28-Nov-03 10:13 
GeneralExcellent - one of the best CP add-ons I've seen Pin
ame1220-Oct-03 3:15
Memberame1220-Oct-03 3:15 
Generalproblem! button was disabled in docked dialog! Pin
youngflea4-Aug-03 23:31
Memberyoungflea4-Aug-03 23:31 
GeneralRe: problem! button was disabled in docked dialog! Pin
Anonymous30-Oct-03 22:46
MemberAnonymous30-Oct-03 22:46 
GeneralRe: problem! button was disabled in docked dialog! Pin
Anonymous30-Oct-03 23:10
MemberAnonymous30-Oct-03 23:10 

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

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