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

aw27

Quote from: jj2007 on May 07, 2019, 02:22:59 AM
The latter doesn't understand the SB_... message when visual themes are active. The old 5.82 works fine with "visual" themes (I hate this "visual" word, it's so meaningless; "Aero" made more sense).

There is some confusion here. It understands the SB_... when we exclude the pertinent control out of the theme. This is what we have been talking about since long. I.e, we need to exclude the status bar.

Vortex

Hi Jochen,

Probably, I was lucky as I first tried the status bar on a dialog box. Interesting case. My Windows 7 64-bit setup is a standard one. I can tell that the Aero theme is enabled as I can hit the Windows flag + TAB combination to view the superposition of application windows.

Vortex

Hi clamicun,

I only tested the status bar on a dialog box. Let's see the results of the new tests.

clamicun

for Vortex example to use OD: ...
       invoke  SendMessage,hStatusBar,SB_SETTEXT,SBT_OWNERDRAW,ADDR sbtext

    .ELSEIF uMsg==WM_DRAWITEM

        mov edi,lParam
        .IF [edi].DRAWITEMSTRUCT.CtlID == IDW_STATBAR
            invoke FillRect,[edi].DRAWITEMSTRUCT.hDC,ADDR [edi].DRAWITEMSTRUCT.rcItem,3
            invoke TextOut,[edi].DRAWITEMSTRUCT.hDC,4,4,[edi].DRAWITEMSTRUCT.itemData,10
        .ENDIF

timoVJL,
yes, it works, the status bar is colored, but the text is black/white.
So actually it isn't good for anything, but I am learning a lot.

clamicun

#34
vortex,
I tested the status bar on a dialog box. Let's see the results of the new tests.

It works with a window as well
windows 10 64b

ADDR [edi].DRAWITEMSTRUCT.rcItem,3 
This I don't understand.  3 is a color/brush on fillrect , but if I use anything but a number (e.g. 1 = black) it doesn' work.

Why not ?
RGB 0,0,255
ADDR [edi].DRAWITEMSTRUCT.rcItem,eax     

Same with the lenght:
[edi].DRAWITEMSTRUCT.itemData,60  ; works but a var doesn't.

mov eax,len(addr textstring)
[edi].DRAWITEMSTRUCT.itemData,eax

jj2007

Quote from: AW on May 07, 2019, 02:35:33 AMI.e, we need to exclude the status bar.

My analysis is correct: A statusbar that was created by a program with an XP manifest doesn't handle the SB_SETBKCOLOR message correctly when a "visual" theme is active.

But your workaround for this Windows bug is also correct - and I confess I had not understood previously that one can "exclude" a single control using SetWindowTheme. This works fine:

        Dll "UxTheme"
        Declare
void SetWindowTheme, 3
        SetWindowTheme(hSbar, 0, wChr$(0))
        invoke SendMessageW, hSbar, SB_SETBKCOLOR, 0, LiteRed

TimoVJL

#36
That 3 was just a color index.
With a real brush    .IF uMsg==WM_INITDIALOG
...
        invoke CreateSolidBrush,RGB(200,210,50)
        mov hBkBrush, eax
        invoke  SendMessage,hStatusBar,SB_SETTEXT,SBT_OWNERDRAW,ADDR sbtext

    .ELSEIF uMsg==WM_DRAWITEM

        mov edi,lParam
        .IF [edi].DRAWITEMSTRUCT.CtlID == IDW_STATBAR
            invoke FillRect,[edi].DRAWITEMSTRUCT.hDC,ADDR [edi].DRAWITEMSTRUCT.rcItem,hBkBrush
            invoke SetBkMode,[edi].DRAWITEMSTRUCT.hDC,1 ;TRANSPARENT
            invoke TextOut,[edi].DRAWITEMSTRUCT.hDC,4,5,[edi].DRAWITEMSTRUCT.itemData,10
        .ENDIF
Pascal style strings, first byte is a lenght of string...
sbLText     db 10,'Status bar',0
...
            invoke SetBkMode,[edi].DRAWITEMSTRUCT.hDC,1 ;TRANSPARENT
            mov eax, [edi].DRAWITEMSTRUCT.itemData
            movsx ecx, BYTE PTR [eax]
            inc eax
            invoke TextOut,[edi].DRAWITEMSTRUCT.hDC,4,5,eax,ecx
EDIT: In C toovoid OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem)
{
if (lpDrawItem->CtlID == IDC_STATUS) {
FillRect(lpDrawItem->hDC, &lpDrawItem->rcItem, hBkBrush);
SetBkMode(lpDrawItem->hDC, TRANSPARENT);
char *p = (char*)lpDrawItem->itemData;
TextOut(lpDrawItem->hDC, 4, 5, p, *(p++));
}
return;
}
May the source be with you

clamicun

Timo VJL,

Absolutely wonderful. Works perfectly with dialogs and windows.
"Problem" solved. Many Thanks

One thing I don't understand in my example Status_win_color.
If I don't include the manifest.xml it works, but the status window has a "Grip".
Thanks again
clamicun

TimoVJL

In normal window you have to handle WM_SIZE and send / relay a WM_SIZE to statusbar.
May the source be with you

jj2007

I wonder why you want to resort to complicated solutions. José's suggestion works just fine...

        SetWindowTheme(hSbar, 0, wChr$(0))
        invoke SendMessageW, hSbar, SB_SETBKCOLOR, 0, Rgb(whatever)

clamicun

Case you talk to me. It's the only solution which works on my computer windows 10 Home 64b

hutch--

> One thing I don't understand in my example Status_win_color.
If I don't include the manifest.xml it works, but the status window has a "Grip".

Without the manifest you get the old Windows interface.

jj2007

Quote from: clamicun on May 08, 2019, 09:06:42 AM
Case you talk to me. It's the only solution which works on my computer windows 10 Home 64b

I also have a Windows 10 Home 64 machine, and the SB_SETBKCOLOR works fine there, provided you use SetWindowTheme as shown above.

Interesting btw that common controls are stuck at version 6.16 since Windows XP. There is (was?) apparently a version 7.0 that shipped with Office 2016, but they're crashing Excel :badgrin:

aw27

If we include the WS_THICKFRAME style the window will have a grip.

clamicun

jj,
a couple of days ago you wrote:

"Mysteries of Windows..."