Jump to content

WM_NOTIFY on edit control???


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 weeks later...

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.

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