GtaSpider Posted January 25, 2008 Posted January 25, 2008 Hi,I've gotta prob.. i'll create a window with the default XP titlebar. But not in this blue. e.g. if there is an error happened, then the title bar should be colored red.I don't want use XSkin or smth like this, because the program have to be little as possible.. I tough the best way is with the WinAPI or GDI+ but i dont know how.It would be great AMAZING, if someone can help me MFG / BEst Regards your Spider www.AutoIt.de - Moderator of the German AutoIt Forum
Greenhorn Posted January 25, 2008 Posted January 25, 2008 Moin Spider, the colors of the Window frames are defiened as Bitmaps in the Theme-DLLs, so I don't know if it is possible to change/paint over the frame colors easily. But it sounds interesting and it would make me delighted too if there is a way to do so ... Has the window a fixed size ? Then maybe create your own frame and set the window style to popup ... Yeah, ok, it's abad idea, but ... Gretz Greenhorn
GtaSpider Posted January 25, 2008 Author Posted January 25, 2008 "Moin" Greenhorn Yes, i though too, about a popupwindow with 50% transparent on e.g RED and then i put it over the titlebar. But the window hasn't got a fixed pos/size.I have an second question^^: How can i colorize menus? I dont mean smth like this. I mean the main Menu (GuiCtrlCreateMenu("File")). Is this possible to colorize? I have a black GUI and it looks bad if the Menu aren't black (the default gray suxt^^)Thank you for comment, Greenhorn MFG / BEst Regardz Spider www.AutoIt.de - Moderator of the German AutoIt Forum
Greenhorn Posted January 25, 2008 Posted January 25, 2008 Did you tried GuiCtrlSetBkColor(), doesn't this work for menus ??? I'll try it by the time and let you know about it, maybe here or in the german Forum ... Greetz from Hamburg to Kiel !
GtaSpider Posted January 25, 2008 Author Posted January 25, 2008 Yes, i tried, but it wont work Tank you v. much! greetz back^^ www.AutoIt.de - Moderator of the German AutoIt Forum
therks Posted January 25, 2008 Posted January 25, 2008 Example from GUICtrlGetHandle expandcollapse popup#include <GUIConstants.au3> Global Const $MIM_APPLYTOSUBMENUS = 0x80000000 Global Const $MIM_BACKGROUND = 0x00000002 $hGui = GUICreate("My GUI", 300, 200) $FileMenu = GUICtrlCreateMenu("&File") $OpenItem = GUICtrlCreateMenuItem("&Open", $FileMenu) $SaveItem = GUICtrlCreateMenuItem("&Save", $FileMenu) GUICtrlCreateMenuItem("", $FileMenu) $OptionsMenu = GUICtrlCreateMenu("O&ptions", $FileMenu) $ViewItem = GUICtrlCreateMenuItem("View", $OptionsMenu) GUICtrlCreateMenuItem("", $OptionsMenu) $ToolsItem = GUICtrlCreateMenuItem("Tools", $OptionsMenu) GUICtrlCreateMenuItem("", $FileMenu) $ExitItem = GUICtrlCreateMenuItem("&Exit", $FileMenu) $HelpMenu = GUICtrlCreateMenu("&?") $AboutItem = GUICtrlCreateMenuItem("&About", $HelpMenu) $EndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20) SetMenuColor($FileMenu, 0xEEBB99) ; BGR color value SetMenuColor($OptionsMenu, 0x66BB99); BGR color value SetMenuColor($HelpMenu, 0x99BBEE) ; BGR color value GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $EndBtn, $GUI_EVENT_CLOSE ExitLoop Case $AboutItem Msgbox(64, "About...", "Colored menu sample") EndSwitch WEnd Exit ; Apply the color to the menu Func SetMenuColor($nMenuID, $nColor) ; Minimum OS are Windows98 and 2000 If @OSVersion = "WIN_95" Or @OSVersion = "WIN_NT4" Then Return $hMenu = GUICtrlGetHandle($nMenuID) $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor) $hBrush = $hBrush[0] Local $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr") DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo)) DllStructSetData($stMenuInfo, 2, BitOr($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND)) DllStructSetData($stMenuInfo, 5, $hBrush) DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo)) ; release Struct not really needed as it is a local $stMenuInfo = 0 EndFunc My AutoIt Stuff | My Github
Greenhorn Posted January 25, 2008 Posted January 25, 2008 (edited) Thanx Saunders, it looks great !!! I think GtaSpider will be very delighted about this solution ! (me naturally too ) The last days he hadn't much luck with his requests, so I think he's gone offline now and sit in his Flat, drinking a lot of alcohol ... (No, I'm just a joking ) Greetz Greenhorn Edited January 25, 2008 by Greenhorn
GaryFrost Posted January 26, 2008 Posted January 26, 2008 Example from GUICtrlGetHandle expandcollapse popup#include <GUIConstants.au3> Global Const $MIM_APPLYTOSUBMENUS = 0x80000000 Global Const $MIM_BACKGROUND = 0x00000002 $hGui = GUICreate("My GUI", 300, 200) $FileMenu = GUICtrlCreateMenu("&File") $OpenItem = GUICtrlCreateMenuItem("&Open", $FileMenu) $SaveItem = GUICtrlCreateMenuItem("&Save", $FileMenu) GUICtrlCreateMenuItem("", $FileMenu) $OptionsMenu = GUICtrlCreateMenu("O&ptions", $FileMenu) $ViewItem = GUICtrlCreateMenuItem("View", $OptionsMenu) GUICtrlCreateMenuItem("", $OptionsMenu) $ToolsItem = GUICtrlCreateMenuItem("Tools", $OptionsMenu) GUICtrlCreateMenuItem("", $FileMenu) $ExitItem = GUICtrlCreateMenuItem("&Exit", $FileMenu) $HelpMenu = GUICtrlCreateMenu("&?") $AboutItem = GUICtrlCreateMenuItem("&About", $HelpMenu) $EndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20) SetMenuColor($FileMenu, 0xEEBB99) ; BGR color value SetMenuColor($OptionsMenu, 0x66BB99); BGR color value SetMenuColor($HelpMenu, 0x99BBEE) ; BGR color value GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $EndBtn, $GUI_EVENT_CLOSE ExitLoop Case $AboutItem Msgbox(64, "About...", "Colored menu sample") EndSwitch WEnd Exit ; Apply the color to the menu Func SetMenuColor($nMenuID, $nColor) ; Minimum OS are Windows98 and 2000 If @OSVersion = "WIN_95" Or @OSVersion = "WIN_NT4" Then Return $hMenu = GUICtrlGetHandle($nMenuID) $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor) $hBrush = $hBrush[0] Local $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr") DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo)) DllStructSetData($stMenuInfo, 2, BitOr($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND)) DllStructSetData($stMenuInfo, 5, $hBrush) DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo)) ; release Struct not really needed as it is a local $stMenuInfo = 0 EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
GaryFrost Posted January 26, 2008 Posted January 26, 2008 (edited) Far as I can tell you can set the System Active Title Bar color, not just a the Active Window at least not with-out painting and callback procedure. This will set the System Active Title Bar color. Note: It sets it back to the original color upon exit. expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GuiMenu.au3> Global Const $COLOR_ACTIVECAPTION = 2 Global Const $COLOR_GRADIENTACTIVECAPTION = 27 _Main() Func _Main() Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_GRADIENTACTIVECAPTION] ; Red and Yellow Local $aColors[2] = [255, 65535], $aSaveColors[2] $hGui = GUICreate("My GUI", 300, 200) $FileMenu = GUICtrlCreateMenu("&File") $OpenItem = GUICtrlCreateMenuItem("&Open", $FileMenu) $SaveItem = GUICtrlCreateMenuItem("&Save", $FileMenu) GUICtrlCreateMenuItem("", $FileMenu) $OptionsMenu = GUICtrlCreateMenu("O&ptions", $FileMenu) $ViewItem = GUICtrlCreateMenuItem("View", $OptionsMenu) GUICtrlCreateMenuItem("", $OptionsMenu) $ToolsItem = GUICtrlCreateMenuItem("Tools", $OptionsMenu) GUICtrlCreateMenuItem("", $FileMenu) $ExitItem = GUICtrlCreateMenuItem("&Exit", $FileMenu) $HelpMenu = GUICtrlCreateMenu("&?") $AboutItem = GUICtrlCreateMenuItem("&About", $HelpMenu) $EndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20) ; Minimum OS are Windows98 and 2000 If @OSVersion <> "WIN_95" And @OSVersion <> "WIN_NT4" Then _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($FileMenu), _WinAPI_CreateSolidBrush(0xEEBB99)) _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($OptionsMenu), _WinAPI_CreateSolidBrush(0x66BB99)) _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($HelpMenu), _WinAPI_CreateSolidBrush(0x99BBEE)) EndIf $aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION) $aSaveColors[1] = _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION) _WinAPI_SetSysColors($aElements, $aColors) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $EndBtn, $GUI_EVENT_CLOSE ExitLoop Case $AboutItem MsgBox(64, "About...", "Colored menu sample") EndSwitch WEnd GUIDelete() _WinAPI_SetSysColors($aElements, $aSaveColors) Exit EndFunc ;==>_Main Func _WinAPI_SetSysColors($vElements, $vColors) Local $isEArray = IsArray($vElements), $isCArray = IsArray($vColors) Local $iElementNum If Not $isCArray And Not $isEArray Then $iElementNum = 1 ElseIf $isCArray Or $isEArray Then If Not $isCArray Or Not $isEArray Then Return SetError(-1, -1, False) If UBound($vElements) <> UBound($vColors) Then Return SetError(-1, -1, False) $iElementNum = UBound($vElements) EndIf Local $tElements = DllStructCreate("int Element[" & $iElementNum & "]") Local $tColors = DllStructCreate("int NewColor[" & $iElementNum & "]") Local $pElements = DllStructGetPtr($tElements) Local $pColors = DllStructGetPtr($tColors) If Not $isEArray Then DllStructSetData($tElements, "Element", $vElements, 1) Else For $x = 0 To $iElementNum - 1 DllStructSetData($tElements, "Element", $vElements[$x], $x + 1) Next EndIf If Not $isCArray Then DllStructSetData($tColors, "NewColor", $vColors, 1) Else For $x = 0 To $iElementNum - 1 DllStructSetData($tColors, "NewColor", $vColors[$x], $x + 1) Next EndIf Local $iResults = DllCall("user32.dll", "int", "SetSysColors", "int", $iElementNum, "ptr", $pElements, "ptr", $pColors) If @error Then Return SetError(-1, -1, False) Return $iResults[0] <> 0 EndFunc ;==>_WinAPI_SetSysColors Edited January 26, 2008 by GaryFrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
erezlevi Posted January 26, 2008 Posted January 26, 2008 hi Gray, I am getting errors on both your examples, can you take a look at them?
BrettF Posted January 26, 2008 Posted January 26, 2008 (edited) hi Gray,I am getting errors on both your examples, can you take a look at them?Missing some WinAPI functions there Gar... I don't have them. Do you?? Are they in the beta?Answered my own question... Run it with beta... Edited January 26, 2008 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
GtaSpider Posted January 26, 2008 Author Posted January 26, 2008 (edited) HelloYeah, AMAZING. Thats very nice! Respect to booth of you! But the Menubar isnt colored by me On WindowBlinds nothing Works (On the Default XP Theme, the Color in then Menu works), but this is not sooo important..Thank you for your Replies Mfg / Best Regardz Spider Edited January 26, 2008 by GtaSpider www.AutoIt.de - Moderator of the German AutoIt Forum
GaryFrost Posted January 26, 2008 Posted January 26, 2008 hi Gray,I am getting errors on both your examples, can you take a look at them?Who the hell is Gray?Nothing wrong with the examples, look at the beta. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
GaryFrost Posted January 26, 2008 Posted January 26, 2008 (edited) Hello Yeah, AMAZING. Thats very nice! Respect to booth of you! But the Menubar isnt colored by me On WindowBlinds nothing Works (On the Default XP Theme, the Color in then Menu works), but this is not sooo important.. Thank you for your Replies Mfg / Best Regardz Spider You didn't say anything about coloring the menu bar itself. Global Const $COLOR_MENU = 4 Global Const $COLOR_MENUHILIGHT = 29 Global Const $COLOR_MENUBAR = 30 Global Const $COLOR_MENUTEXT = 7 Edited January 26, 2008 by GaryFrost added vars SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Greenhorn Posted January 26, 2008 Posted January 26, 2008 Moin Gary,it's a cool thing that you figured out.My question is: Is this only available with the beta of AutoIt or also with the stable version ???GreetzGreenhornp.s.: I put an advert in the newspaper to search for 'Gray' ! I'll let you know if it succeeds, but maybe we'll find an Alien ...
GaryFrost Posted January 26, 2008 Posted January 26, 2008 Moin Gary,it's a cool thing that you figured out.My question is: Is this only available with the beta of AutoIt or also with the stable version ???GreetzGreenhornp.s.: I put an advert in the newspaper to search for 'Gray' ! I'll let you know if it succeeds, but maybe we'll find an Alien ...Well if it don't run in stable then I would say only in beta ATM. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
star2 Posted January 26, 2008 Posted January 26, 2008 (edited) how can I use this with tray menus?-----------Edit : sorry never mind found it in the help file !! Edited January 26, 2008 by star2 [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]
Squirrely1 Posted January 26, 2008 Posted January 26, 2008 ...if there is an error happened, then the title bar should be colored red.If you want something that looks and behaves like a title bar that can change colors, you could create your GUI with only the $WS_POPUP style or something, so that it has no title bar, and create it so that it can't be re-sized. Then you create an image file that looks like a title bar and put it at the top of your GUI and disable the pic control with GuiCtrlSetState. Then replace the image when needed, with another title-bar looking image, but of a different color, using GuiCtrlSetImage or by destroying the original pic control and replacing it, using the new colored image. You could even replicate the Windows system controls that minimize/restore, and close the GUI. Das Häschen benutzt Radar
Greenhorn Posted January 26, 2008 Posted January 26, 2008 If you want something that looks and behaves like a title bar that can change colors, you could create your GUI with only the $WS_POPUP style or something, so that it has no title bar, and create it so that it can't be re-sized. Then you create an image file that looks like a title bar and put it at the top of your GUI and disable the pic control with GuiCtrlSetState. Then replace the image when needed, with another title-bar looking image, but of a different color, using GuiCtrlSetImage or by destroying the original pic control and replacing it, using the new colored image. You could even replicate the Windows system controls that minimize/restore, and close the GUI.Moin Squirrely1,GtaSpider told me that it is not for a self created GUI ! He want to use it for windows from any Application, if I understood him right.Greetz
GtaSpider Posted January 26, 2008 Author Posted January 26, 2008 HiYeah, Greenhorn you're rigth..@Gary: (Sorry, i now, you are not a color^^)Yes, the inMenu is colored, like this: http://www.autoitscript.com/forum/index.ph...;hl=color++menuBut the Gray (not you^^) Top Menu isnt colored I have already installed the Beta. (3.2.11.0)Thank you for Replies Mfg / BEst regards sPider www.AutoIt.de - Moderator of the German AutoIt Forum
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now