Gui DropDownList and ComboBox remember drop-down height when control is emptied - bug or feature?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Gui DropDownList and ComboBox remember drop-down height when control is emptied - bug or feature?

Post by JoeWinograd » 05 Jun 2023, 19:57

Here's the example at the DropDownList and ComboBox documentation in a simple script:

Code: Select all

Gui,Add,DDL,vColorChoice,Red|Green|Blue|Black|White
;Gui,Add,ComboBox,vColorChoice,Red|Green|Blue|Black|White ; also happens with this
Gui,Add,Button,,OK
Gui,Show
Return

ButtonOK:
Gui,Submit,NoHide
GuiControl,,ColorChoice,| ; empty control
MsgBox look at drop-down now
Return

GuiClose:
ExitApp
The documentation says:

"To make the control empty, specify only a pipe character (|)."

Yes, it sets all the choices to null, but it remembers the height of the list from the last time it was populated.

For example, if the Gui,Add,DDL or Gui,Add,ComboBox statement has no values specified, the drop-down list looks like this — truly empty:

DDL or ComboBox truly empty.png
DDL or ComboBox truly empty.png (2.11 KiB) Viewed 313 times

That's what I would expect to see after clearing the control with the pipe-only string. But the result from running the script above is this:

DDL or ComboBox empty but remembers height.png
DDL or ComboBox empty but remembers height.png (2.16 KiB) Viewed 313 times

Even though the list has "empty" choices, it remembers the height from the previous population of the five colors. Is this a bug or feature? In either case, is there a work-around to have it display the drop-down list as shown in the first screenshot in this post (without having to destroy the GUI)? Thanks, Joe

just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Gui DropDownList and ComboBox remember drop-down height when control is emptied - bug or feature?

Post by just me » 06 Jun 2023, 05:50

Hi @JoeWinograd,

it seems to be a feature. The List Box control of a ComboBox (DDL) is created and owned by the system.

The only workaround I found is the good old hiding game:

Code: Select all

#NoEnv
Gui, Add, DDL, vColorChoice, Red|Green|Blue|Black|White
Gui, Add, DDL, vColorEmpty xp yp wp +Hidden
;Gui,Add,ComboBox,vColorChoice,Red|Green|Blue|Black|White ; also happens with this
Gui, Add, Button, , Remove
Gui, Add, Button, , Restore
Gui, Show
Return

ButtonRemove:
GuiControl, Hide, ColorChoice
GuiControl, Show, ColorEmpty
GuiControl, , ColorChoice, |
Return

ButtonRestore:
GuiControl, , ColorChoice, |Blue|Black|White
GuiControl, Hide, ColorEmpty
GuiControl, Show, ColorChoice
Return

GuiClose:
ExitApp

User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Gui DropDownList and ComboBox remember drop-down height when control is emptied - bug or feature?

Post by JoeWinograd » 06 Jun 2023, 11:01

Hi @just me,
Thanks for the work-around idea...works perfectly!
Regards, Joe

Post Reply

Return to “Ask for Help (v1)”