I tumbled upon another problem when I tried to create a function to redraw every control.
When I tried to read or destroy the dropdownlist, it does not seem to work, because probably the dropdownlist is a combination of multiple controls.
I already managed to do the following controls: Edit, Button, Listview (the functions are not finisched yet, I want just one function that automatically detects the type and the size and also copies this, if no new size is given). The Listview works already quite good, it copies the content, columnsize and the selection (if only one line selected). I commented the Listview commands out, so you can test it if you want.
I could not get the list of the dropdownlist without the v variable, and destroying this control is apparently also difficult. Does anybody has some experience with this?
Code: Select all
#SingleInstance Force
Gui, +Resize
oGui := {}
Gui, Add, DropDownList, hwndhDDL1, row1|row2|Row3
;~ Gui, Add, Button, ggButton hwndhButton, Test
;~ Gui, Add, Edit, x6 y6 w200 hwndhEdit1, test
;~ Gui, Add, ListView, r3 hwndhLV1, col1|col2
LV_Add(, "Field1", "Field2")
LV_Add(, "Field15", "Field3")
LV_Add(, "Field25", "Field4")
LV_Add(, "Field35", "Field5")
Gui, Add, Tab3, vvTab, 1|2|3|4
Gui, Tab, 4
Gui, +hwndhGuiTest
Gui, Show, W300 H300
return
GuiSize:
DllCall("LockWindowUpdate", Uint,hGuiTest)
TabHeight := A_GuiHeight - 110
if (A_GuiHeight<200){
if (TaBY!=4){
TabY:=4
GuiControlGet, SelectedTab, , vTab
GuiControl, , vTab, |1|2|3|4
GuiControl, Choose, vTab, % SelectedTab
Gui, Tab, 4
hDDL1 :=GuiRedrawDDL(hDDL1, "x15 y140")
;~ hbutton:=GuiRedrawButton(hbutton, "ggButton")
;~ hEdit1:=GuiRedraw(hEdit1, "x10 y60 w200")
;~ hLV1:=GuiRedrawLV(hLV1, "x15 y140 r3")
Gui, Tab
}
TabHeight+=96
}
else{
if (TabY!=30){
TabY:=100
GuiControlGet, SelectedTab, , vTab
GuiControl, , vTab, |1|2|3
GuiControl, Choose, vTab, % SelectedTab
Gui, Tab
hDDL1 :=GuiRedrawDDL(hDDL1, "x6 y6")
;~ hbutton:=GuiRedrawButton(hbutton, "ggButton x6 y6")
;~ hEdit1:=GuiRedraw(hEdit1, "x6 y6 w200")
;~ hLV1:=GuiRedrawLV(hLV1, "x6 y6 r3")
}
}
GuiControl, Move, vTab, % "y" TabY " h" TabHeight " w" A_GuiWidth-20
;Enable updating of gui
DllCall("LockWindowUpdate", Uint, 0)
Gui, Show
return
GuiRedrawEdit(ControlID, Options){
; works
GuiControlGet, Control_Content, , % ControlID
DllCall("DestroyWindow", "UInt", ControlID)
Gui, Add, Edit, % options " hwndControlID", % Control_Content
return ControlID
}
GuiRedrawButton(ControlID, Options){
; works
GuiControlGet, Control_Content, , % ControlID
DllCall("DestroyWindow", "UInt", ControlID)
Gui, Add, Button, % options " hwndControlID", % Control_Content
return ControlID
}
GuiRedrawDDL(ControlID, Options :=""){
; does not work
WinGetClass, controlClass, ahk_id %ControlID%
GuiControlGet, Control_List, List , % ControlID
;Seems to fail
MsgBox, % Control_List
GuiControlGet, Control_Content, , % ControlID
DllCall("DestroyWindow", "UInt", ControlID)
Gui, Add, DropDownList, % options " hwndControlID", % StrReplace(DDLList, "`n", "|")
return ControlID
}
GuiRedrawLV(ControlID, Options){
; works, copies content and selection
WinGetClass, controlClass, ahk_id %ControlID%
Control_Content:=""
Number_Col := LV_GetCount("Col")
Number_Rows := LV_GetCount()
SelectedRow:=LV_GetNext()
loop, % Number_Col{
LV_GetText(RetrievedText,0, A_Index)
Control_Content .= Control_Content="" ? RetrievedText : "|" RetrievedText
}
RowWidth:={}
Loop % Number_Col {
SendMessage, 0x101D, A_Index -1, 0, % controlClass "1" ; 0x101D is LVM_GETCOLUMNWIDTH.
RowWidth[A_Index]:= ErrorLevel
}
Control_List :=
Loop % Number_Rows
{
Row := A_Index
Line_content :=""
loop, % Number_Col{
LV_GetText(RetrievedText,Row, A_Index)
Line_content .= Line_content="" ? RetrievedText : "`t" RetrievedText
}
Control_List .= Control_List="" ? Line_content : "`n" Line_content
}
DllCall("DestroyWindow", "UInt", ControlID)
Gui, Add, ListView, % options " hwndControlID", % Control_Content
GuiControl, -Redraw, % ControlID
Loop, Parse, Control_List, `n
{
oLine := StrSplit(A_LoopField, "`t")
LV_Add(,oLine* )
}
Loop, % Number_Col
{
if (RowWidth[A_Index]!= "Fail"){
LV_ModifyCol(A_Index, RowWidth[A_Index])
}
}
if (SelectedRow!=0){
LV_Modify(SelectedRow, "Select")
}
GuiControl, +Redraw, % ControlID
return ControlID
}
gButton:
;~ DebugWindow("test`n",Clear:=0)
MsgBox, test
return