Sign in to follow this  
Followers 0
gottygolly

Error with GuiCtrlRead()

5 posts in this topic

I've been working on some different code here and there and I saw a post about double clicking in a GuiCtrlCreateListView(). So I decided to just mess around with it and learn it as good as I can. However the problem I am having is I have a line: GuiCtrlRead(GuiCtrlRead($var)), it can read the $var but it will read it as: Example.exe| and it won't run because of the " | ".

Anyone know the error?

#include <File.au3>
#include<guiconstants.au3>
$gui = GUICreate("GUI",300,300,-1,-1)
GUIRegisterMsg($WM_NOTIFY,"WM_NOTIFY")
$b = GUICtrlCreateButton("Load",10,10,100,20)
$list = GUICtrlCreateListView("Swf List",5,40,290,260)
Global $DoubleClicked = False
GUISetState()
While 1
   If $DoubleClicked Then
      double()
      $DoubleClicked = False
      EndIf
   $msg = GUIGetMsg(1)
   Switch $msg[1]
   Case $gui
      Switch $msg[0]
      Case -3
         Exit
      Case $b
         GUICtrlCreateListViewItem("notepad.exe",$list)
      EndSwitch
   EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $list And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
 EndFunc
 Func double()
    $go = GUICtrlRead(GUICtrlRead($list))
    ShellExecute($go)
    EndFunc

Share this post


Link to post
Share on other sites



gottygolly,

There is no error - GUICtrlRead adds a delimiter at the end of the ListView content. If you add another column to the ListView like this you can see that the same thing happens:

#include <File.au3>
#include<guiconstants.au3>

$gui = GUICreate("GUI", 300, 300, -1, -1)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$b = GUICtrlCreateButton("Load", 10, 10, 100, 20)
$list = GUICtrlCreateListView("Swf List|    ", 5, 40, 290, 260)
Global $DoubleClicked = False
GUISetState()

While 1
    If $DoubleClicked Then
        double()
        $DoubleClicked = False
    EndIf
    $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $gui
            Switch $msg[0]
                Case -3
                    Exit
                Case $b
                    GUICtrlCreateListViewItem("notepad.exe|3", $list)
            EndSwitch
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $list And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func double()
    $go = GUICtrlRead(GUICtrlRead($list))
    ShellExecute($go)
EndFunc   ;==>double
So you need to use StringTrimRight to remove the added delimiter - then you will get what you require. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for the help Melba.

I tried to insert the StringTrimRight() like you said to do but it seems to be doing anything. I might be doing something wrong can you point it out?

#include <File.au3>
#include<guiconstants.au3>
$gui = GUICreate("GUI",300,300,-1,-1)
GUIRegisterMsg($WM_NOTIFY,"WM_NOTIFY")
$b = GUICtrlCreateButton("Load",10,10,100,20)
$list = GUICtrlCreateListView("Swf List",5,40,290,260)
Global $DoubleClicked = False
GUISetState()
While 1
   If $DoubleClicked Then
      double()
      $DoubleClicked = False
      EndIf
   $msg = GUIGetMsg(1)
   Switch $msg[1]
   Case $gui
      Switch $msg[0]
      Case -3
         Exit
      Case $b
         $fr = StringTrimRight("notepad.exe",0)
         GuiCtrlCreateListViewItem($fr,$list)
      EndSwitch
   EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $list And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
 EndFunc
 Func double()
    $go = GUICtrlRead(GUICtrlRead($list))
    ShellExecute($go)
    EndFunc
Edited by gottygolly

Share this post


Link to post
Share on other sites

gottygolly,

As it is GUICtrlRead that returns the extra delimiter, it is that string that you need to trim: ;)

$go = StringTrimRight(GUICtrlRead(GUICtrlRead($list)), 1)
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Sweet, works like its suppose to  :thumbsup:

Thanks for the help Melba I just had a bit of a brain fart.

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  
Followers 0