orbs Posted July 7, 2013 Share Posted July 7, 2013 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). expandcollapse popup#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 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 7, 2013 Moderators Share Posted July 7, 2013 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
orbs Posted July 8, 2013 Author Share Posted July 8, 2013 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. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 8, 2013 Moderators Share Posted July 8, 2013 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
orbs Posted July 8, 2013 Author Share Posted July 8, 2013 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 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
guinness Posted July 8, 2013 Share Posted July 8, 2013 I didn't know what route you went with. Now I see the code I understand. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Malkey Posted July 8, 2013 Share Posted July 8, 2013 Here is another method to click on a split button. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 8, 2013 Moderators Share Posted July 8, 2013 Malkey,Sneaky! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
orbs Posted July 8, 2013 Author Share Posted July 8, 2013 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: 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. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now