crazyjts

Help with keeping cursor in an input field after enabling a button

4 posts in this topic

Hi all,

I have the following snippet of code that sort of works but isn’t doing exactly what I want.

expand popup
#include <GuiConstants.au3>

Global $gGUIWidth = 250
Global $gGUIHeight = 150

Initial()

Func Initial()

   ; Create the initial GUI
   $BaseGUI = GUICreate("", $gGUIWidth, $gGUIHeight, -1, -1, -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)

   GUISetState(@SW_SHOW, $BaseGUI)

   ; Create a field for entering the current value
   GUICtrlCreateLabel("Current Value:",  10, 10)
   $CurrentValueFld = GUICtrlCreateInput("", 10, 40, 215, 20, $ES_NUMBER)
   GUICtrlSetState($CurrentValueFld, $GUI_FOCUS)

   ; Create Calculate button
   Local $CalculateButton = GUICtrlCreateButton("Calculate", 10, 70, 75, 25)
   GUICtrlSetState($CalculateButton, $GUI_DISABLE)

   ; Watch the value field and determine if the value is greater than 0 and if so, enable Calculate button
   $i = 0
   Do
      $CurrentValue = GUICtrlRead($CurrentValueFld)
      If $CurrentValue > 0 Then
         GUICtrlSetState($CalculateButton, $GUI_ENABLE + $GUI_FOCUS)
         $i = 1
      EndIf
   until $i = 1

   ;Loop until the user exits and check for ESC, "X", or Begin button
   While 1
      $InitialGUIMsg = GUIGetMsg()
      If $InitialGUIMsg = $GUI_EVENT_CLOSE Then
         Exit
      EndIf
   WEnd
EndFunc

 

I want to be able to:

  1.   Start with focus in the value field (it is doing this now)
  2.  Allow for more than one digit to be entered into the field (it is sort of doing this now but I have to bring focus back to the field)
  3. Enable the Calculate button and give focus to it once a value is entered into the value field (it is doing this now) but keep the cursor in the value field so the more digits can be entered (it is not doing this now)
  4. Be able to hit ESC or “X” to close the dialog at any time (this only works after I enter a digit in the value field

Basically, I want to be able to allow the user to enter one or more digits and hit ENTER or SPACE (while the cursor is still in the value field) to push the Calculate button.  I assume I need to bring focus to the button but maybe I don't and can get away with assigning hotkeys for ENTER and SPACE to push the Calculate button while keeping focus in the value field.

If you could, please add comments in your code as to what the changes are doing if they aren't obvious to a noobish programmer.  

Thanks for any help you can offer on this.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

No need to continue to press the calc button, you could just update the value every time the input is altered.

#include <GuiConstants.au3>
#include <WindowsConstants.au3>

Global $gGUIWidth = 250
Global $gGUIHeight = 150
; Good idea to declare your variables used for the GUI has global, so there's access to them from other functions
Global $BaseGUI = GUICreate("", $gGUIWidth, $gGUIHeight, -1, -1, -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)

; Create a field for entering the current value
Global $CurrentValueFld = GUICtrlCreateInput("", 10, 40, 215, 20, $ES_NUMBER)

; Create Calculate button
Local $CalculateButton = GUICtrlCreateButton("Calculate", 10, 70, 75, 25)
Global $lblValue = GUICtrlCreateLabel("Current Value:", 10, 10, 230)

; Sett he states of your buttons
GUICtrlSetState($CalculateButton, $GUI_DISABLE)
GUICtrlSetState($CurrentValueFld, $GUI_FOCUS)
GUISetState(@SW_SHOW, $BaseGUI)

; Register the WM_COMMAND for this GUI, certain codes from the Windows OS will be sent to the GUI when it is being used, WM_COMMAND is one of these codes
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

While (True)
    ; Use Local, Dim, or Global to declare your variables, good practice!
    Local $InitialGUIMsg = GUIGetMsg()
    Switch ($InitialGUIMsg)
        Case $GUI_EVENT_CLOSE
            GUIDelete($BaseGUI)
            Exit 0
        Case $CalculateButton
            GUICtrlSetData($lblValue, "Current Value: " & GUICtrlRead($CurrentValueFld))
    EndSwitch
WEnd

; The WM_COMMAND Function, these will capture certain commands sent from the Windows OS!
Func WM_COMMAND($hWndFrom, $iMsg, $wParam, $lParam)
    #forceref $hWndFrom, $wParam
    ; The $wParam holds the ID of the control that has focus and code that control is sending
    Local $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    Local $iCode = BitShift($wParam, 16) ; Hi Word

    ; Switch based on the GUI that has focus, good practice to use this even if you only have one GUI
    Switch ($hWndFrom)
        Case $BaseGUI   ; Your $BaseGUI has focus
            ; Switch based on the control ID
            Switch ($iIDFrom)
                Case $CurrentValueFld ; The input box is sending a code
                    ; Switch based on the code your input box is sending
                    Switch ($iCode)
                        Case $EN_CHANGE ; The input box is sending the changing code, the user is adding, or removing, stuff from the input box
                            ; Update your label with the current input value
                            GUICtrlSetData($lblValue, "Current Value: " & GUICtrlRead($CurrentValueFld))
                            ; Set the state of your button (now obsolete)
                            GUICtrlSetState($CalculateButton, $GUI_ENABLE)
                    EndSwitch
            EndSwitch
    EndSwitch

    ; Return the default message, there were no errors
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Since your input only accepts numbers you won't be able to do any math (unless you do it on your own) but if you want to add the ability to calculate an expression use

Execute(Expression)

Ex. Execute($input_data)
Local $input_date = "32+4+10/2"

 

Edited by InunoTaishou

Share this post


Link to post
Share on other sites

try this

#include <GuiConstants.au3>

Global $gGUIWidth = 250
Global $gGUIHeight = 150
Global $BaseGUI = GUICreate("", $gGUIWidth, $gGUIHeight, -1, -1, -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)

; Create a field for entering the current value
GUICtrlCreateLabel("Current Value:", 10, 10)
Global $CurrentValueFld = GUICtrlCreateInput("", 10, 40, 215, 20, $ES_NUMBER)
GUICtrlSetState($CurrentValueFld, $GUI_FOCUS)

; Create Calculate button
Local $CalculateButton = GUICtrlCreateButton("Calculate", 10, 70, 75, 25)
;~ GUICtrlSetState($CalculateButton, $GUI_DISABLE)

; Hot keys Set
Global $AcceptESC = GUICtrlCreateDummy() ;press ESC to exit
Global $AcceptEnter = GUICtrlCreateDummy() ;press ENTER to Calculate
Dim $AccelKeys[2][2] = [["{ENTER}", $AcceptEnter], ["{ESC}", $AcceptESC]]
GUISetAccelerators($AccelKeys)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($BaseGUI)
            Exit 0
        Case $AcceptESC
            GUIDelete($BaseGUI)
            Exit 0
        Case $CalculateButton
            If GUICtrlRead($CurrentValueFld) > 1 Then
                MsgBox(262144, "", "input reads " & GUICtrlRead($CurrentValueFld))
            EndIf
        Case $AcceptEnter
            If GUICtrlRead($CurrentValueFld) > 1 Then
                MsgBox(262144, "", "input reads " & GUICtrlRead($CurrentValueFld))
            EndIf
    EndSwitch
    Sleep(10)
WEnd

 

Share this post


Link to post
Share on other sites

Thank you UnunoTaisho and Deye,  your solutions helped.

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

  • Similar Content

    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys this is my gui and i need the numeric value typed in the highlighted  inputbox. if this value is greater than 1 i need to perform some operations
      \
       
      Here is the summary about that field which i got from wininfo tool

      i tried writing the code as shown below.. but the msgbox is popping up empty value..when the same code is pasted under some button action i am able to access the value present in the field..but when placed alone as written in the attached script i am unable to fetch it... 

      here i am using the valu present in the field

      can you guys tell me what's wrong??? or how can i get that value?
       
      My_GUI.au3

    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      in need the path/text present int above shown input box to be copied or retrieved into a variable .. how can i do that?
       
      Thanks
       
    • Jibberish
      By Jibberish
      I am having difficulties getting updated results from GUICtrlCreateInput. I wrote a small script to demonstrate what I am trying to do.
      This script reads a text file into an array and displays the Name and Number from the text file.
      The user can check a name and change the number, and the results are displayed in _ArrayDisplay.
      Only the Checked names are displayed in their original position. This is necessary for future
      plumbing.
      The problem with this script is the original number is returned, not the changed number. I cannot
      figure out how to get the updated number to be displayed.
      ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; This script reads a text file into an array and displays the Name and Number from the text file. ; The user can check a name and change the number, and the results are displayed in _ArrayDisplay. ; Only the Checked names are displayed in their original position. This is necessary for future ; plumbing. ; ; The problem with this script is the original number is returned, not the changed number. I cannot ; figure out how to get the updated number to be displayed. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include-once #include <MsgBoxConstants.au3> #include <array.au3> #include <Date.au3> #include <WinAPIFiles.au3> #include <AutoItConstants.au3> #include <Misc.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Local $iMax = 6 ;Default number of Videos - 1 for the array counter Dim $aTextFile[$iMax][2] ; [start with 5 entries][Name, Number] Don't get confused! [Row][Column] Local $i = 0 Local $iLeft = 30 Local $iTop = 30 Local $sName Local $sNumber Local $aArray Local $iMaxCol = 5 Local $iRow = 0 Local $iCol = 0 Local $aNumberCount[$iMaxCol][2] $aArray1 = ReadFile() $aNamesNumbers = DisplayNames($aArray1) _ArrayDisplay($aNamesNumbers) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; ReadFile() places the contents of the NameNumber.txt file in an array ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func ReadFile() Local $sFileData = @ScriptDir & "\NameNumber.txt" Local $iStrReturn = 0 Local $aArrayFile Local $aTextFile[$iMaxCol][2] Local $aName Local $sCheckBox1 Const $iL = 10 ; Count from Left for GUI so all buttons line up Local $sFill Local $iA = 0, $iN = 0 ; Put the Names into an Array _FileReadToArray($sFileData, $aArrayFile) For $iA = 0 To $aArrayFile[0] ; Step through the array looking for Names If StringInStr($aArrayFile[$iA], "Name:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next $iCol = 1 $iRow = 0 $sFill = "" For $iA = 1 To $aArrayFile[0] ; Step through the array looking for Numbers If StringInStr($aArrayFile[$iA], "Number:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next Return $aTextFile EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the Name and Number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayNames($aArray1) Local $aName[$iMax] Local $aNumbers[$iMax] $iMMCount = UBound($aArray1) $iMMCount -=1 Local $iWidth = 300 Local $iLength = 300;$iMMCount * 30 GUISetFont(12) $hGUI = GUICreate("Edit / Update Number Test", $iWidth, $iLength, -1, -1) GUICtrlCreateLabel(" Name Number",1,5) ;$iTop += 30 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display Name with a Checkbox. Only Checked Names should be saved. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For $i = 0 to $iMMCount Step 1 $sNameText = $aArray1[$i][0] $iNameLength = StringLen($sNameText) $aName[$i] = GUICtrlCreateCheckbox($sNameText,$iLeft, $iTop) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the number from the text file below each name. Allow the user to change the number and display the ; new number. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iLeft = 60 GUIStartGroup() $iTop = 28 For $i = 0 to $iMMCount Step 1 $sNumberText = $aArray1[$i][1] $aNumberCount[$i][1] = $sNumberText $aNumberCount[$i][0] = GUICtrlCreateInput($sNumberText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO) GUICtrlSetPos($aNumberCount[$i][0],200) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Read the checked names and (possibly updated) number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iMMCount = UBound($aNumberCount) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedNameNumber[$iMMCount][2] $iLeft = 30 Local $idCloseGUI = GUICtrlCreateButton("Close",$iLeft, $iTop) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCloseGUI For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aName[$i]) Case $GUI_CHECKED $aCheckedNameNumber[$i][0] = $aArray1[$i][0] Case $GUI_UNCHECKED EndSwitch Switch GUICtrlRead($aNumberCount[$i][0]) Case $aCheckedNameNumber[$i][1] = GUICtrlRead($aNumberCount[$i][1]) EndSwitch Next ExitLoop EndSwitch WEnd For $i = 0 to $iMMNewCount step 1 GUICtrlRead($aNumberCount[$i][0]) If $aCheckedNameNumber[$i][0] <> "" Then $aCheckedNameNumber[$i][1] = $aNumberCount[$i][1] EndIf Next GUIDelete($hGUI) Return $aCheckedNameNumber EndFunc This is the text file I am reading. If you want to try this out put the NameNumber.txt file in your script directory. It's attached to the post.
      * This is a dummy file with a Name and Number * The only purpose of this file is to read the updated Number. Name:Taggart Number:916 Name:Mongo Number:90 Name:Hedley Lamarr Number:22 Name:Bart Number:9999 Name:The Waco Kid Number:2244 If I change the number, the original number is displayed at the end, not the updated/modified number. I need the modified number to be displayed.
      Thanks in advance for any assistance!
      Jibberish
      NameNumber.txt
    • Daka
      By Daka
      Global $l = GUICtrlCreateInput("3", 16, 48, 25, 22, $ES_NUMBER) Global $p = GUICtrlCreateInput("3", 56, 48, 25, 22, $ES_NUMBER) $go = GUICtrlCreateButton("Start", 136, 48, 83, 25) Global $m = GUICtrlCreateInput("1", 96, 48, 25, 22, $ES_NUMBER) Case $go $l = Number(GUICtrlRead($l)) $p = Number(GUICtrlRead($p)) $m = Number(GUICtrlRead($m)) Then I say consolewrite:
      ConsoleWrite(" l: " & $l & " p: " & $p & " m: " & $m & @LF); And first time when I hit Start ($go) button it gives me default numbers and works fine
      l: 3 p: 3 m: 1 But then I hit Start again and no need to change the numbers in input it gives me:
      l: 68 p: 68 m: 0 Then I hit again Start and this is result:
      l: 0 p: 0 m: 0 from this moment it is all the time 0 (zero) so what could be this?
    • Jewtus
      By Jewtus
      I have been trying to figure out how to get my GUI to do what I want. I am including sample code below that has what I'm working with.
       
      Essentially, what I want is for 4 list views to control the visibility and the ability to change data on a sub GUI. The primary gui has the 4 list views and a tab control (as well as 3 tabs). I want to be able to click on the first list view and have it activate the first tab and allow the values to be changed (the example only has a label). When the 2nd list view is clicked, I want it to disable the first tab and enable the 2nd tab for editing. When the 3rd list view is clicked, I want the 3rd tab to be activated and editable, and when the 4th list view is clicked, I want all tabs to be visible but not editable. Preferably, I'd like to have the 2nd and 3rd tab hidden if the first list view is selected, but I'll settle for it just being disabled.
       
      Can anyone point out what I'm doing wrong? The disable commands I have before any of the case statements don't seem to do anything and I'm struggling to figure out how to tweak this to achieve what I'm looking for.
       
      Here is my code:
      #include <WindowsConstants.au3> ; $WS_Maximizebox #include <GUICombobox.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Entry() Func Entry() Local $riskID Global $aGUIChildren[3], $labArea[3] Global $RiskGUI = GUICreate("Entry", 960, 500) GUICtrlSetFont(-1, 20, 400, 0, "Times New Roman") $iStart = GUICtrlCreateDummy() global $idRisksFirst = GUICtrlCreateListView("", 16, 48, 161, 97) global $idRisksSecond = GUICtrlCreateListView("", 16, 152, 161, 97) global $idRisksThird = GUICtrlCreateListView("", 16, 256, 161, 97) global $idRisksFinal = GUICtrlCreateListView("", 16, 360, 161, 97) $iEnd = GUICtrlCreateDummy() local $testVals[3][3]=[[1,2,3],[1,2,3],[1,2,3]] For $i = $iStart To $iEnd _GUICtrlListView_AddColumn($i,"ID",25) _GUICtrlListView_AddColumn($i,"Type",70) _GUICtrlListView_AddColumn($i,"Entered By",65) Next _GUICtrlListView_AddArray($idRisksFirst,$testVals) _GUICtrlListView_AddArray($idRisksSecond,$testVals) _GUICtrlListView_AddArray($idRisksThird,$testVals) _GUICtrlListView_AddArray($idRisksFinal,$testVals) GUIRegisterMsg($WM_NOTIFY, "LV_NOTIFY") $newFirst = GUICtrlCreateButton("New", 183, 78, 27, 25) $newSecond = GUICtrlCreateButton("New", 183, 190, 27, 25) $btnRefresh = GUICtrlCreateButton("Refresh", 844, 96, 75, 25) Global $Tabs = GUICtrlCreateTab(216, 48, 577, 440) $tab1=GUICtrlCreateTabItem("First") GUICtrlSetState($tab1,$GUI_HIDE) $tab2=GUICtrlCreateTabItem("Second") GUICtrlSetState($tab2,$GUI_HIDE) $tab3=GUICtrlCreateTabItem("Final") GUICtrlSetState($tab3,$GUI_HIDE) $aGUIChildren[0]=SubGui($aGUIChildren,0,True) $aGUIChildren[1]=SubGui($aGUIChildren,1,True) $aGUIChildren[2]=SubGui($aGUIChildren,2,True) GUISetState(@SW_SHOW,$RiskGUI) GUISetState(@SW_SHOW,$aGUIChildren[0]) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($RiskGUI) GUIDelete($aGUIChildren[0]) GUIDelete($aGUIChildren[1]) GUIDelete($aGUIChildren[2]) ExitLoop Case $Tabs ; Hide/show children depending on tab selected For $i = 0 To 2 GUISetState(@SW_HIDE, $aGUIChildren[$i]) Next GUISetState(@SW_SHOW, $aGUIChildren[GUICtrlRead($Tabs)]) EndSwitch WEnd EndFunc Func SubGui($aGUIChildren,$index,$Disabled=False) $aGUIChildren[$index] = GUICreate("", 564, 409, 220, 70,$WS_POPUP,$WS_EX_MDICHILD,$RiskGUI) $iStart = GUICtrlCreateDummy() $labArea[$index] = GUICtrlCreateLabel("Area", 13, 8, 70, 17) $iEnd = GUICtrlCreateDummy() If $Disabled=True then For $i = $iStart To $iEnd GUICtrlSetState($i, $GUI_DISABLE) Next EndIf Return $aGUIChildren[$index] EndFunc Func LV_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView1,$hWndListView2,$hWndListView3,$hWndListView4, $tInfo If Not IsHWnd($idRisksFirst) Then $hWndListView1 = GUICtrlGetHandle($idRisksFirst) If Not IsHWnd($idRisksSecond) Then $hWndListView2 = GUICtrlGetHandle($idRisksSecond) If Not IsHWnd($idRisksThird) Then $hWndListView3 = GUICtrlGetHandle($idRisksThird) If Not IsHWnd($idRisksFinal) Then $hWndListView4 = GUICtrlGetHandle($idRisksFinal) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView1 Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button MsgBox(0,"","Left Click on First Line") Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button MsgBox(0,"","Right Click on First Line") EndSwitch Case $hWndListView2 Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button MsgBox(0,"","Left Click on Second Line") GUICtrlSetState($tabs,$GUI_ENABLE) Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button MsgBox(0,"","Right Click on Second Line") EndSwitch Case $hWndListView3 Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button MsgBox(0,"","Left Click on Third Line") Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button MsgBox(0,"","Right Click on Third Line") EndSwitch Case $hWndListView4 Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button MsgBox(0,"","Left Click on Final Line") Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button MsgBox(0,"","Right Click on Final Line") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY