MODSTYLE function

Purpose:

MODSTYLE modifies the Window Style or Extended Window Style of a window or control.

Syntax:

Retval = MODSTYLE(HndlWnd AS HWND  _
             [, AddStyle AS ULONG] _
          [, RemoveStyle AS ULONG] _
             [, StyleType AS BOOL])

Return Value:

Parameters:

  • Data type: HWND
    HndlWnd The handle to a window or control.
  • Data type: ULONG
    AddStyle [OPTIONAL] Either Window Styles or Extended Window Styles to add. Set this parameter to zero if styles are not being added. If a style is being removed with RemoveStyle, the AddStyle style must be the same as the style in RemoveStyle, that is, either Window Style or Extended Window Style. For more information, visit the Microsoft Window Styles and the Microsoft Extended Window Styles webpages.
  • Data type: ULONG
    RemoveStyle [OPTIONAL] Either Window Styles or Extended Window Styles to remove. Set this parameter to zero if styles are not being removed. If a style is being added with AddStyle, the RemoveStyle style must be the same as the style in AddStyle, that is, either Window Style or Extended Window Style. For more information, visit the Microsoft Window Styles and the Microsoft Extended Window Styles webpages.
  • Data type: BOOL
    StyleType [OPTIONAL] Either FALSE for Window Styles or TRUE for Extended Window Styles. Default value is FALSE indicating that the Window Styles is being added and/or removed.

Remarks:

If a style is being added and removed, the style added must be the same as the style being removed, that is, either a Window Style or an Extended Window Style.

MODSTYLE will not change ListBox control styles.

Example:

Here is an example to toggle Window Styles WS_MAXIMIZEBOX and WS_MINIMIZEBOX.

GUI "NoMaxMin"

DIM frmMain AS CONTROL
DIM button1 AS CONTROL
GLOBAL Toggle = TRUE

SUB FORMLOAD
  frmMain = BCX_FORM("My Form", 100, 100, 100, 100)
  button1 = BCX_BUTTON("ModStyle", frmMain, 102, 35, 40, 30, 10)
  SHOW(frmMain)
END SUB

BEGIN EVENTS

  SELECT CASE CBMSG
  CASE WM_COMMAND
    IF wParam = 102 THEN
      Toggle = NOT Toggle
      IF NOT Toggle THEN
        MODSTYLE(frmMain, 0, WS_MAXIMIZEBOX | WS_MINIMIZEBOX, FALSE)
      ELSE
        MODSTYLE(frmMain, WS_MAXIMIZEBOX | WS_MINIMIZEBOX, 0, FALSE)
      END IF
    END IF
  CASE WM_CLOSE
    DestroyWindow(hWnd)
    EXIT FUNCTION
  END SELECT
END EVENTS