Jump to content

capturing a double-click


stafe
 Share

Recommended Posts

I am just new to this and have only written a few small pieces of code.

I have written a small program that produces a list box and I can select the item by clicking on it and either clicking the okay button or pressing the enter button. I want to also be able to select an item by double-clicking on it. Could someone please tell me how it is done?

an example of the code that I have used is

CODE
Global $mydata2

GUICreate("Insert Pathology Tests", 210, 300)

GUISetIcon(@SystemDir & "\mspaint.exe", 0)

$testSelected=GuiCtrlCreateList("", 5, 60, 200, 200)

GuiCtrlSetData(-1, "1 Lipid Review|2 Diabetes Review|3 Thyroid Tests", "1 Lipid Review")

$OK_Btn = GUICtrlCreateButton("OK", 20, 21, 70, 25)

$Cancel_Btn = GUICtrlCreateButton("Cancel", 110, 21, 70, 25)

GUISetState()

While 1

$msg = GUIGetMsg()

$mydata = GUICtrlRead($testSelected)

Select

case $mydata = "1 Lipid Review"

$mydata2= "tests 1"

case $mydata = "2 Diabetes Review"

$mydata2= "tests 2"

case $mydata = "3 Thyroid Tests"

$mydata2= "tests 3"

EndSelect

Select

Case $msg = $OK_Btn or _IsPressed ("0D")

GUISetState (@SW_MINIMIZE)

ExitLoop

Case $msg = $Cancel_Btn Or $msg = $GUI_Event_Close

Exit

EndSelect

WEnd

Send($mydata2)

Exit

Thanks

Stafe

Edited by stafe
Link to comment
Share on other sites

Hi , a rough example with your code.

There's probably a tidier way to do it.. but here goes.

#include <GUIConstants.au3>
#include <misc.au3>

Global Const $WM_COMMAND = 0x0111
Global $mydata2, $DBLCLK

GUICreate("Insert Pathology Tests", 210, 300)
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

$testSelected = GuiCtrlCreateList("", 5, 60, 200, 200)
GuiCtrlSetData(-1, "1 Lipid Review|2 Diabetes Review|3 Thyroid Tests|4 Dementia Screen|5 STD Screen|6 Hepatitis Screen|7 Antenatal Screen", "1 Lipid Review")

$OK_Btn = GUICtrlCreateButton("OK", 20, 21, 70, 25)
$Cancel_Btn = GUICtrlCreateButton("Cancel", 110, 21, 70, 25)

GUISetState()

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

While 1
    $msg = GUIGetMsg()
    $mydata = GUICtrlRead($testSelected)
    Select
        Case $msg = $OK_Btn or _IsPressed ("0D") Or $DBLCLK = 1
            GUISetState (@SW_MINIMIZE)
            ExitLoop
        Case $msg = $Cancel_Btn Or $msg = $GUI_Event_Close
            Exit
        case $mydata = "1 Lipid Review"
            $mydata2= "tests 1"
        case $mydata = "2 Diabetes Review"
            $mydata2= "tests 2"
        case $mydata = "3 Thyroid Tests"
            $mydata2= "tests 3"
        case $mydata = "4 Dementia Screen"
            $mydata2= "tests 4"
        case $mydata = "5 STD Screen"
            $mydata2= "tests 5"
        case $mydata = "6 Hepatitis Screen"
            $mydata2= "tests 6"
        case $mydata = "7 Antenatal Screen"
            $mydata2= "tests 7"
        case $mydata = "8 GTT/Insulin"
            $mydata2= "tests 8"
    EndSelect
WEnd

Send($mydata2)

Exit

Func MY_WM_COMMAND($hWnd, $MsgID, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAnd($wParam, 0x0000FFFF)
    Local Const $LBN_DBLCLK = 2
    Switch $nID
        Case $testSelected
            Switch $nNotifyCode
                Case $LBN_DBLCLK
                    $DBLCLK = 1
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Cheers

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