AutoIt:3.3.9.5 (Os:WIN_7/SP1/X64 OSLang:0409)
Example:
Edited by therks, 08 July 2012 - 12:42 AM.
Posted 22 June 2012 - 11:04 PM
Edited by therks, 08 July 2012 - 12:42 AM.
Posted 07 July 2012 - 09:09 AM
eMyvnE
Posted 07 July 2012 - 10:15 AM
The reason of this problem is that the Label receives the WM_GETTEXT message when we double click on it. To stop this behavior, we can ignore the WM_GETTEXT message when double-clicking operation happens.
To do this, create a new class derived from the Label class and override the WndProc method. In the override method, if the Label has received the WM_LBUTTONDBLCLK message before it receives the WM_GETTEXT message, we ignore the WM_GETTEXT message.
The following is a sample:
class MyLabel:Label
{
int WM_GETTEXT = 0xD;
int WM_LBUTTONDBLCLK = 0x203;
bool doubleclickflag = false;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_LBUTTONDBLCLK)
{
doubleclickflag = true;
}
if (m.Msg == WM_GETTEXT && doubleclickflag)
{
doubleclickflag = false;
return;
}
base.WndProc(ref m);
}
}The reason of this problem is that the Label receives the WM_GETTEXT message when we double click on it. To stop this behavior, we can ignore the WM_GETTEXT message when double-clicking operation happens.Posted 07 July 2012 - 10:19 AM
#include-once #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate('', 150, 100) GUICtrlCreateLabel('Double click me', 5, 5, 100, 20,0x0B) GUICtrlSetState(-1,$GUI_DISABLE) GUISetState() ClipPut('Example') While 1 ToolTip('ClipGet() = ' & ClipGet()) $iGUIGetMsg = GUIGetMsg() Switch $iGUIGetMsg Case $GUI_EVENT_CLOSE ExitLoop Case Else If $iGUIGetMsg > 0 Then ToolTip($iGUIGetMsg & ':' & GUICtrlRead($iGUIGetMsg)) EndIf EndSwitch WEnd
Edited by PhoenixXL, 07 July 2012 - 10:21 AM.
Posted 07 July 2012 - 10:49 AM
#include <GUIConstants.au3> $hGUI = GUICreate('', 150, 100) GUICtrlCreateLabel('Double click me', 5, 5, 100, 20) GUICtrlSetStyle(-1, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() ClipPut('Example') While 1 ToolTip('ClipGet() = ' & ClipGet()) $iGUIGetMsg = GUIGetMsg() Switch $iGUIGetMsg Case $GUI_EVENT_CLOSE ExitLoop Case Else If $iGUIGetMsg > 0 Then ToolTip($iGUIGetMsg & ':' & GUICtrlRead($iGUIGetMsg)) EndIf EndSwitch WEnd
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> OnAutoItExitRegister("_AutoExit") Global $fDblClk = False ; Register callback function and obtain handle to _New_WndProc $hNew_WndProc = DllCallbackRegister("_New_WndProc", "int", "hwnd;uint;wparam;lparam") ; Get pointer to _New_WndProc Local $pNew_WndProc = DllCallbackGetPtr($hNew_WndProc) $hGUI = GUICreate('', 150, 100) $clabel = GUICtrlCreateLabel('Double click me', 5, 5, 100, 20) GUISetState() ; Store old WndProc $pOld_WndProc = _Label_SubClass(GUICtrlGetHandle($cLabel), $pNew_WndProc) ClipPut('Example') While 1 ToolTip('ClipGet() = ' & ClipGet()) $iGUIGetMsg = GUIGetMsg() Switch $iGUIGetMsg Case $GUI_EVENT_CLOSE ExitLoop Case Else If $iGUIGetMsg > 0 Then ToolTip($iGUIGetMsg & ':' & GUICtrlRead($iGUIGetMsg)) EndIf EndSwitch WEnd Func _New_WndProc($hWnd, $iMsg, $wParam, $lParam) ; Set DBLCLK flag if one detected If $iMsg = 0x203 Then $fDblClk = True EndIf ; If GETTEXT message sent If $iMsg = 0x000D Then ; WM_GETTEXT ; Check state of DBLCLK flag If $fDblClk Then ; Clear flag $fDblClk = False ; Ignore specific message from subclassed control Return 0 Else ; Pass message to original WindowProc Return _WinAPI_CallWindowProc($pOld_WndProc, $hWnd, $iMsg, $wParam, $lParam) EndIf Else ; Pass other messages to original WindowProc Return _WinAPI_CallWindowProc($pOld_WndProc, $hWnd, $iMsg, $wParam, $lParam) EndIf EndFunc ;==>_New_WndProc Func _Label_SubClass($hWnd, $pNew_WindowProc) Local $iRes = _WinAPI_SetWindowLong($hWnd, -4, $pNew_WindowProc) If @error Then Return SetError(1, 0, 0) If $iRes = 0 Then Return SetError(1, 0, 0) Return $iRes EndFunc ;==>_Label_SubClass Func _AutoExit() ; Unsubclass the label _Label_SubClass(GUICtrlGetHandle($cLabel), $pOld_WndProc) ; Now free UDF created WndProc DllCallbackFree($hNew_WndProc) EndFunc
Edited by Melba23, 07 July 2012 - 11:05 AM.
Added code
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
Posted 07 July 2012 - 12:58 PM
#include <GUIConstants.au3> $hGUI = GUICreate('', 150, 100) GUICtrlCreateLabel('Double click me', 5, 5, 100, 20,0) ;GUICtrlSetStyle(-1, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() ClipPut('Example') While 1 ToolTip('ClipGet() = ' & ClipGet()) $iGUIGetMsg = GUIGetMsg() Switch $iGUIGetMsg Case $GUI_EVENT_CLOSE ExitLoop Case Else If $iGUIGetMsg > 0 Then ToolTip($iGUIGetMsg & ':' & GUICtrlRead($iGUIGetMsg)) EndIf EndSwitch WEnd
#include-once #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate('', 150, 100) GUICtrlCreateLabel('Double click me', 5, 5, 100, 20,0x0B) GUICtrlSetState(-1,$GUI_DISABLE) GUISetState() ClipPut('Example') While 1 ToolTip('ClipGet() = ' & ClipGet()) $iGUIGetMsg = GUIGetMsg() Switch $iGUIGetMsg Case $GUI_EVENT_CLOSE ExitLoop Case Else If $iGUIGetMsg > 0 Then ToolTip($iGUIGetMsg & ':' &GUICtrlRead($iGUIGetMsg)) EndIf EndSwitch WEnd
Edited by PhoenixXL, 07 July 2012 - 01:04 PM.
Posted 08 July 2012 - 12:38 AM
Edited by therks, 08 July 2012 - 12:53 AM.
Posted 08 July 2012 - 11:49 AM
CS_DBLCLKS style issue again.Stop double click from copying label contents to clipboard?
#include <GUIConstants.au3> #include <WinAPIEx.au3> $hGUI = GUICreate('', 150, 100) $cLbl = GUICtrlCreateLabel('Double click me', 5, 5, 100, 20) _Remove_CS_DBLCLKS(-1) GUISetState() ClipPut('Example') While 1 ToolTip('ClipGet() = ' & ClipGet()) $iGUIGetMsg = GUIGetMsg() Switch $iGUIGetMsg Case $GUI_EVENT_CLOSE ExitLoop ;Case $cLbl ;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $cLbl = ' & $cLbl & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Case Else If $iGUIGetMsg > 0 Then ToolTip($iGUIGetMsg & ':' & GUICtrlRead($iGUIGetMsg)) EndIf EndSwitch WEnd Func _Remove_CS_DBLCLKS($Ctrl) ;Author; rover 2k9 - updated 2k12 ;Requires WinAPIEx.au3 ; ;Removes the CS_DBLCLKS style from Static or Button class controls ;Fixes the issue of slow response(lag) with Labels or colour Buttons when rapidly clicking with the mouse ; ;NOTE: Run one time only on the first control created in your script process with the control class you want to remove this style from ;All subsequently created controls of the Static or Button class for the current process will not have the CS_DBLCLKS style ;http://www.autoitscript.com/forum/topic/90309-why-the-huge-performance-hit/page__view__findpost__p__663443 If Not IsHWnd($Ctrl) Then $Ctrl = GUICtrlGetHandle($Ctrl) If Not IsHWnd($Ctrl) Then Return SetError(1, 0, 0) EndIf If Not IsDeclared("GCL_STYLE") Then Local Const $GCL_STYLE = -26 If Not IsDeclared("CS_DBLCLKS") Then Local Const $CS_DBLCLKS = 0x8 Local $ClassStyle = _WinAPI_GetClassLongEx($Ctrl, $GCL_STYLE) If @error Or Not $ClassStyle Then Return SetError(2, @error, 0) Local $NewStyle = BitAND($ClassStyle, BitNOT($CS_DBLCLKS)) _WinAPI_SetClassLongEx($Ctrl, $GCL_STYLE, $NewStyle) If @error Then Return SetError(3, @error, 0) Local $ClassChk = _WinAPI_GetClassLongEx($Ctrl, $GCL_STYLE) If @error Or Not $ClassChk Then Return SetError(4, @error, 0) If $ClassStyle = $ClassChk Then Return SetError(5, 0, 0) Return SetError(0, 0, 1) EndFunc ;==>_Remove_CS_DBLCLKS
0 members, 0 guests, 0 anonymous users