pippi Posted November 6, 2006 Posted November 6, 2006 Is it possible to create a button, that triggers through a doubleclick instead of a normal single click? regards, pippi
GaryFrost Posted November 6, 2006 Posted November 6, 2006 expandcollapse popup#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.
pippi Posted November 6, 2006 Author Posted November 6, 2006 Wow, quite some code for a button:) Thanks, ill check it out. Pippi
jennico Posted July 29, 2007 Posted July 29, 2007 (edited) 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 July 29, 2007 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
jennico Posted August 1, 2007 Posted August 1, 2007 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.Don't forget this IP: 213.251.145.96
jennico Posted August 1, 2007 Posted August 1, 2007 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.Don't forget this IP: 213.251.145.96
GaryFrost Posted August 1, 2007 Posted August 1, 2007 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. expandcollapse popup#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.
jennico Posted August 2, 2007 Posted August 2, 2007 (edited) 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 August 2, 2007 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
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