Jump to content
Sign in to follow this  
Jazkal

Looking for pointers or direction

Recommended Posts

My app reads an INI file and populates a ListView. I want to be able to click on one of the items, and have it populate the Input dialogs. So I can edit them, and then update the ListView with the modified items.

Just looking for the correct commands to do this. Or even a better way of doing this.

Here is my current code. NOTE: the INI file needs to be named the same as the AU3 file.

test.au3

#include <GUIConstants.au3>
#include <Array.au3>

Dim $inumBatch, $numBatch, $icmdBatch, $cmdBatch

$ScriptName = StringLeft ( @ScriptName, ((StringLen (@ScriptName)) - 4)) 
$Settings = ($ScriptName & ".ini")

$iBatchLoop = IniRead ($Settings, "batch", "total", "NotFound")
Dim $aBatchArray[$iBatchLoop]
$iLoop = 0
Do
    $iBatch = IniRead ($Settings, "batch", $iLoop + 1, "NotFound")
    $aBatchArray[$iLoop] = $iBatch
    $iLoop = $iLoop + 1
Until $iLoop = $iBatchLoop

Opt("GUIOnEventMode", 1); Change to OnEvent mode 

GUICreate("Test App", 275, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState (@SW_SHOW)   ; will display an empty dialog box

$listView = GuiCtrlCreateListView(" # |Batch Command|", 20, 40, 210, 130)
    $iBLoop = 0
    Do
        GuiCtrlCreateListViewItem($iBLoop + 1 & "|" & $aBatchArray[$iBLoop], $listView)
        $iBLoop = $iBLoop + 1
    Until $iBLoop = $iBatchLoop
GuiCtrlCreateLabel("#", 25, 180)
    $inumBatch = GuiCtrlCreateInput($numBatch, 20, 200, 20, 20)
GuiCtrlCreateLabel("Batch Command", 60, 180)
    $icmdBatch = GuiCtrlCreateInput($cmdBatch, 45, 200, 150, 20)
$Add1 = GUICtrlCreateButton ("Add", 50, 225)
    GUICtrlSetOnEvent(-1, "AddPressed")
$Insert1 = GUICtrlCreateButton ("Insert", 85, 225)
    GUICtrlSetOnEvent(-1, "InsertPressed")
$Delete1 = GUICtrlCreateButton ("Delete", 130, 225)
    GUICtrlSetOnEvent(-1, "DeletePressed")

While 1
; Run the GUI until the dialog is closed
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Func AddPressed()
  Exit
EndFunc

Func InsertPressed()
  Exit
EndFunc

Func DeletePressed()
  Exit
EndFunc

Func CLOSEClicked()
  Exit
EndFunc

test.ini

[batch]
total=7
1=call OC.bat
2=netcfg -v -winpe
3=ipconfig /renew
4=ping -n 8 testserver
5=net use z: \\testserver\win2k3
6=net use y: \\testserver\win2k
7=z:\x86_scripts\startx32.bat
Edited by Jazkal

Share this post


Link to post
Share on other sites

I looked that code over, and that pointed me to other code, and was able to get the double clicking on the list view to work.

The problem however, is that to get it to owrk I had to disable this command:

Opt("GUIOnEventMode", 1)

But other parts of my code won't work without that option. Does anyone know how to get the doubleclick working with "Opt("GUIOnEventMode", 1)" enabled?

I've included the files as a zip.

test.zip

Edited by Jazkal

Share this post


Link to post
Share on other sites

I looked that code over, and that pointed me to other code, and was able to get the double clicking on the list view to work.

The problem however, is that to get it to owrk I had to disable this command:

Opt("GUIOnEventMode", 1)

But other parts of my code won't work without that option. Does anyone know how to get the doubleclick working with "Opt("GUIOnEventMode", 1)" enabled?

I've included the files as a zip.

<{POST_SNAPBACK}>

With eventmode on, $msg = GUIGetMsg() is useless. You have to use guictrlsetonevent($control,"myfunction") for every control. See if the that help.

.

Share this post


Link to post
Share on other sites

I looked through the above Process Blocker and couldnt find the Double click code. I am unaware what method you are using but I know this way works like a charm for me, not sure if it will work with Opt("GUIOnEventMode", 1) but worth a try.

CODE
Global $Timer

Global $Threshold = Number(RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "DoubleClickSpeed"))

Case $msg = $GUI_EVENT_PRIMARYDOWN

$MousePos = GUIGetCursorInfo()

If ($MousePos[4] == $listview And GUICtrlRead($listview) > 0 And _

_GUICtrlListViewGetHotItem ($listview) = _GUICtrlListViewGetCurSel($listview)) Then

If TimerDiff($Timer) <= $Threshold Then

MsgBox(4096, "", "DoubleClick Detected")

EndIf

$Timer = TimerInit()

EndIf

Edited by Burrup

qq

Share this post


Link to post
Share on other sites

Yes, this is the method I tried, and it works nice by itself, but will not work with GUIOnEventMode on.

And I don't see how I can use guictrlsetonevent for each item, as they are loaded up dynamicly each time the app is run. They aren't hard coded, and my attempts at adding guictrlsetonevent to my dynamic code doesn't work. I could be doing something wrong, but I don't see it.

Edited by Jazkal

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...