Jump to content

How to make GUICtrlCreateEdit entries executable?


Polyphem
 Share

Recommended Posts

Hi Folks,

I have an edit control in my GUI, which is filled with filenames:

$filenameoutput = GUICtrlCreateEdit("none", 40, 245, 410, 80,BitOR($ES_READONLY, $WS_HSCROLL, $WS_VSCROLL),$WS_EX_CLIENTEDGE)

like:

c:\temp\test.txt

c:\pic\nice.jpg

etc.

Is it somehow possible to make the filenames clickable, so that via comsec the file is execute with the respective application? Or is this possible with another type of control? Think i saw something like that in an explorer replacement...

Thanks and kind regards

This post will be edited again by Polyphem: Tomorrow, 11:55 AM
Link to comment
Share on other sites

Try something like this:

#include <Misc.au3>

While 1
    If _IsPressed(01) And GUICtrlRead($filenameoutput) <> 0 Then
        Run GUICtrlRead($filenameoutput)
    EndIf
WEnd

This isn't tested, and obviously won't run by itself, so just work it into your existing code.

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to comment
Share on other sites

I think you might be better off using a 'List' control.

#include <GUIConstants.au3>

Opt('GUIOnEventMode', 1)

GUICreate('Edit Test', 120, 150)
GUISetOnEvent($GUI_EVENT_CLOSE, 'quit')

$listctrl = GUICtrlCreateList('', 10, 10, 100, 130)
GUICtrlSetOnEvent(-1, 'editfunc')
GUICtrlSetData(-1, 'notepad|cmd|msconfig')

GUISetState()

While 1
    Sleep(50)
WEnd

Func editfunc()
    $read = GUICtrlRead($listctrl)
    ShellExecute($read)
EndFunc

Func quit()
    Exit
EndFunc

edit - because I always edit

Edited by xcal
Link to comment
Share on other sites

Thanks JoshDB and xcal for the replies. The list seems nearly what I'm searching for. Does anyone know, how to implement a HScroll on this one? The standard styles dont seem to work.

This post will be edited again by Polyphem: Tomorrow, 11:55 AM
Link to comment
Share on other sites

Great, thats seems to do what i want. The limit is set by pixels, but i wanted it to depend on the items length. Workaround => stringlen * 5.5 seems to fit for the standard font.

#include <GUIConstants.au3>

Opt('GUIOnEventMode', 1)
Opt('RunErrorsFatal',0); otherwise not found entries in the list would terminate the script

GUICreate('Edit Test', 400, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, 'quit')

$listctrl = GUICtrlCreateList('', 10, 10, 180, 130,BitOR($GUI_SS_DEFAULT_LIST, $WS_HSCROLL))
GUICtrlSetLimit (-1, 174) ;HSCROLL doesn't seem to work without setting the limit, 180 - 6 for the VScroll
GUICtrlSetOnEvent(-1, 'editfunc')
GUICtrlSetData(-1, 'notepad|cmd|msconfig')

GUISetState()

; Code for adding values to List
$newvalue = 'C:\temp\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\test.JPG'
GUICtrlSetLimit (-1, StringLen($newvalue)*5.5) ; Limit refers to pixels, Stringlen $newvalue *5.5 seems to fit for the standard font
GUICtrlSetData($listctrl,GUICtrlRead($listctrl) & $newvalue)
; Code End

While 1
    Sleep(50)
WEnd

Func editfunc()
    $read = GUICtrlRead($listctrl)
    ShellExecute($read)
EndFunc

Func quit()
    Exit
EndFunc

Thanks a lot xcal

regards

Edit: I see what you mean with the tags, they seems to hate me too :P...

Edited by Polyphem
This post will be edited again by Polyphem: Tomorrow, 11:55 AM
Link to comment
Share on other sites

No problem. :P

edit -

And here's some more fun. Automatically remove 'dead' items.

#include <GUIConstants.au3>
#Include <GuiList.au3>

Opt('GUIOnEventMode', 1)
Opt('RunErrorsFatal', 0)

GUICreate('Edit Test', 120, 150, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, 'quit')

$listctrl = GUICtrlCreateList('', 10, 10, 100, 130, BitOR($GUI_SS_DEFAULT_LIST, $WS_HSCROLL))
GUICtrlSetOnEvent(-1, 'listfunc')
GUICtrlSetData(-1, 'notepad|fake item|msconfig|cmd')
GUICtrlSetLimit(-1, 500)

GUISetState()

While 1
    Sleep(50)
WEnd

Func listfunc()
    $read = GUICtrlRead($listctrl)
    ShellExecute($read)
    If @error Then _GUICtrlListDeleteItem($listctrl, _GUICtrlListSelectedIndex($listctrl))
EndFunc

Func quit()
    Exit
EndFunc
Edited by xcal
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...