Jump to content

GUI/Tray Menu with icons and colors


Holger
 Share

Recommended Posts

Whenever I do GUICtrlSetDefBkColor(0xB9D1EA) with my GUI all of my buttons dissappear if I have ModerMenuRaw.au3 included. How can I prevent this?

EDIT: It is actually anytime I set the background color for a button. Other things work but not buttons. They will disappear. Any ideas how to fix this please?

As far as I know, Buttons are drawn in ownerdraw mode, if a color is set for them. Possibly ModernMenu doesn't return GUI_RUNDEFMSG, when it's no menu but a button to paint

//Edit: Yes, thats the problem. Just change the beginning of the Func WM_DRAWITEM to this an it will work :P

Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    Local $nResult      = "GUI_RUNDEFMSG"
    
    Local $stDrawItem   = DllStructCreate("uint;uint;uint;uint;uint;dword;dword;int[4];dword", $lParam)
    
    If DllStructGetData($stDrawItem, 1) = 1 Then
        $nResult = FALSE
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

As far as I know, Buttons are drawn in ownerdraw mode, if a color is set for them. Possibly ModernMenu doesn't return GUI_RUNDEFMSG, when it's no menu but a button to paint

//Edit: Yes, thats the problem. Just change the beginning of the Func WM_DRAWITEM to this an it will work :P

Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    Local $nResult      = "GUI_RUNDEFMSG"
    
    Local $stDrawItem   = DllStructCreate("uint;uint;uint;uint;uint;dword;dword;int[4];dword", $lParam)
    
    If DllStructGetData($stDrawItem, 1) = 1 Then
        $nResult = FALSE
THANK YOU! Maybe an update for this program... wierd issue... can't beleive no one had this prior.
Link to comment
Share on other sites

Hi,guys,I come from China and can't speak English very well.

I like this UDF,and have some questions of using it.

It has some conflict with WindowsConstants.au3 and Constants.au3.

I want to hide some controls(such as labels) and creat new controls(covering the hided controls).

When I run the program, controls can be hided,but new created controls are not show.

Please help me,thanks.

Edited by finebbs
Link to comment
Share on other sites

Hi,guys,I come from China and can't speak English very well.

I like this UDF,and have some questions of using it.

It has some conflict with WindowsConstants.au3 and Constants.au3.

I want to hide some controls(such as labels) and creat new controls(covering the hided controls).

When I run the program, controls can be hided,but new created controls are not show.

Please help me,thanks.

Hi post a topic in General support. Remember to give lots of detail and post your code.

Cheers,

Brett

Link to comment
Share on other sites

Hi post a topic in General support. Remember to give lots of detail and post your code.

Cheers,

Brett

The code:

(when click "Change", the last two lines of _new() haven't work)

#include <ModernMenuRaw.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#NoTrayIcon

$hwnd = GUICreate("Test ", 200, 100, -1, -1)

$Label1 = GUICtrlCreateLabel("Today is: "&@YEAR&@MON&@MDAY, 10, 10)
$Label2 = GUICtrlCreateLabel("This is a test.", 10, 40)

$Button1=GUICtrlCreateButton("Change",20,70,60,25)

GUISetState()

$nTrayIcon1 = _TrayIconCreate("Test", "shell32.dll", -40)
_TrayIconSetClick($nTrayIcon1, 16)
_TrayIconSetState()
$bUseAdvTrayMenu = FALSE
$nTrayMenu1 = _TrayCreateContextMenu() 
$nSideItem3 = _CreateSideMenu($nTrayMenu1)
_SetSideMenuText($nSideItem3, "Test")
_SetSideMenuColor($nSideItem3, 0x00FFFF) 
_SetSideMenuBkColor($nSideItem3, 0x802222)
_SetSideMenuBkGradColor($nSideItem3, 0x4477AA) 

$help= _TrayCreateItem("Help")
    _TrayItemSetIcon($help , "shell32.dll", -15)
$About  = _TrayCreateItem("About")
    _TrayItemSetIcon($About, "shell32.dll", -25)

$TrayExit       = _TrayCreateItem("Exit")
    _TrayItemSetIcon($TrayExit, "shell32.dll", -28)

_TrayIconSetState()



While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            _TrayIconDelete($nTrayIcon1)
            Exit
        Case $msg = $Button1
            _new()
        Case $msg = $TrayExit
            _TrayIconDelete($nTrayIcon1)
            Exit
    EndSelect
WEnd

Func _new()
    GUICtrlSetState($Label1,$GUI_Hide)
    GUICtrlSetState($Label2,$GUI_Hide)

    $Label3 = GUICtrlCreateLabel(@OSVersion&@OSServicePack, 10, 10)
    $Label4 = GUICtrlCreateLabel(@OSBuild, 10, 40)
EndFunc

_TrayIconDelete($nTrayIcon1)
Edited by finebbs
Link to comment
Share on other sites

Just add GUISwitch($hwnd) after _TrayIconCreate()

(ModernMenu creates a GUI forto receive Messages from Tray Icons. So you mustn't foget to reset the GUI for GUICtrl functions after the first call of _TrayIconCreate )

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Just add GUISwitch($hwnd) after _TrayIconCreate()

(ModernMenu creates a GUI forto receive Messages from Tray Icons. So you mustn't foget to reset the GUI for GUICtrl functions after the first call of _TrayIconCreate )

Thank you vrey much!

Link to comment
Share on other sites

  • 2 weeks later...

i played around with your udf quite a lot. everything seems to work excellently. :mellow:

just one question left:

could you explain _TrayIconSetClick ? what are the params ?

ok, just in this moment i found the answer:

Case $WM_LBUTTONDOWN

$nClick = 1

case $WM_LBUTTONUP

$nClick = 2

case $WM_LBUTTONDBLCLK

$nClick = 4

case $WM_RBUTTONDOWN

$nClick = 8

case $WM_RBUTTONUP

$nClick = 16

case $WM_RBUTTONDBLCLK

$nClick = 32

case $WM_MOUSEMOVE

$nClick = 64

i think this hint is very hard to find, should be explained in the _TrayIconSetClick function.

and let me add: parameter 0 will never open the tray menu,

while, if you leave away _TrayIconSetClick, it will be opened on any trayevent.

right ?

cheers j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

ah, someone here. yes thats clear, it's the icon ID.

but does not flash.

i tried inserting _TrayIconSetState($ID, 4) in the example scripts, nothing. i hope this can be fixed.

state 1 (show) and 2 (hide) are working though.

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

ah, someone here. yes thats clear, it's the icon ID.

but does not flash.

i tried inserting _TrayIconSetState($ID, 4) in the example scripts, nothing. i hope this can be fixed.

state 1 (show) and 2 (hide) are working though.

j.

Just going from bad memory here but I think that function is for the icons on tray items and tray menus themselves. As far as I know the only one that can be flashed is the main icon in the system tray.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

@GEOSoft:

but... the function does the following: it creates an empty icon and sets a timer to exchange blank and icon according to flashtime interval. in this way it should be working for the tray icon itself, too. i can do that "manually", so maybe it's the script and not a basic problem.

but dose any one have a clue with my hotkey problem?

sorry ? what problem ?

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

sorry ? what problem ?

This problem,My very 1st post. 8 posts before this one!

How do you show the tray menu with a hotkey?

Please HELP I AM DESPERATE! :(:mellow:

ps I love what you have done :)

Also how do you do this with the "TrayCreate..." auotit commands? as well as the cool menu functions of this thread.

[edit:]oh I am also using the unicode one by the way.

Edited by abushcrafter

[center]I click you, you click me!The Home Of abushcrafter[/center]

Link to comment
Share on other sites

do you mean like this:

$visible=0

GUICreate("")
GUICtrlCreateLabel("Hit Enter Key",20,20,100,30)
GUISetState()

HotKeySet("{Enter}","_TrayIcon")

Do
    $msg=GUIGetMsg()
Until $msg=-3

Func _TrayIcon()
    $visible=($visible=0)
    Opt("TrayIconHide",$visible)
EndFunc

this is very basic. i think you should learn how to use the helpfile first.

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

do you mean like this:

$visible=0

GUICreate("")
GUICtrlCreateLabel("Hit Enter Key",20,20,100,30)
GUISetState()

HotKeySet("{Enter}","_TrayIcon")

Do
    $msg=GUIGetMsg()
Until $msg=-3

Func _TrayIcon()
    $visible=($visible=0)
    Opt("TrayIconHide",$visible)
EndFunc

this is very basic. i think you should learn how to use the helpfile first.

j.

Sorry but that's not what I mean.

I would like to show the TRAY MENU (the pop up menu when you click the tray icon.)

I can do the HotKeySet bit fine. But what I am struggling with is in the function that you call with HotKeySet, What func do you have there?

E.G

HotKeySet("#^t", "ShowTheDarnMenu"
Func ShowTheDarnMenu()
    ;The unknow func to have here???...
EndFunc

If you what I can post my source code?

AND I do use the help file, In fact IT IS ALWAYS RUNNING WHEN THE EDITOR IS RUNNING.

Edited by abushcrafter

[center]I click you, you click me!The Home Of abushcrafter[/center]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...