Hi all,
I was hoping for help in creating and populating a GUI. I don't have much familiarity with this so I was hoping for some assistance in setting this up. Ideally the GUI would look like below:
The left hand column would populate with names of templates, while the right hand column would populate with the contents of said template depending on which selection was clicked on the left hand column. Hitting select would then paste the template into a textbox.
Help with Creating and populating a GUI?
Re: Help with Creating and populating a GUI?
Something to start with, mainly stolen from AHK's help...
Double clicking on a row will update the content within the viewer pane. Now it's up to you to add some buttons. Good luck
Code: Select all
#SingleInstance, Force
Gui, Add, ListView, x10 y10 r20 w300 h300 gMyListView, Name|Size (KB)
Gui, Add, Edit, xp+310 yp wp hp+8 readonly wrap vLB
Loop, %A_ScriptDir%\*.ahk
LV_Add("", A_LoopFileName, A_LoopFileSizeKB)
LV_ModifyCol() ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer") ; For sorting purposes, indicate that column 2 is an integer.
; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, Show,, Test
return
MyListView:
if (A_GuiEvent = "DoubleClick") {
GuiControl,, LB,% ""
LV_GetText(RowText, A_EventInfo) ; Get the text from the row's first field.
FileRead, content,% RowText
GuiControl,, LB,% content
}
return
GuiClose: ; Indicate that the script should exit automatically when the window is closed.
ExitApp
- AlphaBravo
- Posts: 586
- Joined: 29 Sep 2013, 22:59
Re: Help with Creating and populating a GUI?
here is something to get you started
Code: Select all
oTemplate := {"One":"One Contents", "Two":"Two Contents"}
for template, v in oTemplate
templates .= template "|"
templates := Trim(templates, "|") ; remove extra "|" at the end
templates := StrReplace(templates, "|", "||",, 1) ; replace first "|" with "||" ie first item is selected
Gui, add, ListBox, h200 vLB gPopulate, % templates
Gui, add, Edit, x+10 hp w400 vtextbox ReadOnly
Gui, show
gosub, Populate
return
Populate:
Gui, Submit, NoHide
GuiControl, , textbox, % oTemplate[LB]
return