Jump to content

Recommended Posts

Posted

I've been doing some work on Toolbar controls recently for GUIDarkTheme UDF and realized that toolbars created with _GUICtrlToolbar_Create are transparent by default. I need to program GUIDarkTheme UDF to handle this and act accordingly. Getting that value is not a problem.

But my question is:

Is transparent toolbar by default the expected behaviour? Or is that a bug?

The default style that is set is $TBSTYLE_FLAT, not $TBSTYLE_TRANSPARENT.

Here is the code for the _GUICtrlToolbar_Create function from GuiToolbar.au3:

Func _GUICtrlToolbar_Create($hWnd, $iStyle = $TBSTYLE_FLAT, $iExStyle = 0x00000000)
    $iStyle = BitOR($iStyle, $__GUICTRLCONSTANT_WS_CHILD, $__TOOLBARCONSTANT_WS_CLIPSIBLINGS, $__GUICTRLCONSTANT_WS_VISIBLE)

    Local $nCtrlID = __GuiCtrl_GetNextGlobalID($hWnd)
    If @error Then Return SetError(@error, @extended, 0)

    Local $hTool = _WinAPI_CreateWindowEx($iExStyle, $__TOOLBARCONSTANT_ClassName, "", $iStyle, 0, 0, 0, 0, $hWnd, $nCtrlID)
    __GUICtrlToolbar_ButtonStructSize($hTool)

    Return $hTool
EndFunc   ;==>_GUICtrlToolbar_Create

And here is the example from the help file showing transparent toolbar being default:

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetBkColor(0xffffff)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleTransparent($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has transparent style .: " & $bStyle)
    GUISetState(@SW_LOCK)
    _GUICtrlToolbar_SetStyleTransparent($hToolbar, Not $bStyle)
    GUISetState(@SW_UNLOCK)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has transparent style .: " & _GUICtrlToolbar_GetStyleTransparent($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

 

Posted
16 minutes ago, Nine said:

Seems that FLAT also makes it TRANSPARENT

That is interesting. So with FLAT, we must expect transparency. Understandable.

But then the question becomes, should FLAT be the default style for a toolbar if a user does not specify?

My own personal thought is that, over a long history I am more accustomed to seeing toolbars that are not transparent.

Having transparency option is fantastic and important. My concern is more about whether it should be default behaviour from the standard UDF functions.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...