mCtrl  0.11.2
Data Structures
mditab.h File Reference

Go to the source code of this file.

Detailed Description

MDI tab control (MC_WC_MDITAB).

This control is a replacement for standard multiple document interface (MDI), as that interface seems to be outdated, and does not reflect modern GUI requirements.

Instead this control provides user experience similar to the web browsers with tabbing support. Actually the control was designed after the successful user experience provide by modern browsers ("tabbed browsing").

The control is very similar to the standard tab control from COMCTL32.DLL, both visually and from developer's point of view. There two main differences:

Styles, messages and notifications the control supports mostly correspond to subset of messages and styles of the standard tab control. They even usually have the same names (differing only in prefix of the identifiers).

So if you are familiar with the standard tab control, you should be able to adopt MC_WC_MDITAB very quickly. However please note that the messages and styles are not interchangeable: The constants of styles and messages differ in their values.

Migration from MDI

Although the purpose of the control is to provide a replacement for the MDI, the programmatic interfaces substantially differs. If you want to migrate your application from MDI to the MDI tab control, expect it will take some time and even philosophy how the application should manage the opened documents:

Item Callbacks

The control can be told to ask parent instead of remembering some attributes of item.

To use the callbacks, you can set item texts to MC_LPSTR_TEXTCALLBACK, and/or images to MC_I_IMAGECALLBACK.

Whenever the control needs to paint the item, it then sends notification MC_MTN_GETDISPINFO with dwMask specifying what members of it the application has to fill.

MDI Tab Control and Desktop Window Manager

Since Windows Vista, it is possible to extend window frame into window client and in specific cases it can provide much nicer visual effect.

mditab.png

To take use of this feature with the MDI tab control, use the style MC_MTS_EXTENDWINDOWFRAME. When the control has this style (and DWM is available and DWM composition is enabled as of the function DwmIsCompositionEnabled()), the control extends the top level window frame so that the upper border of it reaches as far as the bottom of the MDI tab control.

However note that when using the style, the application should also call function mcMditab_DefWindowProc() from its main window procedure.

Standard Messages

These standard messages are handled by the control:

These standard notifications are sent by the control:

Data Structures

struct  MC_MTITEMW
 Structure for manipulating with the tab item (Unicode variant). More...
 
struct  MC_MTITEMA
 Structure for manipulating with the tab item (ANSI variant). More...
 
struct  MC_MTITEMWIDTH
 Structure for messages MC_MTM_SETITEMWIDTH and MC_MTM_GETITEMWIDTH. More...
 
struct  MC_MTHITTESTINFO
 Structure for message MC_MTM_HITTEST. More...
 
struct  MC_NMMTSELCHANGE
 Structure for notification MC_MTN_SELCHANGE. More...
 
struct  MC_NMMTDELETEITEM
 Structure for notification MC_MTN_DELETEITEM. More...
 
struct  MC_NMMTCLOSEITEM
 Structure for notification MC_MTN_CLOSEITEM. More...
 
struct  MC_NMMTDISPINFOW
 Structure used by notification MC_MTN_GETDISPINFO (Unicode variant). More...
 
struct  MC_NMMTDISPINFOA
 Structure used by notification MC_MTN_GETDISPINFO (ANSI variant). More...
 

Initialization Functions

BOOL mcMditab_Initialize (void)
 
void mcMditab_Terminate (void)
 

Other Functions

BOOL mcMditab_DefWindowProc (HWND hwndMain, HWND hwndMditab, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
 

Window Class

#define MC_WC_MDITABW   L"mCtrl.mditab"
 
#define MC_WC_MDITABA   "mCtrl.mditab"
 

Control Styles

#define MC_MTS_CBONTOOLBAR   0x0000
 Show close button on right side of the control. This is default. More...
 
#define MC_MTS_CBONEACHTAB   0x0001
 Not supported, reserved for future use. More...
 
#define MC_MTS_CBONACTIVETAB   0x0002
 Not supported, reserved for future use. More...
 
#define MC_MTS_CBNONE   0x0003
 Don't show close button. More...
 
#define MC_MTS_CBMASK   0x0003
 This is not valid style, its bit-mask of MC_MTS_CBxxx styles. More...
 
#define MC_MTS_TLBALWAYS   0x0000
 Popup tab list button is shown always. This is default. More...
 
#define MC_MTS_TLBONSCROLL   0x0004
 Popup tab list button is shown if scrolling is triggered on. More...
 
#define MC_MTS_TLBNEVER   0x0008
 Popup tab list button is never displayed. More...
 
#define MC_MTS_TLBMASK   0x000C
 This is not valid style, but bit-mask of MC_NTS_TLBxxx styles. More...
 
#define MC_MTS_SCROLLALWAYS   0x0010
 Always shows scrolling buttons. More...
 
#define MC_MTS_CLOSEONMCLICK   0x0020
 Middle click closes a tab. More...
 
#define MC_MTS_FOCUSONBUTTONDOWN   0x0040
 Mouse button down gains focus. More...
 
#define MC_MTS_FOCUSNEVER   0x0080
 Never gains focus. More...
 
#define MC_MTS_FOCUSMASK   0x00C0
 This is not valid style, but bit-mask of MC_NTS_FOCUSxxx styles. More...
 
#define MC_MTS_DOUBLEBUFFER   0x0100
 Enable painting with double buffering. More...
 
#define MC_MTS_ANIMATE   0x0200
 Allow animation. More...
 
#define MC_MTS_EXTENDWINDOWFRAME   0x0400
 Extend top window frame down to the bottom of the tab control. More...
 
#define MC_MTS_NOTOOLTIPS   0x0800
 Disables a tooltip window. More...
 
#define MC_MTS_DRAGDROP   0x1000
 Allow drag-and-drop reordering of control items. More...
 

MC_MTITEM::dwMask Bits

#define MC_MTIF_TEXT   (1 << 0)
 MC_MTITEMW::pszText or MC_MTITEMA::pszText is valid. More...
 
#define MC_MTIF_IMAGE   (1 << 1)
 MC_MTITEMW::iImage or MC_MTITEMA::iImage is valid. More...
 
#define MC_MTIF_PARAM   (1 << 2)
 MC_MTITEMW::lParam or MC_MTITEMA::lParam is valid. More...
 

MC_MTHITTESTINFO::flags bits

#define MC_MTHT_NOWHERE   (1 << 0)
 The hit test coordinates are outside of any tabs. More...
 
#define MC_MTHT_ONITEMICON   (1 << 1)
 The coordinates hit the tab on its icon. More...
 
#define MC_MTHT_ONITEMLABEL   (1 << 2)
 The coordinates hit the tab, but its icon or close button. More...
 
#define MC_MTHT_ONITEMCLOSEBUTTON   (1 << 3)
 The coordinates hit the tab on its close button. More...
 
#define MC_MTHT_ONITEM   (MC_MTHT_ONITEMICON | MC_MTHT_ONITEMLABEL | MC_MTHT_ONITEMCLOSEBUTTON)
 The coordinates hit the tab anywhere in its rectangle. More...
 
#define MC_MTHT_ONLEFTSCROLLBUTTON   (1 << 4)
 The coordinates hit the auxiliary button for scrolling to the left. More...
 
#define MC_MTHT_ONRIGHTSCROLLBUTTON   (1 << 5)
 The coordinates hit the auxiliary button for scrolling to the right. More...
 
#define MC_MTHT_ONLISTBUTTON   (1 << 6)
 The coordinates hit the auxiliary button for listing all items. More...
 
#define MC_MTHT_ONCLOSEBUTTON   (1 << 7)
 The coordinates hit the auxiliary button for closing current item. More...
 
#define MC_MTHT_ONBUTTON
 The coordinates hit any auxiliary button. More...
 
#define MC_MTHT_ABOVE   (1 << 8)
 Above the client area. More...
 
#define MC_MTHT_BELOW   (1 << 9)
 Below the client area. More...
 
#define MC_MTHT_TORIGHT   (1 << 10)
 To right of the client area. More...
 
#define MC_MTHT_TOLEFT   (1 << 11)
 To left of the client area. More...
 

Control Messages

#define MC_MTM_GETITEMCOUNT   (MC_MTM_FIRST + 0)
 Gets count of tabs. More...
 
#define MC_MTM_GETIMAGELIST   (MC_MTM_FIRST + 1)
 Gets image-list. More...
 
#define MC_MTM_SETIMAGELIST   (MC_MTM_FIRST + 2)
 Sets image-list. More...
 
#define MC_MTM_DELETEALLITEMS   (MC_MTM_FIRST + 3)
 Delete all tab items. More...
 
#define MC_MTM_INSERTITEMW   (MC_MTM_FIRST + 4)
 Inserts new tab into the tab control (Unicode variant). More...
 
#define MC_MTM_INSERTITEMA   (MC_MTM_FIRST + 5)
 Inserts new tab into the tab control (ANSI variant). More...
 
#define MC_MTM_SETITEMW   (MC_MTM_FIRST + 6)
 Sets tab in the tab control (Unicode variant). More...
 
#define MC_MTM_SETITEMA   (MC_MTM_FIRST + 7)
 Sets tab in the tab control (ANSI variant). More...
 
#define MC_MTM_GETITEMW   (MC_MTM_FIRST + 8)
 Gets tab data from the tab control (Unicode variant). More...
 
#define MC_MTM_GETITEMA   (MC_MTM_FIRST + 9)
 Gets tab data from the tab control (ANSI variant). More...
 
#define MC_MTM_DELETEITEM   (MC_MTM_FIRST + 10)
 Deletes the item. More...
 
#define MC_MTM_HITTEST   (MC_MTM_FIRST + 11)
 Tests which tab (and its part) is placed on specified position. More...
 
#define MC_MTM_SETCURSEL   (MC_MTM_FIRST + 12)
 Selects a tab. More...
 
#define MC_MTM_GETCURSEL   (MC_MTM_FIRST + 13)
 Gets index of selected tab. More...
 
#define MC_MTM_CLOSEITEM   (MC_MTM_FIRST + 14)
 Asks to close item. More...
 
#define MC_MTM_SETITEMWIDTH   (MC_MTM_FIRST + 15)
 Sets default and minimal width for each tab. More...
 
#define MC_MTM_GETITEMWIDTH   (MC_MTM_FIRST + 16)
 Gets default and minimal width for each tab. More...
 
#define MC_MTM_INITSTORAGE   (MC_MTM_FIRST + 17)
 Preallocate enough memory for requested number of items. More...
 
#define MC_MTM_GETITEMRECT   (MC_MTM_FIRST + 18)
 Get item rectangle. More...
 
#define MC_MTM_ENSUREVISIBLE   (MC_MTM_FIRST + 19)
 Ensure the item is visible. More...
 
#define MC_MTM_SETTOOLTIPS   (MC_MTM_FIRST + 20)
 Associate a tooltip window with the control. More...
 
#define MC_MTM_GETTOOLTIPS   (MC_MTM_FIRST + 21)
 Get tooltip associated with the control. More...
 
#define MC_MTM_CANCELDRAGITEM   (MC_MTM_FIRST + 22)
 Cancel currently ongoing drag-and-drop operation. More...
 

Control Notifications

#define MC_MTN_SELCHANGE   (MC_MTN_FIRST + 0)
 Fired when other tab has been selected. More...
 
#define MC_MTN_DELETEITEM   (MC_MTN_FIRST + 1)
 Fired when a tab is being deleted. More...
 
#define MC_MTN_DELETEALLITEMS   (MC_MTN_FIRST + 2)
 Fired when control processes MC_MTM_DELETEALLITEMS message or when it is being destroyed. More...
 
#define MC_MTN_CLOSEITEM   (MC_MTN_FIRST + 3)
 Fired when user requests closing a tab item. More...
 
#define MC_MTN_GETDISPINFOW   (MC_MTN_FIRST + 4)
 Fired when control needs to retrieve some item data, the parent holds (Unicode variant). More...
 
#define MC_MTN_GETDISPINFOA   (MC_MTN_FIRST + 5)
 Fired when control needs to retrieve some item data, the parent holds (ANSI variant). More...
 

Unicode Resolution

#define MC_WC_MDITAB   MCTRL_NAME_AW(MC_WC_MDITAB)
 
#define MC_MTITEM   MCTRL_NAME_AW(MC_MTITEM)
 
#define MC_MTM_INSERTITEM   MCTRL_NAME_AW(MC_MTM_INSERTITEM)
 
#define MC_MTM_SETITEM   MCTRL_NAME_AW(MC_MTM_SETITEM)
 
#define MC_MTM_GETITEM   MCTRL_NAME_AW(MC_MTM_GETITEM)
 
#define MC_MTN_GETDISPINFO   MCTRL_NAME_AW(MC_MTN_GETDISPINFO)
 
#define MC_NMMTDISPINFO   MCTRL_NAME_AW(MC_NMMTDISPINFO)
 

Data Structure Documentation

struct MC_MTITEMW

Structure for manipulating with the tab item (Unicode variant).

Structures

See also
MC_MTM_INSERTITEM MC_MTM_SETITEM MC_MTM_GETITEM
Data Fields
DWORD dwMask

Bit mask indicating which members of the structure are valid. See MC_MTIF_xxxx.

LPWSTR pszText

Text label of the tab.

int cchTextMax

Number of characters in pszText. Used only on output.

int iImage

Index into control image list. Set to MC_I_IMAGENONE if no image is associated with the item.

LPARAM lParam

User data.

struct MC_MTITEMA

Structure for manipulating with the tab item (ANSI variant).

See also
MC_MTM_INSERTITEM MC_MTM_SETITEM MC_MTM_GETITEM
Data Fields
DWORD dwMask

Bit mask indicating which members of the structure are valid. See MC_MTIF_xxxx.

LPSTR pszText

Text label of the tab.

int cchTextMax

Number of characters in psxText. Used only on output.

int iImage

Index into control image list. Set to MC_I_IMAGENONE if no image is associated with the item.

LPARAM lParam

User data.

struct MC_MTITEMWIDTH

Structure for messages MC_MTM_SETITEMWIDTH and MC_MTM_GETITEMWIDTH.

The structure describes policy how the control manages width of the items. Normally the width of the item is determined with the default width.

However if there are too many items to be displayed, the control may shrink the items in order to show more of them to minimize need for scrolling. The minimal width specifies how much the items may be shrank.

Data Fields
DWORD dwDefWidth

The default item width. If set to zero, default width of each item depends on its label and icon. If set to non-zero then all items have the same width, in pixels.

DWORD dwMinWidth

The minimal item width. If set to zero, the items are never shrank. If set to non-zero, the value specifies the minimal width of all items.

struct MC_MTHITTESTINFO

Structure for message MC_MTM_HITTEST.

Data Fields
POINT pt

Coordinates to test.

UINT flags

On output, set to the result of the test.

struct MC_NMMTSELCHANGE

Structure for notification MC_MTN_SELCHANGE.

Data Fields
NMHDR hdr

Standard notification structure header.

int iItemOld

Index of previously selected tab.

LPARAM lParamOld

Data of previously selected tab, or zero.

int iItemNew

Index of newly selected tab

LPARAM lParamNew

Data of newly selected tab, or zero.

struct MC_NMMTDELETEITEM

Structure for notification MC_MTN_DELETEITEM.

Data Fields
NMHDR hdr

Standard notification structure header.

int iItem

Index of the item being deleted.

LPARAM lParam

User data of the item being deleted.

struct MC_NMMTCLOSEITEM

Structure for notification MC_MTN_CLOSEITEM.

Data Fields
NMHDR hdr

Standard notification structure header.

int iItem

Index of the item being closed.

LPARAM lParam

User data of the item being closed.

struct MC_NMMTDISPINFOW

Structure used by notification MC_MTN_GETDISPINFO (Unicode variant).

Data Fields
NMHDR hdr

Common notification structure header.

UINT iItem

Item index.

MC_MTITEMW item

Structure describing the contents of the cell.

struct MC_NMMTDISPINFOA

Structure used by notification MC_MTN_GETDISPINFO (ANSI variant).

Data Fields
NMHDR hdr

Common notification structure header.

UINT iItem

Item index.

MC_MTITEMA item

Structure describing the contents of the cell.

Macro Definition Documentation

#define MC_WC_MDITABW   L"mCtrl.mditab"

Window class name (Unicode variant).

#define MC_WC_MDITABA   "mCtrl.mditab"

Window class name (ANSI variant).

#define MC_MTS_CBONTOOLBAR   0x0000

Show close button on right side of the control. This is default.

#define MC_MTS_CBONEACHTAB   0x0001

Not supported, reserved for future use.

#define MC_MTS_CBONACTIVETAB   0x0002

Not supported, reserved for future use.

#define MC_MTS_CBNONE   0x0003

Don't show close button.

#define MC_MTS_CBMASK   0x0003

This is not valid style, its bit-mask of MC_MTS_CBxxx styles.

#define MC_MTS_TLBALWAYS   0x0000

Popup tab list button is shown always. This is default.

#define MC_MTS_TLBONSCROLL   0x0004

Popup tab list button is shown if scrolling is triggered on.

#define MC_MTS_TLBNEVER   0x0008

Popup tab list button is never displayed.

#define MC_MTS_TLBMASK   0x000C

This is not valid style, but bit-mask of MC_NTS_TLBxxx styles.

#define MC_MTS_SCROLLALWAYS   0x0010

Always shows scrolling buttons.

#define MC_MTS_CLOSEONMCLICK   0x0020

Middle click closes a tab.

#define MC_MTS_FOCUSONBUTTONDOWN   0x0040

Mouse button down gains focus.

#define MC_MTS_FOCUSNEVER   0x0080

Never gains focus.

#define MC_MTS_FOCUSMASK   0x00C0

This is not valid style, but bit-mask of MC_NTS_FOCUSxxx styles.

#define MC_MTS_DOUBLEBUFFER   0x0100

Enable painting with double buffering.

It prevents flickering when the control is being continuously resized.

#define MC_MTS_ANIMATE   0x0200

Allow animation.

Some operations, like scrolling to left or right and insertion or removal of items, are animated when this style is set.

#define MC_MTS_EXTENDWINDOWFRAME   0x0400

Extend top window frame down to the bottom of the tab control.

Note this style is ignored on older Windows or when DWM composition is disabled (when DwmIsCompositionEnabled() returns FALSE).

Note
When the style is used, the Application should forward the message WM_DWMCOMPOSITIONCHANGED from top level window procedure to the control.
#define MC_MTS_NOTOOLTIPS   0x0800

Disables a tooltip window.

When having a tooltip window associated, the control uses the tooltip to show additional information about the pointed item. By default the control creates its own control when this style is not set.

See also
MC_MTM_SETTOOLTIPS
#define MC_MTS_DRAGDROP   0x1000

Allow drag-and-drop reordering of control items.

#define MC_MTIF_TEXT   (1 << 0)
#define MC_MTIF_IMAGE   (1 << 1)
#define MC_MTIF_PARAM   (1 << 2)
#define MC_MTHT_NOWHERE   (1 << 0)

The hit test coordinates are outside of any tabs.

#define MC_MTHT_ONITEMICON   (1 << 1)

The coordinates hit the tab on its icon.

#define MC_MTHT_ONITEMLABEL   (1 << 2)

The coordinates hit the tab, but its icon or close button.

#define MC_MTHT_ONITEMCLOSEBUTTON   (1 << 3)

The coordinates hit the tab on its close button.

The coordinates hit the tab anywhere in its rectangle.

#define MC_MTHT_ONLEFTSCROLLBUTTON   (1 << 4)

The coordinates hit the auxiliary button for scrolling to the left.

#define MC_MTHT_ONRIGHTSCROLLBUTTON   (1 << 5)

The coordinates hit the auxiliary button for scrolling to the right.

#define MC_MTHT_ONLISTBUTTON   (1 << 6)

The coordinates hit the auxiliary button for listing all items.

#define MC_MTHT_ONCLOSEBUTTON   (1 << 7)

The coordinates hit the auxiliary button for closing current item.

#define MC_MTHT_ONBUTTON
Value:
MC_MTHT_ONLISTBUTTON | MC_MTHT_ONCLOSEBUTTON)
#define MC_MTHT_ONCLOSEBUTTON
The coordinates hit the auxiliary button for closing current item.
Definition: mditab.h:338
#define MC_MTHT_ONRIGHTSCROLLBUTTON
The coordinates hit the auxiliary button for scrolling to the right.
Definition: mditab.h:334
#define MC_MTHT_ONLEFTSCROLLBUTTON
The coordinates hit the auxiliary button for scrolling to the left.
Definition: mditab.h:332

The coordinates hit any auxiliary button.

#define MC_MTHT_ABOVE   (1 << 8)

Above the client area.

#define MC_MTHT_BELOW   (1 << 9)

Below the client area.

#define MC_MTHT_TORIGHT   (1 << 10)

To right of the client area.

#define MC_MTHT_TOLEFT   (1 << 11)

To left of the client area.

#define MC_MTM_GETITEMCOUNT   (MC_MTM_FIRST + 0)

Gets count of tabs.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(int) Count of tabs.
#define MC_MTM_GETIMAGELIST   (MC_MTM_FIRST + 1)

Gets image-list.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(HIMAGELIST) The image list, or NULL.
See also
MC_MTM_SETIMAGELIST
#define MC_MTM_SETIMAGELIST   (MC_MTM_FIRST + 2)

Sets image-list.

The tab items can refer to the images in the list with MC_MTITEM::iImage.

Parameters
wParamReserved, set to zero.
[in]lParam(HIMAGELIST) The image-list.
Returns
(HIMAGELIST) Old image list, or NULL.
See also
MC_MTM_GETIMAGELIST
#define MC_MTM_DELETEALLITEMS   (MC_MTM_FIRST + 3)

Delete all tab items.

The control sends MC_MTN_DELETEALLITEMS notification. Depending on the return value from the notifications, it may also send notification MC_MTN_DELETEITEM for each tab being deleted.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(BOOL) TRUE on success, FALSE otherwise.
See also
MC_MTM_DELETEITEM
#define MC_MTM_INSERTITEMW   (MC_MTM_FIRST + 4)

Inserts new tab into the tab control (Unicode variant).

Parameters
[in]wParam(int) Index of the new item.
[in]lParam(MC_MTITEM*) Pointer to detailed data of the new tab.
Returns
(int) index of the new tab, or -1 on failure.
#define MC_MTM_INSERTITEMA   (MC_MTM_FIRST + 5)

Inserts new tab into the tab control (ANSI variant).

Parameters
[in]wParam(int) Index of the new item.
[in]lParam(MC_MTITEM*) Pointer to detailed data of the new tab.
Returns
(int) index of the new tab, or -1 on failure.
#define MC_MTM_SETITEMW   (MC_MTM_FIRST + 6)

Sets tab in the tab control (Unicode variant).

Parameters
[in]wParam(int) Index of the item.
[in]lParam(MC_MTITEMW*) Pointer to detailed data of the tab.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_SETITEMA   (MC_MTM_FIRST + 7)

Sets tab in the tab control (ANSI variant).

Parameters
[in]wParam(int) Index of the item.
[in]lParam(MC_MTITEMA*) Pointer to detailed data of the tab.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_GETITEMW   (MC_MTM_FIRST + 8)

Gets tab data from the tab control (Unicode variant).

Application has to set MC_MTITEM::dwMask prior sending the message to indicate what attributes of the item to retrieve. If the application uses MC_MTIF_TEXT, then it also has to set MC_MTITEM::pszText to point to a buffer where the text will be stored and set MC_MTITEM::cchTextMax to specify size of the buffer.

Parameters
[in]wParam(int) Index of the item.
[out]lParam(MC_MTITEMW*) Pointer to detailed data of the tab, receiving the data according to MC_MTITEM::dwMask.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_GETITEMA   (MC_MTM_FIRST + 9)

Gets tab data from the tab control (ANSI variant).

Application has to set MC_MTITEM::dwMask prior sending the message to indicate what attributes of the item to retrieve. If the application uses MC_MTIF_TEXT, then it also has to set MC_MTITEM::pszText to point to a buffer where the text will be stored and set MC_MTITEM::cchTextMax to specify size of the buffer.

Parameters
[in]wParam(int) Index of the item.
[in,out]lParam(MC_MTITEMA*) Pointer to detailed data of the tab, receiving the data according to MC_MTITEM::dwMask.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_DELETEITEM   (MC_MTM_FIRST + 10)

Deletes the item.

Sends MC_MTN_DELETEITEM notification to parent window.

Parameters
[in]wParam(int) Index of tab to be deleted.
lParamReserved, set to zero.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_HITTEST   (MC_MTM_FIRST + 11)

Tests which tab (and its part) is placed on specified position.

Parameters
wParamReserved, set to zero.
[in,out]lParam(MC_MTHITTESTINFO*) Pointer to a hit test structure. Set MC_MTHITTESTINFO::pt on input.
Returns
(int) Index of the hit tab, or -1.
#define MC_MTM_SETCURSEL   (MC_MTM_FIRST + 12)

Selects a tab.

Parameters
[in]wParam(int) Index of the tab to select.
lParamReserved, set to zero.
Returns
(int) Index of previously selected tab, or -1.
#define MC_MTM_GETCURSEL   (MC_MTM_FIRST + 13)

Gets index of selected tab.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(int) Index of selected tab, or -1.
#define MC_MTM_CLOSEITEM   (MC_MTM_FIRST + 14)

Asks to close item.

It causes to send MC_MTN_CLOSEITEM notification and depending on its return value it then can cause deleting the item.

Parameters
[in]wParam(int) Index of the item to be closed.
lParamReserved, set to zero.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_SETITEMWIDTH   (MC_MTM_FIRST + 15)

Sets default and minimal width for each tab.

If there is enough space, all tabs have the default width. When there are too many widths, they are made narrower so more tabs fit into the visible space area, but never narrower then the minimal width.

Parameters
wParamReserved, set to zero.
[in]lParam(MC_MTITEMWIDTH*) Pointer to a structure specifying the default and minimal widths. When NULL is passed, the values are reset to built-in defaults.
Returns
(BOOL) TRUE on success, FALSE otherwise.
See also
MC_MTM_GETITEMWIDTH
#define MC_MTM_GETITEMWIDTH   (MC_MTM_FIRST + 16)

Gets default and minimal width for each tab.

Parameters
wParamReserved, set to zero.
[out]lParam(MC_MTITEMWIDTH*) Pointer to a structure where the current widths will be set.
Returns
(BOOL) TRUE on success, FALSE otherwise.
See also
MC_MTM_SETITEMWIDTH
#define MC_MTM_INITSTORAGE   (MC_MTM_FIRST + 17)

Preallocate enough memory for requested number of items.

You may want to use this message before adding higher number of items into the controls to speed it up by avoiding multiple reallocations.

Parameters
[in]wParam(UINT) The number of items to add.
lParamReserved, set to zero.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_GETITEMRECT   (MC_MTM_FIRST + 18)

Get item rectangle.

The shape of items is curved so the returned rectangle is only approximation of its geometry.

Parameters
[in]wParam(DWORD) Low word specifies index of the item. High word specifies whether whole rectangle (non-zero) or only visible part (zero) is requested.
[out]lParam(RECT*) Pointer to rectangle.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_ENSUREVISIBLE   (MC_MTM_FIRST + 19)

Ensure the item is visible.

If not visible, the control scrolls to make it visible.

Parameters
[in]wParam(int) Index of the item.
lParamReserved, set to zero.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_MTM_SETTOOLTIPS   (MC_MTM_FIRST + 20)

Associate a tooltip window with the control.

Parameters
[in]wParam(HWND) Handle of the tooltip window.
lParamReserved, set to zero.
Returns
(HWND) Handle of previous tooltip window or NULL if no tooltip was associated with the control.
See also
MC_MTS_NOTOOLTIPS
#define MC_MTM_GETTOOLTIPS   (MC_MTM_FIRST + 21)

Get tooltip associated with the control.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(HWND) Handle of the tooltip window or NULL if no tooltip is associated with the control.
#define MC_MTM_CANCELDRAGITEM   (MC_MTM_FIRST + 22)

Cancel currently ongoing drag-and-drop operation.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(BOOL) TRUE on success, FALSE otherwise (e.g. if no drag-and-drop operation is currently in progress).
See also
mditab_drag_and_drop
#define MC_MTN_SELCHANGE   (MC_MTN_FIRST + 0)

Fired when other tab has been selected.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMMTSELCHANGE*) Pointer to a structure specifying details about the selection change.
Returns
Application should return zero, if it processes the message.
#define MC_MTN_DELETEITEM   (MC_MTN_FIRST + 1)

Fired when a tab is being deleted.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMMTDELETEITEM*) Pointer to a structure specifying details about the item being deleted.
Returns
Application should return zero if it processes the notification.
#define MC_MTN_DELETEALLITEMS   (MC_MTN_FIRST + 2)

Fired when control processes MC_MTM_DELETEALLITEMS message or when it is being destroyed.

Depending on the value returned from the notification, calling MC_MTN_DELETEITEM notifications for all the items can be suppressed.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(NMHDR*)
Returns
Application should return FALSE to receive subsequent MC_MTN_DELETEITEM for each item; or TRUE to suppress sending them.
#define MC_MTN_CLOSEITEM   (MC_MTN_FIRST + 3)

Fired when user requests closing a tab item.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMMTCLOSEITEM*) Pointer to a structure specifying details about the item being closed.
Returns
Application should return FALSE to remove the tab (the tab is then deleted and MC_MTN_DELETEITEM notification is sent); or TRUE to cancel the tab closure.
#define MC_MTN_GETDISPINFOW   (MC_MTN_FIRST + 4)

Fired when control needs to retrieve some item data, the parent holds (Unicode variant).

This may happen when MC_MTITEM::pszText was to to the magical value MC_LPSTR_TEXTCALLBACK, or MC_MTITEM::iImage was set to the magical value MC_I_IMAGECALLBACK.

When sending the notification, the control sets MC_NMMTDISPINFO::iItem to identify the desired item. The control also sets MC_NMMTDISPINFO::item::lParam.

The control specifies what members in MC_NMMTDISPINFO::item the application should fill with the MC_NMMTDISPINFO::item::dwMask.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in,out]lParam(MC_NMMTDISPINFO*) Pointer to MC_NMMTDISPINFO structure.
Returns
None.
#define MC_MTN_GETDISPINFOA   (MC_MTN_FIRST + 5)

Fired when control needs to retrieve some item data, the parent holds (ANSI variant).

This may happen when MC_MTITEM::pszText was to to the magical value MC_LPSTR_TEXTCALLBACK, or MC_MTITEM::iImage was set to the magical value MC_I_IMAGECALLBACK.

When sending the notification, the control sets MC_NMMTDISPINFO::iItem to identify the desired item. The control also sets MC_NMMTDISPINFO::item::lParam.

The control specifies what members in MC_NMMTDISPINFO::item the application should fill with the MC_NMMTDISPINFO::item::dwMask.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in,out]lParam(MC_NMMTDISPINFO*) Pointer to MC_NMMTDISPINFO structure.
Returns
None.
#define MC_WC_MDITAB   MCTRL_NAME_AW(MC_WC_MDITAB)

Unicode-resolution alias.

See also
MC_WC_MDITABW MC_WC_MDITABA
#define MC_MTITEM   MCTRL_NAME_AW(MC_MTITEM)

Unicode-resolution alias.

See also
MC_MTITEMW MC_MTITEMA
#define MC_MTM_INSERTITEM   MCTRL_NAME_AW(MC_MTM_INSERTITEM)

Unicode-resolution alias.

See also
MC_MTM_INSERTITEMW MC_MTM_INSERTITEMA
#define MC_MTM_SETITEM   MCTRL_NAME_AW(MC_MTM_SETITEM)

Unicode-resolution alias.

See also
MC_MTM_SETITEMW MC_MTM_SETITEMA
#define MC_MTM_GETITEM   MCTRL_NAME_AW(MC_MTM_GETITEM)

Unicode-resolution alias.

See also
MC_MTM_GETITEMW MC_MTM_GETITEMA
#define MC_MTN_GETDISPINFO   MCTRL_NAME_AW(MC_MTN_GETDISPINFO)

Unicode-resolution alias.

See also
MC_MTN_GETDISPINFOW MC_MTN_GETDISPINFOA
#define MC_NMMTDISPINFO   MCTRL_NAME_AW(MC_NMMTDISPINFO)

Unicode-resolution alias.

See also
MC_NMMTDISPINFOW MC_NMMTDISPINFOA

Function Documentation

BOOL mcMditab_Initialize ( void  )

Registers window class of the control.

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

Unregisters window class of the control.

BOOL mcMditab_DefWindowProc ( HWND  hwndMain,
HWND  hwndMditab,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT *  plResult 
)

Application should call this message from its main window procedure when it uses MDI tab control with the style MC_MTS_EXTENDWINDOWFRAME.

Parameters
hwndMainHandle of the main window hosting the MDI tab control.
hwndMditabHandle of the MDI tab control.
uMsgMessage code.
wParamMessage WPARAM parameter.
lParamMessage LPARAM parameter.
[out]plResultResult of the message processing the application should return from the window procedure if the functions returns TRUE.
Returns
TRUE if the function processed the message, FALSE if it did not and the application should handle it on its own (or call DefWindowProc()).

Thus the typical window procedure using this function looks like this snippet of code:

1 LRESULT AppWndProc(HWND hwndMain, UINT uMsg, WPARAM wParam, LPARAM lParam)
2 {
3  LRESULT lResult;
4 
5  // Give mcMditab_DefWindowProc() the first chance to handle the message
6  // and if it handles it, return the result of its processing.
7  if(mcMditab_DefWindowProc(hwndMain, hwndMditab, uMsg, wParam, lParam, &lResult))
8  return lResult;
9 
10  switch(uMsg) {
11  // Normal message handling as in ordinary window procedure.
12  ...
13 
14  // Pass unhandled messages to DefWindowProc().
15  default:
16  return DefWindowProc(hwndMain, uMsg, wParam, lParam);
17  }
18 
19 }