Sign in to follow this  
Followers 0
supersonic

WM_NOTIFY on edit control???

12 posts in this topic

#1 ·  Posted (edited)

Hi!

I'm trying to trigger single and double clicks in edit controls...

No luck so far... Is there a way to handle it with the help of $WM_NOTIFY?

Here's some sample code:

GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam ; $ilParam
    ; <...>
    Local   $hWndFrom, _
            $hWndCtrl = $aTab2E0, _
            $iCode, _
            $tInfo, _
            $tNMHDR
    ; <...>
    If Not IsHWnd($aTab2E0) Then $hWndCtrl = GUICtrlGetHandle($aTab2E0)
    ; <...>
    $tNMHDR     = DllStructCreate($tagNMHDR, $ilParam)
    $iCode      = DllStructGetData($tNMHDR, "Code")
    $hWndFrom   = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    ; <...>
    Switch $hWndFrom
        Case $hWndCtrl
            Switch $iCode
                Case $NM_DBLCLK
                    Switch $hWndFrom
                        Case $hWndCtrl
                            MsgBox(0, "", "test", 0)
                    EndSwitch
            EndSwitch
    EndSwitch
    ; <...>
    Return $GUI_RUNDEFMSG
EndFunc

Anyone any idea?

Greets,

-supersonic.

Edited by supersonic

Share this post


Link to post
Share on other sites



Seems like the control suppresses this message by handling the message and not calling the default window procedure.

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

If Not IsDeclared("WM_LBUTTONDBLCLK") Then Global Const $WM_LBUTTONDBLCLK = 0x0203

Local $hGUI = GUICreate("Title", 200, 200)
Local $Edit = GUICtrlCreateEdit("Text", 20, 20, 160, 160)
Local $hEdit = GUICtrlGetHandle($Edit)
Local $hFunc, $hOldProc

$hFunc = DllCallbackRegister("_EditProc", "lresult", "hwnd;uint;wparam;lparam")
$hOldProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hFunc))
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()
DllCallbackFree($hFunc)
Exit

Func _EditProc($hWnd, $iMsg, $iwParam, $ilParam)
    If $iMsg = $WM_LBUTTONDBLCLK Then _
        ConsoleWrite("Left double click" & @CRLF)
        
    Return _WinAPI_CallWindowProc($hOldProc, $hEdit, $iMsg, $iwParam, $ilParam)
EndFunc

..until you find a workaround.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you. I'm getting an error message when trying to run the script:

M:\test.au3 (12) : ==> Badly formatted "Func" statement.:

$hFunc = DllCallbackRegister("_EditProc", "lresult", "hwnd;uint;wparam;lparam")

Currently I'm using AutoIt 3.3.0.0. Any idea?

Seems like the control suppresses this message by handling the message and not calling the default window procedure.

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

If Not IsDeclared("WM_LBUTTONDBLCLK") Then Global Const $WM_LBUTTONDBLCLK = 0x0203

Local $hGUI = GUICreate("Title", 200, 200)
Local $Edit = GUICtrlCreateEdit("Text", 20, 20, 160, 160)
Local $hEdit = GUICtrlGetHandle($Edit)
Local $hFunc, $hOldProc

$hFunc = DllCallbackRegister("_EditProc", "lresult", "hwnd;uint;wparam;lparam")
$hOldProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hFunc))
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()
DllCallbackFree($hFunc)
Exit

Func _EditProc($hWnd, $iMsg, $iwParam, $ilParam)
    If $iMsg = $WM_LBUTTONDBLCLK Then _
        ConsoleWrite("Left double click" & @CRLF)
        
    Return _WinAPI_CallWindowProc($hOldProc, $hEdit, $iMsg, $iwParam, $ilParam)
EndFunc

..until you find a workaround.

Edited by supersonic

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Sorry, I'm 3.3.0.0 so convert the necessary error to your version. 3.3.1.3?

Edit:

(\/ )
(oO )
(")(")
Edited by Authenticity

Share this post


Link to post
Share on other sites

Okay... I forgot to add the function called "_EditProc()"...

The script starts but always ends with this:

!>21:31:02 AutoIT3.exe ended.rc:-1073741819

Share this post


Link to post
Share on other sites

Okay... I forgot to add the function called "_EditProc()"...

The script starts but always ends with this:

!>21:31:02 AutoIT3.exe ended.rc:-1073741819

Works ok for me using XP and AutoIt 3.3.00 or Beta 3.3.1.3.

What OS and AutoIt versions are you using supersonic?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

AI V3.3.0.0 or 3.3.1.3. Windows XP Prof. (Admin mode).

Works ok for me using XP and AutoIt 3.3.00 or Beta 3.3.1.3.

What OS and AutoIt versions are you using supersonic?

Share this post


Link to post
Share on other sites

AI V3.3.0.0 or 3.3.1.3. Windows XP Prof. (Admin mode).

I've tried on XP Home and Professional and no problem so I don't know why it doesn't work for you.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Ohhh... Now it is working... Was my fault... :)

Thank for your help...

I've tried on XP Home and Professional and no problem so I don't know why it doesn't work for you.

Share this post


Link to post
Share on other sites

The sample provided Authenticity works pretty well for double clicks...

Is there a way to modify it for single clicks?

Share this post


Link to post
Share on other sites

Just process the $WM_LBUTTONDOWN also. The problem is that $WM_LBUTTONDOWN or $WM_LBUTTONUP are posted in pairs and twice each prior to a $WM_LBUTTONDBLCLK message, I guess. So you should implement a sophisticated mechanism to differentiate a one click event from double click event. You can achieve that by first reading the value of this function to determine the what is the interval that a sequence of mouse clicks are considered a double click, then work with TimerInit() and TimerDiff() with global variables, as of time being.

Share this post


Link to post
Share on other sites

Thank you so far for your help!

Just process the $WM_LBUTTONDOWN also. The problem is that $WM_LBUTTONDOWN or $WM_LBUTTONUP are posted in pairs and twice each prior to a $WM_LBUTTONDBLCLK message, I guess. So you should implement a sophisticated mechanism to differentiate a one click event from double click event. You can achieve that by first reading the value of this function to determine the what is the interval that a sequence of mouse clicks are considered a double click, then work with TimerInit() and TimerDiff() with global variables, as of time being.

Share this post


Link to post
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
Sign in to follow this  
Followers 0