Sign in to follow this  
Followers 0
52AT

A problem about MY_WM_COMMAND function

8 posts in this topic

See the following code, double click the n.notepad in the listbox to open it and don't close it,

then single click any item in the listbox, immediately, another notepad was opened.

Why? and how solve it?

please help me, thanks

Code:

#include <GUIConstants.au3>

#NoTrayIcon

Global Const $WM_COMMAND = 0x0111

Global Const $LBN_SELCHANGE = 1

Global Const $LBN_DBLCLK = 2

Opt ("RunErrorsFatal", 0 )

$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)

GUISetIcon("D:\005.ico")

$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)

GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")

$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)

GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

GUISetState(@SW_SHOW)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

$nNotifyCode = BitShift($wParam, 16)

$nID = BitAnd($wParam, 0x0000FFFF)

$hCtrl = $lParam

If $nID = $GCCList Then

Switch $nNotifyCode

Case $LBN_DBLCLK

If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')

Return 0

EndSwitch

EndIf

EndFunc

Share this post


Link to post
Share on other sites



HI,

does it have to be done with GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") or would another solution also okay?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

So

who has another solution to it? if had, please help me to modify the above code, so that i can cxecute some program through double clicking the listboxitem, but would not cxecute the program if i double clicked any area beyond the listbox

Share this post


Link to post
Share on other sites

So

who has another solution to it? if had, please help me to modify the above code, so that i can cxecute some program through double clicking the listboxitem, but would not cxecute the program if i double clicked any area beyond the listbox

Far as I can tell, it doesn't work correctly when using a run command, at least this run command.

As a test I commented out the line with the run command, made a line that only sent output to the console (Using SciTE), at this point the double click worked as it should

Here's the test script

#include <GUIConstants.au3>
#NoTrayIcon
Global Const $WM_COMMAND = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK = 2

Opt("RunErrorsFatal", 0)
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GUICtrlCreateList("", 20, 70, 200, 200)
GUICtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam
    If $nID = $GCCList Then
        Switch $nNotifyCode
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'n.notepad' Then ConsoleWrite(_DebugHeader("$LBN_DBLCLK"))
;~              If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
        EndSwitch
    EndIf
EndFunc   ;==>MY_WM_COMMAND

Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
EndFunc   ;==>_DebugHeader

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Share this post


Link to post
Share on other sites

Hi,

question could be why a listbox? Why not using a button or some other control?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

question could be why a listbox? Why not using a button or some other control?

So long,

Mega

I think I can make the interface more succinct in this way

Since MY_WM_COMMAND doesn't work correctly when using a run command, who has other codes can make me cxecute some program through double clicking the listboxitem, but would not cxecute the program if i double clicked any area beyond the listbox

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I think I can make the interface more succinct in this way

Since MY_WM_COMMAND doesn't work correctly when using a run command, who has other codes can make me cxecute some program through double clicking the listboxitem, but would not cxecute the program if i double clicked any area beyond the listbox

I would suggest looking in the Search Option for "Double Click" in titles only... That's always the best place start before posting a question like in the last post.

http://www.autoitscript.com/forum/index.ph...te=Double+Click

Edit:

Now you will see more than one option.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

The problem with WM_COMMAND has brought to the devloper(s) attention and added to the list of of things to look at.

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

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