stafe Posted August 21, 2007 Share Posted August 21, 2007 (edited) 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 CODEGlobal $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 August 21, 2007 by stafe Link to comment Share on other sites More sharing options...
GaryFrost Posted August 21, 2007 Share Posted August 21, 2007 http://www.autoitscript.com/forum/index.ph...st&p=283836 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
stafe Posted August 22, 2007 Author Share Posted August 22, 2007 Thank you.That works. However if I want to execute the action in the list box by either double clicking or hitting the enter button or clicking an ok button - how is it done?Stafehttp://www.autoitscript.com/forum/index.ph...st&p=283836 Link to comment Share on other sites More sharing options...
smashly Posted August 22, 2007 Share Posted August 22, 2007 Hi , a rough example with your code. There's probably a tidier way to do it.. but here goes.expandcollapse popup#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 More sharing options...
stafe Posted August 22, 2007 Author Share Posted August 22, 2007 Thank you. That is perfect. It works very wellStafeHi , a rough example with your code.There's probably a tidier way to do it.. but here goes.Cheers Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now