Jump to content

_GUICtrlButton_Create w/ $BS_SPLITBUTTON


 Share

Recommended Posts

Can someone explain me how to make a _GUICtrlButton_Create with $BS_SPLITBUTTON.

I've looked in help file but its so confused, cant find the _GUICtrlButton_Create and $BS_SPLITBUTTON function.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>

Opt("MustDeclareVars", 1)

Global $btn, $iMemo, $btn2

; Note the controlId from these buttons can NOT be read with GuiCtrlRead

_Main()

Func _Main()
    Local $hGUI, $aInfo

    $hGUI = GUICreate("Buttons", 400, 400)
    $iMemo = GUICtrlCreateEdit("", 10, 100, 390, 284, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")

    $btn = _GUICtrlButton_Create($hGUI, "Split Button", 10, 10, 120, 30, $BS_SPLITBUTTON)
    _GUICtrlButton_SetSplitInfo($btn)
    $btn2 = _GUICtrlButton_Create($hGUI, "Split Button 2", 10, 50, 120, 30, $BS_SPLITBUTTON)

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

    $aInfo = _GUICtrlButton_GetSplitInfo($btn)
    MemoWrite("Split Info" & @LF & "----------------")
    For $x = 0 To 3
        MemoWrite("$ainfo[" & $x & "] = " & $aInfo[$x])
    Next
    MemoWrite("Split Info" & @LF & "----------------")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit

EndFunc   ;==>_Main

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg, $wParam
    Local Const $BCN_HOTITEMCHANGE = -1249
    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")
    Local $sText = ""
    
    Switch $nNotifyCode
        Case $BCN_HOTITEMCHANGE ; Win XP and Above
            If BitAND($dwFlags, 0x10) = 0x10 Then
                $sText = "$BCN_HOTITEMCHANGE - Entering: " & @CRLF
                
            ElseIf BitAND($dwFlags, 0x20) = 0x20 Then
                $sText = "$BCN_HOTITEMCHANGE - Leaving: " & @CRLF
            EndIf
            MemoWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_NOTIFY - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
        Case $BCN_DROPDOWN
            MemoWrite("$BCN_DROPDOWN")
            _Popup_Menu($hCtrl)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _Popup_Menu($hCtrl)
    Local $hMenu
    Local Enum $idOpen = 1000, $idSave, $idInfo
    $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $idOpen)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $idSave)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo)
    Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2)
        Case $idOpen
            MemoWrite("Open - Selected")
        Case $idSave
            MemoWrite("Save - Selected")
        Case $idInfo
            MemoWrite("Info - Selected")
    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 $btn, $btn2
            Switch $nNotifyCode
                Case $BN_CLICKED
                    $sText = "$BN_CLICKED" & @CRLF
                Case $BN_PAINT
                    $sText = "$BN_PAINT" & @CRLF
                Case $BN_PUSHED, $BN_HILITE
                    $sText = "$BN_PUSHED, $BN_HILITE" & @CRLF
                Case $BN_UNPUSHED, $BN_UNHILITE
                    $sText = "$BN_UNPUSHED" & @CRLF
                Case $BN_DISABLE
                    $sText = "$BN_DISABLE" & @CRLF
                Case $BN_DBLCLK, $BN_DOUBLECLICKED
                    $sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF
                Case $BN_SETFOCUS
                    $sText = "$BN_SETFOCUS" & @CRLF
                Case $BN_KILLFOCUS
                    $sText = "$BN_KILLFOCUS" & @CRLF
            EndSwitch
            MemoWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
            Return 0 ; Only workout clicking on the button
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND
Link to comment
Share on other sites

Vista Sytles: $BS_SPLITBUTTON - Creates a split button. A split button has a drop down arrow

Try this $btn = _GUICtrlButton_Create($hGUI, "Split Button", 10, 10, 120, 30, BitAND ( $BS_SPLITBUTTON, $WS_VISIBLE) )

Now i see the button but not the drop down arrow...

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • Moderators

wakillon,

You use BitOR to combine styles, not BitAND - but then you need neither here, see below. :)

eracross,

You need to add a few #include files: ;)

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

$hGUI = GUICreate("Test", 500, 500)

$btn = _GUICtrlButton_Create($hGUI, "Split Button", 10, 10, 120, 30, $BS_SPLITBUTTON)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

I see a split button in Vista - now to find out how to get it to work! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

wakillon,

You really do need to use BitOR to combine styles or you might not get what you think you are getting - read the Setting Styles tutorial in the Wiki to see why. :shocked:

eracross,

what i want is the $BS_SPLITBUTTON function how to popup the menu like this

Patience, my friend - I do not think anyone has ever done this in AutoIt so far. ;)

We need to do a bit of research - MSDN here we come. ;)

M23

Edit: See post below. It has been done before, by the OP in his original code! So I have no idea what he wants. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

wakillon,

You really do need to use BitOR to combine styles or you might not get what you think you are getting - read the Setting Styles tutorial in the Wiki to see why. ;)

eracross,

Patience, my friend - I do not think anyone has ever done this in AutoIt so far. :)

We need to do a bit of research - MSDN here we come. ;)

M23

Should set split info ? with _GUICtrlButton_SetSplitInfo Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • Moderators

eracross,

I am now confused - not very difficult, I admit. ;)

Your code in the original post already displays a menu when you click on the dropdown arrow and captures the resulting menu press. What more do you want? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

wakillon,

Yes, it is Vista+, I am afraid. ;)

Time to upgrade, mon ami! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

Yes, I think the difference in O/S from the OP as well. Does that Explain the Behavior with BitOR, BitAND. Because,

this

$btn = _GUICtrlButton_Create($hGUI, "Split Button", 10, 10, 120, 30, $BS_SPLITBUTTON)
     _GUICtrlButton_SetStyle($btn, $WS_VISIBLE)
    _GUICtrlButton_SetSplitInfo($btn)
    $btn2 = _GUICtrlButton_Create($hGUI, "Split Button 2", 10, 50, 120, 30, $BS_SPLITBUTTON)
     _GUICtrlButton_SetStyle($btn2, $WS_VISIBLE)

Works like Wakillons BitAND , Whereas BitOR results with the invisible buttons. So my larger question would be what is the return of $BS_SPLITBUTTON and what effect is it having on the operation in an XP environment that results in this behavior?

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>
#Include <String.au3>

Opt("MustDeclareVars", 1)

Global $btn, $iMemo, $btn2

Global $hexbutton = hex(BitOR($BS_SPLITBUTTON, $WS_VISIBLE))

msgbox (0 , '', $hexbutton)

Global $hexbutton2 = hex(BitAND($BS_SPLITBUTTON, $WS_VISIBLE))

msgbox (0 , '', $hexbutton2)

The BitAND was nulling out the whole lot, leaving normal visible buttons for XP users.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

iamtheky,

Thanks for that input. Like I said above - BitOR to combine styles or you might not get what you think you are getting! ;)

If anyone is interested, you can also use the style with buttons created using the built-in GUICtrlCreateButton command. Here is a simple example script showing both types:

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

Global $hButton_1, $hButton_2

_Main()

Func _Main()
    Local $hGUI

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

    $hButton_1 = GUICtrlCreateButton("Split Button 1", 10, 10, 120, 30, $BS_SPLITBUTTON)
    $hButton_2 = _GUICtrlButton_Create($hGUI, "Split Button 2", 10, 50, 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" & @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 $hMenu
    Local Enum $idOpen = 1000, $idSave, $idInfo
    Local $sButton = "Button 1"
    If $hCtrl = $hButton_2 Then $sButton = "Button 2"
    $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $idOpen)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $idSave)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo)
    Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2)
        Case $idOpen
            ConsoleWrite($sButton & " Open" & @CRLF)
        Case $idSave
            ConsoleWrite($sButton & " Save" & @CRLF)
        Case $idInfo
            ConsoleWrite($sButton & " Info" & @CRLF)
    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"
            EndSwitch
    EndSwitch

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

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

iamtheky,

Thanks for that input. Like I said above - BitOR to combine styles or you might not get what you think you are getting! :)

If anyone is interested, you can also use the style with buttons created using the built-in GUICtrlCreateButton command. Here is a simple example script showing both types:

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

Global $hButton_1, $hButton_2

_Main()

Func _Main()
    Local $hGUI

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

    $hButton_1 = GUICtrlCreateButton("Split Button 1", 10, 10, 120, 30, $BS_SPLITBUTTON)
    $hButton_2 = _GUICtrlButton_Create($hGUI, "Split Button 2", 10, 50, 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" & @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 $hMenu
    Local Enum $idOpen = 1000, $idSave, $idInfo
    Local $sButton = "Button 1"
    If $hCtrl = $hButton_2 Then $sButton = "Button 2"
    $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $idOpen)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $idSave)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo)
    Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2)
        Case $idOpen
            ConsoleWrite($sButton & " Open" & @CRLF)
        Case $idSave
            ConsoleWrite($sButton & " Save" & @CRLF)
        Case $idInfo
            ConsoleWrite($sButton & " Info" & @CRLF)
    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"
            EndSwitch
    EndSwitch

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

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

M23

Thanks melba! ;) btw is this only work for vista?
Link to comment
Share on other sites

  • Moderators

eracross,

That code is based on what you posted in the first post of this topic! ;)

However, if you are happy...... ;)

Like I said to wakillon, you need Vista + (i.e. Vista or Win7) for this to work. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

eracross,

That code is based on what you posted in the first post of this topic! ;)

However, if you are happy...... ;)

Like I said to wakillon, you need Vista + (i.e. Vista or Win7) for this to work. :)

M23

Yeah i know but i couldnt find the exactly string thanks!
Link to comment
Share on other sites

  • Moderators

eracross,

From where did you get the original script you posted? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...