I'm trying to create DDLs from a .INI file. I managed to eventually do it but I can't change DDL2 content when changing choice in DDL1... the script keeps adding the content instead of replacing it.
The idea :
DDL1 > choice1 creates DDL2 with choices2.1
DDL1 > choice2 creates DDL2 with choices2.2
DDL1 > choice3 creates DDL2 with choices2.3
I've tried this trick:
But it's not working ...Setup the DropDownList with a hwnd as follows:Then to clear it use:Code: Select all
Gui, Add, DropDownList, hwndDDL_ID, Item1|Item2|Item3
Code: Select all
SendMessage, 0x014E, -1, 0,, ahk_id %DDL_ID%
Thank you for your help!
Here's the script:
Code: Select all
#NoEnv
#singleinstance force
;==================================================
;VARIABLES
;==================================================
List_DDL := "Choose:||"
; ==================================================
; GUI
; ==================================================
Gosub Show_Categories
Gui, Color, cFFFFFF,
Gui, Add, MonthCal, 28 x12 vSTR_Date,
Gui, Add, DropDownList, x12 y+10 w200 gShow_Subcategories vCategories_DDL, % List_DDL . Category_Name
Gui, Add, DropDownList, x12 y+10 w200 gShow_Tasks vSubcategories_DDL,
Gui, Add, Edit, x12 y+10 Section w110 hp vHours, Hours
Gui, Add, Edit, x132 ys w110 hp vMinutes, Minutes
Gui, Show, AutoSize, STR
Return
; ==================================================
; LABELS
; ==================================================
Show_Categories:
FileRead, STR_Codes_Content, %A_ScriptDir%\str_codes.ini
Loop Parse, STR_Codes_Content, [
{
IfInString, A_LoopField, ]
{
Count+=1
StringGetPos, Cat, A_LoopField, ]
StringLeft, Temp, A_LoopField, %Cat%
Category_Name.=Temp . "|"
}
}
StringTrimRight, Category_Name, Category_Name, 7 ; removes Tasks and last |
Return
Show_Subcategories:
Gui, Submit, NoHide
IniRead, STR_Subcategories, %A_ScriptDir%\str_codes.ini, %Categories_DDL%
StringSplit, Sub_Cat, STR_Subcategories, `n
Loop, % Sub_Cat0
{
Subcategory_Name := Subcategory_Name Sub_Cat%A_Index% "|"
}
StringTrimRight, Subcategory_Name, Subcategory_Name, 1 ; removes last |
GuiControl,,Subcategories_DDL, % List_DDL . Subcategory_Name
Return
GuiClose:
ExitApp
Show_Tasks:
Write_File:
Return
Code: Select all
[Common & Internal]
Change Mgmt=OT0305
Pulse Meetings=C52793
Education=C52795
Workshops=C52833
Skill Transfer=C54438
[Infrastructure]
Windows servers=OT0087
Database SQL Server=OT0121
[Services & Projects]
SFR misc=AG1677
i80=UL0230
[TASKS]
OT0305=Ope
C52793=Other
C52795=Educ
C52833=Imp
C54438=Comp
OT0087=1.0 Gen
OT0121=1.11 Service Dev
OT0121=1.2 Service maint
OT0121=1.3 Service Prob
OT0121=1.4 Service Own
OT0121=1.5 Service Deliver