How to change the background colour of the StatusBar Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
viv
Posts: 217
Joined: 09 Dec 2020, 17:48

How to change the background colour of the StatusBar

19 Oct 2021, 02:13

The following code does not work

Code: Select all

MyGui := gui()
MyGui.BackColor := "FFFFFF"
MyGui.add("text","w500 h400")
SB := MyGui.Add("StatusBar", "BackgroundFF0000", "123456789")
;SB := MyGui.Add("StatusBar", "+BackgroundFF0000", "123456789")
MyGui.Show
1.jpg
1.jpg (29.77 KiB) Viewed 1110 times
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: How to change the background colour of the StatusBar  Topic is solved

19 Oct 2021, 02:28

[edit]
You can try with "-Theme" in options but it looks ugly

Make a own one. There are some examples on old and new forum
e.g self-made bottom with CreateBitmap

Code: Select all

hFF9A9A := DllCall("gdi32\CreateBitmap", "int", 1, "int", 1, "uint", 0x1, "uint", 32, "int64*", 0xFF9A9A, "ptr")


Main := Gui()
Main.MarginX := 0
Main.MarginY := 0
Main.BackColor := "FFFFFF"
Main.AddText("xm ym w500 h400")
Main.AddPicture("xm y+0 w500 h20 BackgroundTrans", "HBITMAP:*" hFF9A9A)
Main.OnEvent("Close", Gui_Close)
Main.Show()


Gui_Close(*)
{
	if (hFF9A9A)
		DllCall("gdi32\DeleteObject", "ptr", hFF9A9A)
	ExitApp
}
or colored Text Control

Code: Select all

Main := Gui()
Main.MarginX := 0
Main.MarginY := 0
Main.BackColor := "FFFFFF"
Main.AddText("xm ym w500 h400")
Main.AddText("xm y+0 w500 h20 0x200 BackgroundFF9A9A", "123456789")
Main.OnEvent("Close", Gui_Close)
Main.Show()


Gui_Close(*)
{
	ExitApp
}
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
viv
Posts: 217
Joined: 09 Dec 2020, 17:48

Re: How to change the background colour of the StatusBar

19 Oct 2021, 03:00

@jNizM

Thank you very much
I need more than this colour (red)
This is actually more obvious as an example

I need it in white
In this case it's not bad except for the line above

But when I have Resize on my GUI OPT
The zoom prompt in the bottom right corner is rather ugly

I will look into your solution
All I need is some information to be displayed on the StatusBar

Maybe Text would be fine
xroot
Posts: 40
Joined: 21 Jun 2019, 08:45

Re: How to change the background colour of the StatusBar

19 Oct 2021, 09:10

Here, try this,it should give you some ideas to make changes to what you want to do with a StatusBar.
Change the Icon to what you like. Ran on Win7 64 AHK v2beta2

Code: Select all

Gui_Size(wParam,lParam,Msg,hWnd){
    static SB_SETICON := 1039
    static IMAGE_ICON := 1
    static cwidth     := 0
    static cheight    := 0
    txt.Move (X+(cwidth-xwidth))/2,(Y+(cheight-xheight))/2
    win.GetClientPos ,,&cwidth,&cheight
    pSize := (lParam & 0xffff)/4
    sb.SetParts pSize*.5,pSize*1.8,pSize*.6
    sb.SetText "`tStatus 1",1
    sb.SetText "`t" StrReplace(FormatTime(,"LongDate")," 0"," "),2
    sb.SetText "`t" FormatTime(,"Time"),3
    SendMessage SB_SETICON,3,LoadPicture("c:\MyDocs\Images\crapper.ico",,&IMAGE_ICON),sb.hWnd
    sb.SetText "`t Exit Icon",4
}

sb_Click(this,indx){
    Switch(indx){
        Case 1,2,3:MsgBox StatusBarGetText(indx,win.hWnd),"Status Bar " indx " Clicked","iconi t2"
        Case 4:ExitApp
    }
}

Update_Time(){
    sb.SetText "`t" FormatTime(,"Time"),3
}

X := 0,Y := 0,xwidth := 0,xheight := 0

WM_SIZE         := 5
SB_SETMINHEIGHT := 1032
GCL_HCURSOR     := -12
IMAGE_CURSOR    := 2

win    := Gui(,"Test StatusBar AHK Version=" A_AHKVERSION (A_PtrSize=8?" 64Bit":" 32Bit"))
win.BackColor := "aqua"
win.OnEvent "Close",ExitApp
win.OnEvent "Escape",ExitApp

txt := win.AddText("center y400 w" A_ScreenWidth/2 " h50","Click Any Status Bar")
txt.SetFont "s32 cnavy underline bold","Times New Roman"

sb := win.AddStatusbar("-Theme Backgroundaqua")
sb.SetFont "s22 bold","Times New Roman"
sb.OnEvent "Click",sb_Click

SendMessage SB_SETMINHEIGHT,50,0,sb.hWnd

DllCall (a_ptrsize=8)?"SetClassLongPtr":"SetClassLong","ptr",sb.hWnd,"int",GCL_HCURSOR,"ptr",LoadPicture("c:\Windows\Cursors\aero_link_xl.cur",,&IMAGE_CURSOR)

win.Opt "+resize"

OnMessage WM_SIZE,Gui_Size

SetTimer Update_Time,999

txt.GetPos &X,&Y

win.Show "w" A_ScreenWidth/2 " h" A_ScreenHeight/2

win.GetClientPos ,,&xwidth,&xheight
viv
Posts: 217
Joined: 09 Dec 2020, 17:48

Re: How to change the background colour of the StatusBar

21 Oct 2021, 01:25

@xroot
Thank you for your help
But I just want to change the background colour...

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: No registered users and 26 guests