mCtrl  0.11.1
expand.h File Reference

Go to the source code of this file.

Detailed Description

Expand control (MC_WC_EXPAND).

The expand control is a utility control used to toggle size of another window between "collapsed" and "expanded" states.

In addition, when collapsing, the control automatically disables and hides all child windows of the managed window which fall out of the visible area; and when expanding it enables and shows all the child windows revealed by the resize operation. Application can disable this behavior with the style MC_EXS_IGNORECHILDREN.

Window

By default the managed window is a parent window of the control. Use message CCM_SETNOTIFYWINDOW to change what window the control manages.

Note
The root control also gets all the notifications from the control.

and Collapsed Sizes

If both width and height the of the expanded and/or collapsed sizes is zero, the control computes automatically from analyzes of position and size of all child windows of the managed window (usually the parent).

The width of the managed window is kept unchanged in this automatic regime. The height of the managed window is calculated so that all child windows of the managed window are visible (the expanded state) or all child windows positioned below the expand control itself are hidden (the collapsed state).

If you use style MC_EXS_CACHESIZES, the computed sizes are retained for next use, i.e. the sizes are computed only once.

You can set expanded and collapsed sizes explicitly with message MC_EXM_SETCOLLAPSEDSIZE and MC_EXM_SETEXPANDEDSIZE respectively.

State

After creation of the control, its logical state is collapsed. Though the control does not resize the dialog because it may not be already fully initialized, e.g. if the expand control is not last control created in the dialog.

Therefore it is supposed that application explicitly sends the message MC_EXM_EXPAND after the dialog and all its children are created, usually as part of the WM_INITDIALOG handling.

These standard messages are handled by the control:

These standard notifications are sent by the control:

Initialization Functions

BOOL mcExpand_Initialize (void)
 
void mcExpand_Terminate (void)
 

Window Class

#define MC_WC_EXPANDW   L"mCtrl.expand"
 
#define MC_WC_EXPANDA   "mCtrl.expand"
 

Control Styles

#define MC_EXS_CACHESIZES   0x0001
 Cache expanded and collapsed sizes. More...
 
#define MC_EXS_RESIZEENTIREWINDOW   0x0002
 Expanded and collapsed sizes are interpreted for whole window. More...
 
#define MC_EXS_DOUBLEBUFFER   0x0004
 Enable painting with double buffering. More...
 
#define MC_EXS_ANIMATE   0x0008
 Causes the control changes size of parent window using an animation. More...
 
#define MC_EXS_IGNORECHILDREN   0x0010
 Instructs the control to not change state of children of the managed window. More...
 

Flags for MC_EXM_EXPAND and MC_EXM_TOGGLE

#define MC_EXE_NOANIMATE   (1 << 0)
 Perform the expand/collapse without using an animation. More...
 

Control Messages

#define MC_EXM_SETCOLLAPSEDSIZE   (MC_EXM_FIRST + 0)
 Specify size of parent's client area when in collapsed state. More...
 
#define MC_EXM_GETCOLLAPSEDSIZE   (MC_EXM_FIRST + 1)
 Gets size of parent's client area when in collapsed state. More...
 
#define MC_EXM_SETEXPANDEDSIZE   (MC_EXM_FIRST + 2)
 Specify size of parent's client area when in expanded state. More...
 
#define MC_EXM_GETEXPANDEDSIZE   (MC_EXM_FIRST + 3)
 Gets size of parent's client area when in expanded state. More...
 
#define MC_EXM_EXPAND   (MC_EXM_FIRST + 4)
 Sets current state of the control to expanded or collapsed. More...
 
#define MC_EXM_TOGGLE   (MC_EXM_FIRST + 5)
 Toggles current state of the control between expanded and collapsed. More...
 
#define MC_EXM_ISEXPANDED   (MC_EXM_FIRST + 6)
 Gets current state of the control. More...
 

Control Notifications

#define MC_EXN_EXPANDING   (MC_EXN_FIRST + 0)
 Fired when the control begins expansing or collapsing the parent window. More...
 
#define MC_EXN_EXPANDED   (MC_EXN_FIRST + 1)
 Fired after the control has finished resizing of the parent window. More...
 

Unicode Resolution

#define MC_WC_EXPAND   MCTRL_NAME_AW(MC_WC_EXPAND)
 

Macro Definition Documentation

#define MC_WC_EXPANDW   L"mCtrl.expand"

Window class name (Unicode variant).

#define MC_WC_EXPANDA   "mCtrl.expand"

Window class name (ANSI variant).

#define MC_EXS_CACHESIZES   0x0001

Cache expanded and collapsed sizes.

When in the automatic mode, this style allows the control to store expanded and/or collapsed sizes instead of recomputing it each time its state changes.

#define MC_EXS_RESIZEENTIREWINDOW   0x0002

Expanded and collapsed sizes are interpreted for whole window.

If this style is not set, they determine client size only.

#define MC_EXS_DOUBLEBUFFER   0x0004

Enable painting with double buffering.

It prevents flickering when the control is being continuously resized.

#define MC_EXS_ANIMATE   0x0008

Causes the control changes size of parent window using an animation.

Using this style causes the control will send series of WM_SIZE messages to the parent window in a period of the animation time, gradually changing its size to the desired values.

Application has to take this into account as if there are other means which change the window size, they can interfere.

#define MC_EXS_IGNORECHILDREN   0x0010

Instructs the control to not change state of children of the managed window.

When not set, it may show/hide and enable/disable child windows of the managed window, whenever they are (un)covered by the managed window resizing.

However that might interfere with application's logic about enabling/disabling the controls.

If you use this style, application should make disable the children manually in the response to control notification MC_EXN_EXPANDING or MC_EXN_EXPANDED.

#define MC_EXE_NOANIMATE   (1 << 0)

Perform the expand/collapse without using an animation.

#define MC_EXM_SETCOLLAPSEDSIZE   (MC_EXM_FIRST + 0)

Specify size of parent's client area when in collapsed state.

If you set both width and height to zero, then the size is computed automatically from position of all controls in the dialog.

Parameters
wParamReserved, set to zero.
[in]lParam(DWORD) The size. Low-order word specifies width and high-order word specifies height.
Returns
(DWORD) The original size.
#define MC_EXM_GETCOLLAPSEDSIZE   (MC_EXM_FIRST + 1)

Gets size of parent's client area when in collapsed state.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(DWORD) The size. Low-order word specifies width and high-order word specifies height.
#define MC_EXM_SETEXPANDEDSIZE   (MC_EXM_FIRST + 2)

Specify size of parent's client area when in expanded state.

If you set both width and height to zero, then the size is computed automatically from position of all controls in the dialog.

Parameters
wParamReserved, set to zero.
[in]lParam(DWORD) The size. Low-order word specifies width and high-order word specifies height.
Returns
(DWORD) The original size.
#define MC_EXM_GETEXPANDEDSIZE   (MC_EXM_FIRST + 3)

Gets size of parent's client area when in expanded state.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(DWORD) The size. Low-order word specifies width and high-order word specifies height.
#define MC_EXM_EXPAND   (MC_EXM_FIRST + 4)

Sets current state of the control to expanded or collapsed.

Parameters
[in]wParam(BOOL) Set to TRUE to expand, FALSE to collapse.
[in]lParam(DWORD) Flags. See MC_EXE_xxxx.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_EXM_TOGGLE   (MC_EXM_FIRST + 5)

Toggles current state of the control between expanded and collapsed.

Parameters
wParamReserved, set to zero.
[in]lParam(DWORD) Flags. See MC_EXE_xxxx.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_EXM_ISEXPANDED   (MC_EXM_FIRST + 6)

Gets current state of the control.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(BOOL) TRUE if expanded, FALSE if collapsed.
#define MC_EXN_EXPANDING   (MC_EXN_FIRST + 0)

Fired when the control begins expansing or collapsing the parent window.

When application receives the message, the control is logically already in the desired style, so it can ask about it using MC_EXM_ISEXPANDED.

However the size of the parent window may be different from the desired state if the control animates it, as that takes some time. When the parent resizing is also finished, the application will receive notification MC_EXN_EXPANDED.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(NMHDR*)
Returns
Application should return zero if it processes the notification.
#define MC_EXN_EXPANDED   (MC_EXN_FIRST + 1)

Fired after the control has finished resizing of the parent window.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(NMHDR*)
Returns
Application should return zero if it processes the notification.
#define MC_WC_EXPAND   MCTRL_NAME_AW(MC_WC_EXPAND)

Unicode-resolution alias.

See also
MC_WC_EXPANDW MC_WC_EXPANDA

Function Documentation

BOOL mcExpand_Initialize ( void  )

Registers window class of the control.

Returns
TRUE on success, FALSE on failure.
void mcExpand_Terminate ( void  )

Unregisters window class of the control.