Skip to content

ModernUI_CaptionBar Control

mrfearless edited this page Oct 23, 2018 · 7 revisions

ModernUI_CaptionBar Functions

MUICaptionBarRegister

Description: Registers the ModernUI_CaptionBar class, which allows the control to be created via dialog resources or via CreateWindowEx and specifying the classname ModernUI_CaptionBar. If using the RadASM custom class control instead of a the ModernUI RadASM Design Time Controls specify ModernUI_CaptionBar as the classname.

Parameters: None

MUICaptionBarCreate

Description: Creates a ModernUI_CaptionBar control. Returns in eax the handle of the newly created control or NULL.

Parameters: hWndParent, lpszCaptionText, dwCaptionHeight, dwResourceID, dwStyle

MUICaptionBarSetProperty

Description: Set a ModernUI_CaptionBar property with a value, which is stored in the external properties structure. Properties are defined as equates and are actually offsets into the memory location used to store the properties.

Parameters: hModernUI_CaptionBar, dwProperty, dwPropertyValue

MUICaptionBarGetProperty

Description: Get a ModernUI_CaptionBar property from the external properties structure. Properties are defined as equates and are actually offsets into the memory location used to store the properties.

Parameters: hModernUI_CaptionBar, dwProperty

MUICaptionBarLoadIcons

Description: Load minimize, restore, maximise and/or close icons from resource ids specified.

Parameters: hModernUI_CaptionBar, idResMin, idResMinAlt, idResMax, idResMaxAlt, idResRes, idResResAlt, idResClose, idResCloseAlt

MUICaptionBarLoadIconsDll

Description: Load minimize, restore, maximise and/or close icons from resource ids specified and uses hInstance specified so that the resources can be loaded from within a dll

Parameters: hModernUI_CaptionBar, hInstance, idResMin, idResMinAlt, idResMax, idResMaxAlt, idResRes, idResResAlt, idResClose, idResCloseAlt

MUICaptionBarLoadBackImage

Description: Loads an image for the back of the ModernUI_CaptionBar, typically a logo.

Parameters: hModernUI_CaptionBar, dwImageType, dwResIDImage

MUICaptionBarAddButton

Description: Adds a caption bar button to the ModernUI_CaptionBar control. Caption buttons add added to the left of existing minimize, restore, maximize and/or close buttons. Loads the icons for the caption button from resource ids specified.

Parameters: hModernUI_CaptionBar, lpszButtonText, dwResourceID, dwResIDImage, dwResIDImageAlt

MUICaptionBarAddButtonEx

Description: Adds a caption bar button to the ModernUI_CaptionBar control. Caption buttons add added to the left of existing minimize, restore, maximize and/or close buttons. Uses handles specified for already loaded icons for the caption button.

Parameters: hModernUI_CaptionBar, lpszButtonText, dwResourceID, hIcon, hIconAlt

MUICapButtonSetProperty

Description: Sets a property for a caption bar button.

Parameters: hCapButton, dwProperty, dwPropertyValue

MUICapButtonGetProperty

Description: Gets a property for a caption bar button.

Parameters: hCapButton, dwProperty

ModernUI_CaptionBar Styles

The CaptionBar control supports a number of style flags (defined in the .inc include file) that allow you to customize the behaviour of the control, what system buttons to include, alignment of caption text etc.

  • MUICS_LEFT - left align caption bar text
  • MUICS_CENTER - center align caption bar text
  • MUICS_NOMINBUTTON - no minimize button
  • MUICS_NOMAXBUTTON - no maximize/restore button
  • MUICS_NOCLOSEBUTTON - no close button
  • MUICS_REDCLOSEBUTTON - close button uses win8+ red background color
  • MUICS_WINNOMUISTYLE - Dont apply MUI borderless frame style to window/dialog, if not specified will apply MUI style.
  • MUICS_WINNODROPSHADOW - Dont apply drop shadow to window/dialog. If not specified will apply dropshadow if MUICS_WINDOWNOMUISTYLE not specified.
  • MUICS_USEICONSFORBUTTONS - Use icons instead of text (Marlett font glyphs) for the min/max/res/close buttons: Load icons via the MUICaptionBarLoadIcons functions or set handles via @CaptionBarBtnIcoXXX properties
  • MUICS_KEEPICONS - Dont delete icons handles when control is destoyed. Essential if icon handles are used in multiple controls or where set directly with properties
  • MUICS_NOCAPTIONTITLETEXT - Dont draw a title text value, use lpszCaptionText for taskbar name of app only.
  • MUICS_NOBORDER - No border used, so position ModernUI_CaptionBar at 0,0 instead of at 1,1
  • MUICS_WINSIZE - Dialog/Window is resizable.
  • MUICS_THEME - Use default windows theme colors and react to WM_THEMECHANGED

ModernUI_CaptionBar Properties

The CaptionBar control supports a number of Properties for changing attributes such as text and background colours, and colours to use when the mouse moves over the system buttons.

  • @CaptionBarTextColor - Text color for captionbar text and system buttons (min/max/restore/close)
  • @CaptionBarTextFont - Font for captionbar text
  • @CaptionBarBackColor - Background color of captionbar and system buttons (min/max/restore/close)
  • @CaptionBarBackImageType - Image Type - One of the following: MUICBIT_NONE,MUICBIT_BMP, MUICBIT_ICO, MUICBIT_PNG
  • @CaptionBarBackImage - Image to display in captionbar background.
  • @CaptionBarBackImageOffsetX - Offset x +/- to set position of hImage. Default = 0
  • @CaptionBarBackImageOffsetY - Offset y +/- to set position of hImage. Default = 0
  • @CaptionBarBtnTxtRollColor - Text color for system buttons (min/max/restore/close) when mouse moves over button
  • @CaptionBarBtnBckRollColor - Background color for system buttons (min/max/restore/close) when mouse moves over button
  • @CaptionBarBtnBorderColor - Border color for system buttons (min/max/restore/close). 0 = use same as @CaptionBarBackColor
  • @CaptionBarBtnBorderRollColor - Border color for system buttons (min/max/restore/close) when mouse moves over button. 0 = use @CaptionBarBtnBckRollColor
  • @CaptionBarBtnWidth - System buttons width. Defaults = 32px
  • @CaptionBarBtnHeight - System buttons height. Defaults = 28px
  • @CaptionBarBtnOffsetX - Offset y +/- to set position of system buttons (min/max/restore/close) in relation to right of captionbar
  • @CaptionBarBtnOffsetY - DWORD. Offset y + to set position of system buttons (min/max/restore/close) in relation to top of captionbar
  • @CaptionBarBtnIcoMin - For minimize button
  • @CaptionBarBtnIcoMinAlt - For minimize button when mouse moves over button
  • @CaptionBarBtnIcoMax - For maximize button
  • @CaptionBarBtnIcoMaxAlt - For maximize button when mouse moves over button
  • @CaptionBarBtnIcoRes - For restore button
  • @CaptionBarBtnIcoResAlt - For restore button when mouse moves over button
  • @CaptionBarBtnIcoClose - For close button
  • @CaptionBarBtnIcoCloseAlt - For close button when mouse moves over button
  • @CaptionBarWindowBackColor - If -1 = No painting of window/dialog background, handled by user or default system.
  • @CaptionBarWindowBorderColor - If -1 = No border. if @CaptionBarWindowBackColor != -1 then color of border to paint on window.
  • @CaptionBarDllInstance - For loading resources (icons) - normally set to 0 (current module) but when resources are in a dll set this before calling MUICaptionBarLoadIcons
  • @CaptionBarParam - Custom user data

Properties can be read or changed by using the MUICaptionBarGetProperty and MUICaptionBarSetProperty functions

For example to change the background color of the caption and system buttons:

Invoke MUICaptionBarCreate, hWin, Addr AppName, 32d, IDC_CAPTIONBAR, MUICS_LEFT or MUICS_REDCLOSEBUTTON
mov hCaptionBar, eax
Invoke MUICaptionSetProperty, hCaptionBar, @CaptionBarBackColor, MUI_RGBCOLOR(128,128,128) ; changes it to a greyish color

ModernUI_CaptionBar Notes

The CaptionBar is a control that comprises a rectangle containing the caption text or title of the window / dialog, along with one or more system buttons. System buttons are typically minimize, maximize/restore and close.

The CaptionBar control is automatically aligned to the top of the window / dialog, and spans the width of it. The control will automatically adjust the width when the window / dialog is resized, via the system buttons (min/max/restore), double clicking the CaptionBar itself (toggles between maximized and restored) or programmatically via ShowWindow or other win32 api calls.

The CaptionBar can be added to your projects in two ways:

  • Calling the MUICaptionBarCreate function. Ideally call this in the WM_INITDIALOG handler.
  • Calling the MUICaptionBarRegister function before your dialog is created (at start of program for example), and placing a custom resource class with the name of 'ModernUI_CaptionBar' in your resource file (if using RadASM, you can add a custom control via the resource editor and update the class name field)

Clone this wiki locally