Author Topic: Change the color of the statusbar/window  (Read 2413 times)

AW

  • Member
  • *****
  • Posts: 2519
  • Let's Make ASM Great Again!
Re: Change the color of the statusbar/window
« Reply #30 on: May 07, 2019, 02:35:33 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

  • Member
  • *****
  • Posts: 2062
Re: Change the color of the statusbar/window
« Reply #31 on: May 07, 2019, 04:02:44 AM »
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

  • Member
  • *****
  • Posts: 2062
Re: Change the color of the statusbar/window
« Reply #32 on: May 07, 2019, 04:37:37 AM »
Hi clamicun,

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

clamicun

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #33 on: May 07, 2019, 04:43:34 AM »
for Vortex example to use OD:
Code: [Select]
...
       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

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #34 on: May 07, 2019, 04:57:28 AM »
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
« Last Edit: May 07, 2019, 06:15:05 AM by clamicun »

jj2007

  • Member
  • *****
  • Posts: 9928
  • Assembler is fun ;-)
    • MasmBasic
Re: Change the color of the statusbar/window
« Reply #35 on: May 07, 2019, 08:14:43 AM »
I.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

  • Member
  • ***
  • Posts: 488
Re: Change the color of the statusbar/window
« Reply #36 on: May 07, 2019, 06:04:20 PM »
That 3 was just a color index.
With a real brush
Code: [Select]
    .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
Code: [Select]
...
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 too
Code: [Select]
void 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;
}
« Last Edit: May 08, 2019, 01:49:57 AM by TimoVJL »
May the source be with you

clamicun

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #37 on: May 07, 2019, 11:26:37 PM »
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

  • Member
  • ***
  • Posts: 488
Re: Change the color of the statusbar/window
« Reply #38 on: May 08, 2019, 01:56:30 AM »
In normal window you have to handle WM_SIZE and send / relay a WM_SIZE to statusbar.
May the source be with you

jj2007

  • Member
  • *****
  • Posts: 9928
  • Assembler is fun ;-)
    • MasmBasic
Re: Change the color of the statusbar/window
« Reply #39 on: May 08, 2019, 07:06:00 AM »
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

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #40 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

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6868
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Change the color of the statusbar/window
« Reply #41 on: May 08, 2019, 11:12:20 AM »
> 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 9928
  • Assembler is fun ;-)
    • MasmBasic
Re: Change the color of the statusbar/window
« Reply #42 on: May 08, 2019, 05:42:08 PM »
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:

AW

  • Member
  • *****
  • Posts: 2519
  • Let's Make ASM Great Again!
Re: Change the color of the statusbar/window
« Reply #43 on: May 08, 2019, 07:36:25 PM »
If we include the WS_THICKFRAME style the window will have a grip.

clamicun

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #44 on: May 08, 2019, 07:56:45 PM »
jj,
a couple of days ago you wrote:

"Mysteries of Windows..."