Jump to content

Button - trigger through doubleclick


pippi
 Share

Recommended Posts

#include <GUIConstants.au3>
Opt("MustDeclareVars", 1)

Global Const $DebugIt = 1
Global Const $WM_COMMAND = 0x0111
Global $Hovered = 0
Global $Button, $status

_Main()

Func _Main()
    Local $x = 48, $y = 88, $msg, $Form2
    
    $Form2 = GUICreate("Blash", 716, 561, 155, 134, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP))
    
    $Button = GUICtrlCreateButton("Button Test", 10, 10, 89, 41)
    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
    GUISetState(@SW_SHOW)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        EndSelect
    WEnd
EndFunc   ;==>_Main

Func Button_Click(ByRef $ctrl_id)
;~  _DebugPrint("Button_Click")
EndFunc   ;==>Button_Click

Func Button_DblClick(ByRef $ctrl_id)
;~  _DebugPrint("Button_DblClick")
    MsgBox(0,"Test", "Button_DblClick")
EndFunc   ;==>Button_Click

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local Const $BN_CLICKED = 0;
    Local Const $BN_PAINT = 1;
    Local Const $BN_HILITE = 2;
    Local Const $BN_PUSHED = $BN_HILITE;
    Local Const $BN_UNHILITE = 3;
    Local Const $BN_UNPUSHED = $BN_UNHILITE;
    Local Const $BN_DISABLE = 4;
    Local Const $BN_DOUBLECLICKED = 5;
    Local Const $BN_DBLCLK = $BN_DOUBLECLICKED;
    Local Const $BN_SETFOCUS = 6;
    Local Const $BN_KILLFOCUS = 7;
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam

    
    If $nID <> 2 Then
        Switch $nNotifyCode
            Case $BN_CLICKED
;~                 _DebugPrint("$BN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hwnd & @LF & _
;~                                                 "MsgID" & @TAB & ":" & $Msg & @LF & _
;~                                                 "wParam" & @TAB & ":" & $wParam & @LF & _
;~                                                 "lParam" & @TAB & ":" & $lParam & @LF & @LF & _
;~                                                 "WM_COMMAND - Infos:" & @LF & _
;~                                                 "-----------------------------" & @LF & _
;~                                                 "Code" & @TAB & ":" & $nNotifyCode & @LF & _
;~                                                 "CtrlID" & @TAB & ":" & $nID & @LF & _
;~                                                 "CtrlHWnd" & @TAB & ":" & $hCtrl)
;~                     Button_Click ($nID)
            Case $BN_PAINT
                _DebugPrint("$BN_PAINT")
            Case $BN_PUSHED, $BN_HILITE
                _DebugPrint("$BN_PUSHED, $BN_HILITE")
            Case $BN_UNPUSHED, $BN_UNHILITE
                _DebugPrint("$BN_UNPUSHED")
            Case $BN_DISABLE
                _DebugPrint("$BN_DISABLE")
            Case $BN_DBLCLK, $BN_DOUBLECLICKED
;~                 _DebugPrint("$BN_DBLCLK, $BN_DOUBLECLICKED")
                _DebugPrint("$BN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hwnd & @LF & _
                                                "MsgID" & @TAB & ":" & $Msg & @LF & _
                                                "wParam" & @TAB & ":" & $wParam & @LF & _
                                                "lParam" & @TAB & ":" & $lParam & @LF & @LF & _
                                                "WM_COMMAND - Infos:" & @LF & _
                                                "-----------------------------" & @LF & _
                                                "Code" & @TAB & ":" & $nNotifyCode & @LF & _
                                                "CtrlID" & @TAB & ":" & $nID & @LF & _
                                                "CtrlHWnd" & @TAB & ":" & $hCtrl)
                     Button_DblClick($nID)
            Case $BN_SETFOCUS
                _DebugPrint("$BN_SETFOCUS")
            Case $BN_KILLFOCUS
                _DebugPrint("$BN_KILLFOCUS")
        EndSwitch
    EndIf
    ; 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   ;==>MY_WM_COMMAND

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • 8 months later...

wow this is nice work.

isn´t this function worth while being adding to the ( #include <GUIConstants.au3> ) ?

maybe like that : if $msg=$button($BN_DOUBLECLICKED) then...

would be very useful

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

hi Lobishomen and others,

how must i alter the code in order to make it work with a label instead of a button, please ?

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

general question:

what am i supposed to do to obtain qualified answers to my questions ?

i said "please", so what ?

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

general question:

what am i supposed to do to obtain qualified answers to my questions ?

i said "please", so what ?

j.

Have patience, some of us work for a living.

#include <GUIConstants.au3>
Opt("MustDeclareVars", 1)

Global Const $DebugIt = 1
;~ Global Const $WM_COMMAND = 0x0111
Global $Hovered = 0
Global $Button, $status, $Label

_Main()

Func _Main()
    Local $x = 48, $y = 88, $msg, $Form2

    $Form2 = GUICreate("Blash", 716, 561, 155, 134, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP))

    $Button = GUICtrlCreateButton("Button Test", 10, 10, 89, 41, $BS_NOTIFY)
    $Label = GUICtrlCreateLabel("Label Test", 10, 60, 120, 22, BitOR($SS_NOTIFY, $SS_SUNKEN, $SS_CENTER))
    
    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
    GUISetState(@SW_SHOW)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        EndSelect
    WEnd
EndFunc   ;==>_Main

Func Button_Click(ByRef $ctrl_id)
;~  _DebugPrint("Button_Click")
EndFunc   ;==>Button_Click

Func Button_DblClick(ByRef $ctrl_id)
;~  _DebugPrint("Button_DblClick")
    MsgBox(0, "Test", "Button_DblClick")
EndFunc   ;==>Button_DblClick

Func Label_Click(ByRef $ctrl_id)
    _DebugPrint("Label_Click")
EndFunc   ;==>Label_Click

Func Label_DblClick(ByRef $ctrl_id)
;~  _DebugPrint("Button_DblClick")
    MsgBox(0, "Test", "Label_DblClick")
EndFunc   ;==>Label_DblClick

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local Const $BN_CLICKED = 0;
    Local Const $BN_PAINT = 1;
    Local Const $BN_HILITE = 2;
    Local Const $BN_PUSHED = $BN_HILITE;
    Local Const $BN_UNHILITE = 3;
    Local Const $BN_UNPUSHED = $BN_UNHILITE;
    Local Const $BN_DISABLE = 4;
    Local Const $BN_DOUBLECLICKED = 5;
    Local Const $BN_DBLCLK = $BN_DOUBLECLICKED;
    Local Const $BN_SETFOCUS = 6;
    Local Const $BN_KILLFOCUS = 7;

    Local Const $STN_CLICKED = 0
    Local Const $STN_DBLCLK = 1
    Local Const $STN_DISABLE = 3
    Local Const $STN_ENABLE = 2

    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    
    If $nID <> 2 Then
        Switch $nID
            Case $Button
                Switch $nNotifyCode
                    Case $BN_CLICKED
                        _DebugPrint("$BN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _
                                "MsgID" & @TAB & ":" & $msg & @LF & _
                                "wParam" & @TAB & ":" & $wParam & @LF & _
                                "lParam" & @TAB & ":" & $lParam & @LF & @LF & _
                                "WM_COMMAND - Infos:" & @LF & _
                                "-----------------------------" & @LF & _
                                "Code" & @TAB & ":" & $nNotifyCode & @LF & _
                                "CtrlID" & @TAB & ":" & $nID & @LF & _
                                "CtrlHWnd" & @TAB & ":" & $hCtrl)
                        Button_Click($nID)
                    Case $BN_PAINT
                        _DebugPrint("$BN_PAINT")
                    Case $BN_PUSHED, $BN_HILITE
                        _DebugPrint("$BN_PUSHED, $BN_HILITE")
                    Case $BN_UNPUSHED, $BN_UNHILITE
                        _DebugPrint("$BN_UNPUSHED")
                    Case $BN_DISABLE
                        _DebugPrint("$BN_DISABLE")
                    Case $BN_DBLCLK, $BN_DOUBLECLICKED
;~                       _DebugPrint("$BN_DBLCLK, $BN_DOUBLECLICKED")
                        _DebugPrint("$BN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _
                                "MsgID" & @TAB & ":" & $msg & @LF & _
                                "wParam" & @TAB & ":" & $wParam & @LF & _
                                "lParam" & @TAB & ":" & $lParam & @LF & @LF & _
                                "WM_COMMAND - Infos:" & @LF & _
                                "-----------------------------" & @LF & _
                                "Code" & @TAB & ":" & $nNotifyCode & @LF & _
                                "CtrlID" & @TAB & ":" & $nID & @LF & _
                                "CtrlHWnd" & @TAB & ":" & $hCtrl)
                        Button_DblClick($nID)
                    Case $BN_SETFOCUS
                        _DebugPrint("$BN_SETFOCUS")
                    Case $BN_KILLFOCUS
                        _DebugPrint("$BN_KILLFOCUS")
                EndSwitch
            Case $Label
                Switch $nNotifyCode
                    Case $STN_CLICKED
;~                       _DebugPrint("$STN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hwnd & @LF & _
;~                                                                  "MsgID" & @TAB & ":" & $Msg & @LF & _
;~                                                                  "wParam" & @TAB & ":" & $wParam & @LF & _
;~                                                                  "lParam" & @TAB & ":" & $lParam & @LF & @LF & _
;~                                                                  "WM_COMMAND - Infos:" & @LF & _
;~                                                                  "-----------------------------" & @LF & _
;~                                                                  "Code" & @TAB & ":" & $nNotifyCode & @LF & _
;~                                                                  "CtrlID" & @TAB & ":" & $nID & @LF & _
;~                                                                  "CtrlHWnd" & @TAB & ":" & $hCtrl)
                        Label_Click($nID)
                    Case $STN_DISABLE
                        _DebugPrint("$STN_DISABLE")
                    Case $STN_ENABLE
                        _DebugPrint("$STN_ENABLE")
                    Case $STN_DBLCLK
;~                       _DebugPrint("$STN_DBLCLK")
                        _DebugPrint("$STN_DBLCLK: " & @LF & "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _
                                "MsgID" & @TAB & ":" & $msg & @LF & _
                                "wParam" & @TAB & ":" & $wParam & @LF & _
                                "lParam" & @TAB & ":" & $lParam & @LF & @LF & _
                                "WM_COMMAND - Infos:" & @LF & _
                                "-----------------------------" & @LF & _
                                "Code" & @TAB & ":" & $nNotifyCode & @LF & _
                                "CtrlID" & @TAB & ":" & $nID & @LF & _
                                "CtrlHWnd" & @TAB & ":" & $hCtrl)
                        Label_DblClick($nID)
                EndSwitch
        EndSwitch
    EndIf
    ; 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   ;==>MY_WM_COMMAND

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

thank you very much.

so do i, working for a living. that's why i only have the night for scripting, and its approaching end is making me impatient :-)

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

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...