News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Change the color of the statusbar/window

Started by clamicun, May 05, 2019, 02:57:21 AM

Previous topic - Next topic

clamicun

I thought it would be easy to change the statuswindow color.

mov status_hnd, rv(CreateWindowEx,0,"msctls_statusbar32","Some text", WS_CHILD or WS_VISIBLE,0,0,0,0,main_hwnd,0,0,0)

RGB 0,0,255   
invoke SendMessage,status_hnd,SB_SETBKCOLOR,0,eax

Returns  4278190080  0xFF000000

It isn't because the color doesn't change

hutch--

A status bar colour is set by the settings in your operating system, its not adjustable. You can code your own but its no fun.

clamicun

A status bar colour is set by the settings in your operating system, its not adjustable. You can code your own but its no fun.

The  SB_SETBKCOLOR message is good for what ?

fearless

https://social.msdn.microsoft.com/Forums/vstudio/en-US/73bf4ce9-e91b-4347-bb9b-91c3ad1116e8/setting-background-of-status-bar?forum=vcgeneral

jj2007

No rocket science, it works fine on Win7-64 - source attached (if you don't have RichMasm, open the *.asc file in WordPad). And yes, this is an ordinary CreateStatusWindowW bar.

Quote from: clamicun on May 05, 2019, 05:13:47 AMThe  SB_SETBKCOLOR message is good for what ?

It is good for setting the statusbar colour in case you have disabled "visual styles", "aero themes", whatever you want to call that crap. My method works also with Aero.

clamicun


TimoVJL

#6
Disabling a Theme from statusbar is an option too.

EDIT: this wasn't tested yet ?
sUXT db "UxTheme.dll",0
sFunc db "SetWindowTheme",0
swNull dw 0
Wnd dd ?

INVOKE LoadLibraryA, ADDR sUXT
.if eax
INVOKE GetProcAddress, eax, ADDR sFunc
.if eax
push OFFSET swNull
push OFFSET swNull
push [Wnd]
call eax
.endif
.endif
May the source be with you

clamicun

To make it a bit easier.

ok. seems to be difficult to change the color of a "real" status bar-
Trying this one.

.if uMsg == WM_CREATE

INVOKE GetClientRect,main_hwnd,offset client
sub client.bottom,23

mov status_hnd, rv(CreateWindowEx,0,"Static","Some text", WS_CHILD or WS_VISIBLE,0,client.bottom,client.right,23,main_hwnd,0,0,0)

This looks like a status bar
How to change the background of this child window ?

hutch--

It is set in your WNDCLASSEX for the window.

Vortex

Hi clamicun,

Here is how to create a status bar and change the color :


    .IF uMsg==WM_INITDIALOG

        invoke  CreateStatusWindow,WS_CHILD or WS_VISIBLE,\
                ADDR sbtext,hWnd,IDW_STATBAR

        mov     hStatusBar,eax
        RGB     200,210,50
        invoke  SendMessage,hStatusBar,SB_SETBKCOLOR,0,eax

jj2007

Hi Erol,

As explained above, Windows ignores SB_SETBKCOLOR if an Aero resp "visual" theme is active.

TimoVJL

In Reply #3 from fearless is a link
QuoteSo, disable theme for status bar (SetWindowTheme) and color it using SB_SETBKCOLOR.
May the source be with you

Vortex

Hi Jochen,

I tested the example on a Windows 7 64-bit system with the aero effect enabled. No any problem.

aw27

Quote from: Vortex on May 06, 2019, 03:19:39 AM
I tested the example on a Windows 7 64-bit system with the aero effect enabled. No any problem.


I don't think it will work with Visual Styles enabled and "all" applications use to have Visual Styles enabled:


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="1.0.0.0"
    processorArchitecture="*"
    name="CompanyName.ProductName.YourApplication"
    type="win32"
/>
<description>Your application description here.</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>
</assembly>


It is possible to turn off Visual Styles on some controls by calling SetWindowTheme.

So this works with Visual Styles enabled (modified Vortex code, thank  you):


include SetStatBarCol.inc

RGB MACRO red,green,blue

    xor     eax,eax
    mov     ah,blue
    shl     eax,8
    mov     ah,green
    mov     al,red

ENDM


DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

IDW_STATBAR equ 1000

.data

DlgBox      db 'DLGBOX',0
sbtext      db 'Status bar',0

includelib \masm32\lib\UxTheme.lib
SetWindowTheme proto :HWND, :ptr, :ptr

.data

hStatusBar  dd ?
nada db 0

.code

start:

    invoke  GetModuleHandle,0
    invoke  DialogBoxParam,eax,ADDR DlgBox,0,ADDR DlgProc,0
    invoke  ExitProcess,eax

DlgProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

    .IF uMsg==WM_INITDIALOG

        invoke  CreateStatusWindow,WS_CHILD or WS_VISIBLE,\
                ADDR sbtext,hWnd,IDW_STATBAR

        mov     hStatusBar,eax
invoke SetWindowTheme, hStatusBar, offset nada, offset nada

        RGB     255,0,0

        invoke  SendMessage,hStatusBar,SB_SETBKCOLOR,0,eax

    .ELSEIF uMsg==WM_CLOSE

        invoke  EndDialog,hWnd,0

    .ELSE

        xor     eax,eax
        ret

    .ENDIF

    mov     eax,1
    ret

DlgProc ENDP

END start


jj2007

Quote from: Vortex on May 06, 2019, 03:19:39 AM
Hi Jochen,

I tested the example on a Windows 7 64-bit system with the aero effect enabled. No any problem.

Hi Erol,

I just built your code and tested it, and strangely enough, it works with Aero enabled. This is weird, my SB_SETBKCOLOR message refuses to work with Aero (and it works fine with a non-Aero theme). Mysteries of Windows... :(

Mine is a window, yours is a dialog - could that make a difference?