Dynamic menu widht problem Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
d1niel84
Posts: 51
Joined: 20 Oct 2019, 12:28
Location: Germany

Dynamic menu widht problem

Post by d1niel84 » 06 Oct 2022, 13:25

My problem is that the width of the menu does not adjust dynamically.
if i select the short menu first and then the long one, the short one will also be "long" afterwards.

Code: Select all

Gui, Add, Button, gButton1, short
Gui, Add, Button, gButton2, long
Gui, Show
Return

Button1:
	Menu, ButtonMenu, Add
	Menu, ButtonMenu, DeleteAll
	Menu, ButtonMenu, Add, short, empty
	Menu, ButtonMenu, Show
Return

Button2:
	Menu, ButtonMenu, Add
	Menu, ButtonMenu, DeleteAll
	Menu, ButtonMenu, Add, looooooooong, empty
	Menu, ButtonMenu, Show
Return

empty:
Return

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Dynamic menu widht problem

Post by mikeyww » 06 Oct 2022, 13:30

Code: Select all

Menu, short, Add, short       , Empty
Menu, long , Add, looooooooong, Empty
Gui, Font, s10
Gui, Add, Button, w230, Short
Gui, Add, Button, wp  , Long
Gui, Show
Return

ButtonShort:
Menu, short, Show
Return

ButtonLong:
Menu, long, Show
Return

Empty:
Return

d1niel84
Posts: 51
Joined: 20 Oct 2019, 12:28
Location: Germany

Re: Dynamic menu widht problem

Post by d1niel84 » 06 Oct 2022, 13:59

Thanks mikeyww. Above was a example. What i want to say is that I use the same menu but with different content. I load the content dynamicly
Not two different menus.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Dynamic menu widht problem

Post by mikeyww » 06 Oct 2022, 14:09

Sounds like it could warrant a @teadrinker solution. 8-)

d1niel84
Posts: 51
Joined: 20 Oct 2019, 12:28
Location: Germany

Re: Dynamic menu widht problem

Post by d1niel84 » 06 Oct 2022, 15:29

mikeyww wrote:
06 Oct 2022, 14:09
Sounds like it could warrant a @teadrinker solution. 8-)
Yes, but only for 5 minutes.
Then I need a solution ;)

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Dynamic menu widht problem

Post by teadrinker » 08 Oct 2022, 12:52

There is no plain solution. Just ignore that.

Descolada
Posts: 1128
Joined: 23 Dec 2021, 02:30

Re: Dynamic menu widht problem  Topic is solved

Post by Descolada » 08 Oct 2022, 13:37

@d1niel84, replace DeleteAll with Delete:

Code: Select all

Gui, Add, Button, gButton1, short
Gui, Add, Button, gButton2, long
Gui, Show
Return

Button1:
	Menu, ButtonMenu, Add
	Menu, ButtonMenu, Delete
	Menu, ButtonMenu, Add, short, empty
	Menu, ButtonMenu, Show
Return

Button2:
	Menu, ButtonMenu, Add
	Menu, ButtonMenu, Delete
	Menu, ButtonMenu, Add, loooooooooooooong, empty
	Menu, ButtonMenu, Show
Return

empty:
Return
I think this is because when the Win32 menu is destroyed, its width is also reset. From the documentation:
Any of the following can cause this Win32 menu to be destroyed, along with any parent menus and submenus:

Deleting a menu.
Replacing an item's submenu with a label or a different menu.
Prior to [v1.1.27.03], calling the sub-commands NoStandard (if the standard items were present) or DeleteAll.
This implies that after v1.1.27.03 DeleteAll doesn't do that, but Delete does.

d1niel84
Posts: 51
Joined: 20 Oct 2019, 12:28
Location: Germany

Re: Dynamic menu widht problem

Post by d1niel84 » 08 Oct 2022, 14:39

Descolada wrote:
08 Oct 2022, 13:37
@d1niel84, replace DeleteAll with Delete:

Code: Select all

Gui, Add, Button, gButton1, short
Gui, Add, Button, gButton2, long
Gui, Show
Return

Button1:
	Menu, ButtonMenu, Add
	Menu, ButtonMenu, Delete
	Menu, ButtonMenu, Add, short, empty
	Menu, ButtonMenu, Show
Return

Button2:
	Menu, ButtonMenu, Add
	Menu, ButtonMenu, Delete
	Menu, ButtonMenu, Add, loooooooooooooong, empty
	Menu, ButtonMenu, Show
Return

empty:
Return
I think this is because when the Win32 menu is destroyed, its width is also reset. From the documentation:
Any of the following can cause this Win32 menu to be destroyed, along with any parent menus and submenus:

Deleting a menu.
Replacing an item's submenu with a label or a different menu.
Prior to [v1.1.27.03], calling the sub-commands NoStandard (if the standard items were present) or DeleteAll.
This implies that after v1.1.27.03 DeleteAll doesn't do that, but Delete does.
@Descolada
Thanks it works :dance:

Post Reply

Return to “Ask for Help (v1)”