Sign in to follow this  
Followers 0
orbs

SplitButton - can the split be vertical?

9 posts in this topic

hello world,

sometime in the past i stumbled upon this piece of code, which demonstrates a SplitButton with the dropdown arrow on the left-hand-side. i'm wondering if it's possible that the dropdown arrow be placed at the bottom of the button (imagine a button size 40x50, where the upper part 40x40 contains a 32x32 icon, and the lower part 40x10 is separated).

#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>

Global $hButton_1, $hButton_2, $hButton_1_Handle

_Main()

Func _Main()
    Local $hGUI

    $hGUI = GUICreate("Buttons", 400, 400)

    $hButton_1 = GUICtrlCreateButton("Initial 1", 10, 10, 120, 30, $BS_SPLITBUTTON)
    $hButton_1_Handle = GUICtrlGetHandle(-1)
    $hButton_2 = _GUICtrlButton_Create($hGUI, "Initial 1", 270, 10, 120, 30, $BS_SPLITBUTTON)
    _GUICtrlButton_SetSplitInfo($hButton_2) ; puts icon to left

    GUISetState()

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hButton_1
                ConsoleWrite("Button 1 Pressed - " & GUICtrlRead($hButton_1) & @CRLF)
        EndSwitch
    WEnd

    Exit

EndFunc   ;==>_Main

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)

    #forceref $hWnd, $Msg, $wParam

    Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
    Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
    ;Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
    Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
    ;Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")

    Switch $nNotifyCode
        Case $BCN_DROPDOWN
            _Popup_Menu($hCtrl)
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_NOTIFY

Func _Popup_Menu($hCtrl)

    Local Enum $iOption_1 = 1000, $iOption_2
    Local $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Disable", $iOption_1)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Enable", $iOption_2)
    Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2)
        Case $iOption_1
            Switch $hCtrl
                Case $hButton_1_Handle
                    ConsoleWrite("Button 1 - Option 1" & @CRLF)
                    GUICtrlSetData($hButton_1, "Option 1")
                    _GUICtrlButton_Enable($hButton_2, False) ; <<<<<<<<<<<<<<<<<<<<<<<<
                Case $hButton_2
                    ConsoleWrite("Button 2 - Option 1" & @CRLF)
                    _GUICtrlButton_SetText($hButton_2, "Option 1")
                    GUICtrlSetState($hButton_1, $GUI_DISABLE) ; <<<<<<<<<<<<<<<<<<<<<<<<
            EndSwitch
        Case $iOption_2
            Switch $hCtrl
                Case $hButton_1_Handle
                    ConsoleWrite("Button 1 - Option 2" & @CRLF)
                    GUICtrlSetData($hButton_1, "Option 2")
                    _GUICtrlButton_Enable($hButton_2, True) ; <<<<<<<<<<<<<<<<<<<<<<<<
                Case $hButton_2
                    ConsoleWrite("Button 2 - Option 2" & @CRLF)
                    _GUICtrlButton_SetText($hButton_2, "Option 2")
                    GUICtrlSetState($hButton_1, $GUI_ENABLE) ; <<<<<<<<<<<<<<<<<<<<<<<<
            EndSwitch
    EndSwitch
    _GUICtrlMenu_DestroyMenu($hMenu)

EndFunc   ;==>_Popup_Menu

; React on a button click
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

    #forceref $hWnd, $Msg

    Local $nNotifyCode = BitShift($wParam, 16)
    ;Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
    Local $sText = ""
    Switch $hCtrl
        Case $hButton_2
            Switch $nNotifyCode
                Case $BN_CLICKED
                    $sText = "Button 2 Clicked - " & _GUICtrlButton_GetText($hButton_2)
            EndSwitch
    EndSwitch

    If $sText <> "" Then ConsoleWrite($sText & @CRLF)

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

Share this post


Link to post
Share on other sites



orbs,

According to MSDN the only available styles are BCSS_ALIGNLEFT and BCSS_NOSPLIT - nothing about vertical splits. :(

But you might be able to make an owner-drawn equivalent using 2 buttons with a context menu on the lower. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

But you might be able to make an owner-drawn equivalent using 2 buttons with a context menu on the lower. ;)

 

 

thanks Melab23, yes that I already did, it works but it looks... well... "aesthetically-challenged" i believe would be the politically-correct term  ;) . but that's probably my fault. i'll stick to what's possible.

Share this post


Link to post
Share on other sites

orbs,

If you post what you have perhaps someone could help turn your "sow's ear" into something more closely ressembling a ""silk purse". ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

nothing to show, just 2 buttons with same width, one under the other, the lower one is with an arrow character, and height of 15px.

i also tried to make the main button (the upper one) overlap on few px of the lower button, so at-least the upper corners of the lower button are hidden by the main button. but that makes it flicker.

so here's a simplified example of what i've got so far:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

Local $msg

; GUI build
GUICreate('Vertical pseudo SplitButton')
$gButton_main=GUICtrlCreateButton('',10,10,40,40,$BS_ICON)
GUICtrlSetImage($gButton_main,'shell32.dll',322)
$gButton_split=GUICtrlCreateButton(Chr(54),10,50,40,15)
GUICtrlSetFont($gButton_split,12,Default,Default,'Webdings')
$gButton_split_menu=GUICtrlCreateContextMenu($gButton_split)
$gButton_split_menu_item=GUICtrlCreateMenuItem('Secondary Action',$gButton_split_menu)
GUISetState()

; main loop
While True
    $msg=GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $gButton_split
            ControlClick('','',$gButton_split,'right')
        Case $gButton_main
            MsgBox(64,'action','this is where the primary action occures.  ')
        Case $gButton_split_menu_item
            MsgBox(64,'action','this is where the secondary action occures.  ')
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

I didn't know what route you went with. Now I see the code I understand.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Here is another method to click on a split button.

#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
; Up and down arrows copied from Character Map @ 
; "Start" button on Windows taskbar > All programs > Accessories > System Tools > click on Character Map
; Note: To allow up and down arrow on SciTE, click on menu File > Encoding > click on "UTF-8 with BOM"

_Main()


Func _Main()
    Local $hGUI, $hButton_1, $hButton_2, $aPos
    $hGUI = GUICreate("Buttons", 400, 400)
    $hButton_1 = GUICtrlCreateButton("▲" & @LF & "------------------" & @LF & "Button 1", 10, 10, 60, 45, BitOR($BS_MULTILINE, $BS_BOTTOM))
    $hButton_2 = GUICtrlCreateButton("▼", 270, 10, 50, 60, BitOR($BS_MULTILINE, $BS_TOP))
    GUICtrlSetImage($hButton_2, 'shell32.dll', 322)
    GUISetState()
    While 1
        $aPos = GUIGetCursorInfo()
        ToolTip($aPos[0] & ", " & $aPos[1])
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hButton_1
                If $aPos[1] < 35 Then
                    ConsoleWrite("Button 1 UPPER is Pressed - " & @CRLF)
                Else
                    ConsoleWrite("Button 1 Lower is Pressed - " & @CRLF)
                EndIf
            Case $hButton_2
                If $aPos[1] < 40 Then
                    ConsoleWrite("Button 2 UPPER is Pressed - " & @CRLF)
                Else
                    ConsoleWrite("Button 2 Lower is Pressed - " & @CRLF)
                EndIf
        EndSwitch
    WEnd
    Exit
EndFunc   ;==>_Main

Share this post


Link to post
Share on other sites

Malkey,

Sneaky! :thumbsup:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

that is a nice approach indeed.

note about any special characters you may introduce: when displayed in GUI (not related to SciTe encoding) they rely on your non-unicode support (a.k.a system locale). for some values other than English or Latin, they are displayed as empty squares, like this:

post-47848-0-69467700-1373318548_thumb.p

so for now i'll stick to the font-based solution.

also the separator made by minuses can be better visualized by underscores (no empty dots in the line), this also requires careful settings of heights of the elements. i will continue experimenting on it.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0