Jump to content

Cannot select list box item via mouse


Recommended Posts

My simple code:

;include constants
#include <GUIConstants.au3>

;initialize GUI height and width
Global $GUIWidth
Global $GUIHeight

$GUIWidth = @DesktopWidth - 200
$GUIHeight = @DesktopHeight - 200

;show splashscreen image
ShowSplashScreen()

;create window
GUICreate("Russian", $GUIWidth, $GUIHeight)

;create category label
$font = "Times New Roman"
GUICtrlCreateLabel ("Pick your category", 70, 50, 170, 70)
GUICtrlSetFont (-1, 16, 700, 0, $font)

;create list box
$categoryListBox = GUICtrlCreateList ("", 70 , 80, 170, 500, $LBS_STANDARD)
GUICtrlSetData(-1, "Greetings")
GUICtrlSetData(-1, "Time")
GUICtrlSetData(-1, "Numbers")
GUICtrlSetData(-1, "Words")

;create command buttons
;Create a "English -> Russian" button
;$ENG2RUS_Btn = GUICtrlCreateButton("English -> Russian", 50, 50, 200, 25)

;Create a "Russian -> English" button
;$RUS2ENG_Btn = GUICtrlCreateButton("Russian -> English", 50, 100, 200, 25)

;show window
GUISetState(@SW_SHOW)

While 1
;after every loop check if the user clicked something in the GUI window
    $msg = GUIGetMsg()

    Select
   
    ;check if user clicked on the close button
        Case $msg = $GUI_EVENT_CLOSE
        ;destroy the GUI including the controls
            GUIDelete()
        ;exit the script
            Exit
        



        Case $msg = $categoryListBox
            $category = GUICtrlRead($categoryListBox)
            
    ;Case $msg = $OK_Btn
        ;MsgBox(64, "New GUI", "You clicked on the OK button!")
      
;Case $msg = $Cancel_Btn
        ;MsgBox(64, "New GUI", "You clicked on the Cancel button!")
         
   EndSelect

WEnd


;shows splashscreen image
Func ShowSplashScreen()
;image path
    $destination = @ScriptDir & "\images\" & "splashscreen.JPG"
;time to display image
    $timeToDisplayImage = 5000
;show image
    SplashImageOn("Splash Screen", $destination, -1, -1, -1, -1, 1)
;wait x amount of time
    Sleep($timeToDisplayImage)
;hide image
    SplashOff()
EndFunc

Ok, I can select the various list items by using the cursor keys fine, each item is selected as soon as I press 'up' for example.

But when I try to select a list item by using the mouse.... a. most of the time it does not respond (does nothing) or b. It works. Basically it just does not work.

Any ideas on why this is?

Thanks

Link to comment
Share on other sites

; ----------------------------------------------------------------------------
;include constants
#include <GUIConstants.au3>

;initialize GUI height and width
Global $GUIWidth
Global $GUIHeight

$GUIWidth = @DesktopWidth - 200
$GUIHeight = @DesktopHeight - 200

;show splashscreen image
ShowSplashScreen()

;create window
GUICreate("Russian", $GUIWidth, $GUIHeight)

;create category label
$font = "Times New Roman"
GUICtrlCreateLabel ("Pick your category", 70, 50, 170)
GUICtrlSetFont (-1, 16, 700, 0, $font)

;create list box
$categoryListBox = GUICtrlCreateList ("", 70 , 80, 170, 500, $LBS_STANDARD)
GUICtrlSetData(-1, "Greetings")
GUICtrlSetData(-1, "Time")
GUICtrlSetData(-1, "Numbers")
GUICtrlSetData(-1, "Words")

;create command buttons
;Create a "English -> Russian" button
;$ENG2RUS_Btn = GUICtrlCreateButton("English -> Russian", 50, 50, 200, 25)

;Create a "Russian -> English" button
;$RUS2ENG_Btn = GUICtrlCreateButton("Russian -> English", 50, 100, 200, 25)

;show window
GUISetState(@SW_SHOW)

While 1
;after every loop check if the user clicked something in the GUI window
    $msg = GUIGetMsg()

    Select
   
   ;check if user clicked on the close button
        Case $msg = $GUI_EVENT_CLOSE
       ;destroy the GUI including the controls
            GUIDelete()
       ;exit the script
            Exit
        



        Case $msg = $categoryListBox
            $category = GUICtrlRead($categoryListBox)
            
   ;Case $msg = $OK_Btn
       ;MsgBox(64, "New GUI", "You clicked on the OK button!")
      
;Case $msg = $Cancel_Btn
       ;MsgBox(64, "New GUI", "You clicked on the Cancel button!")
         
   EndSelect

WEnd


;shows splashscreen image
Func ShowSplashScreen()
;image path
    $destination = @ScriptDir & "\images\" & "splashscreen.JPG"
;time to display image
    $timeToDisplayImage = 5000
;show image
    SplashImageOn("Splash Screen", $destination, -1, -1, -1, -1, 1)
;wait x amount of time
    Sleep($timeToDisplayImage)
;hide image
    SplashOff()
EndFunc

Your label, "Please pick a category"'s height was really big, so it was covering the listbox... It should work now.

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