Sign in to follow this  
Followers 0
rpaz

Tray menu width resize?

1 post in this topic

#1 ·  Posted (edited)

Hi,

I'm creating a litle script that will fill the Tray Menu dinamically and found a litle bug/problem on Windows 7!

I made a simple script to ilustrate the problem:

#NoTrayIcon
#include <Constants.au3>

Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1)

dim $txt = "Very long menu text line"
dim $id = 0, $clicks = 0

Func Example()
    TrayCreateItem("Click me")
    TrayItemSetOnEvent(-1, "ClickMe")

    TrayCreateItem("")

    TrayCreateItem("Exit")
    TrayItemSetOnEvent(-1, "ExitScript")

    TraySetState(1)

    While 1
        Sleep(100)
    WEnd
EndFunc   ;==>Example

Func ExitScript()
    Exit
EndFunc   ;==>ExitScript

Func ClickMe()
    switch $clicks
        Case 0 ; 1st click add long text
            $id = TrayCreateItem($txt,-1, 1)
            $txt = "Option2"
        Case 1 ; 2nd click delete long text
            TrayItemDelete($id)
        Case 2 ; 2rd click add small text (the menu size isn't adjusted!)
            TrayCreateItem($txt,-1, 1)
    Endswitch
    $clicks = $clicks + 1
EndFunc

;;; Main
Example()

To test run the script above, open the Tray Menu and click the ClickMe option three times

- on the 1st click a new entry is created with a long line

- 2nd click will remove the long line. When this happens the tray menu resizes properly

- on the 3rd click a new option is added with smaller text. The problem is here! The Tray menu doesn't resize to adjust it uses the old big size!

 

The code above or the compiled exe will work just fine on Windows XP but not on Windows 7!

Is there any way arround this or is it possible to delete the Tray Menu and start over?

 

I also tried to reset the Tray Menu using the following code but after Destroy I coudn't create a new Tray Menu!

local $Tray_ID = TrayItemGetHandle(0)
_GUICtrlMenu_DestroyMenu($TRAY_ID)
TrayCreateItem("Exit")
...
Edited by rpaz

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0