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

TimoVJL

  • Member
  • ****
  • Posts: 525
Re: Change the color of the statusbar/window
« Reply #15 on: May 06, 2019, 06:21:04 PM »
compatibility section in manifest ?

EDIT: RGB macro
Code: [Select]
;#define RGB(r,g,b)  ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
RGB MACRO r:REQ,g:REQ,b:REQ
   EXITM %((r and 0ffh) or ((g and 0ffh) shl 8) or ((b and 0ffh) shl 16) )
ENDM
« Last Edit: May 06, 2019, 09:56:36 PM by TimoVJL »
May the source be with you

jj2007

  • Member
  • *****
  • Posts: 10322
  • Assembler is fun ;-)
    • MasmBasic
Re: Change the color of the statusbar/window
« Reply #16 on: May 06, 2019, 06:56:45 PM »
You nailed it, Timo :t

So the situation under Windows 7-64 is as follows (source & 2*exe attached):
- SB_SETBKCOLOR works always if no "visual" theme is activated
- if, however, an "Aero" or "visual" theme is active, then
- SB_SETBKCOLOR works if no manifest is present, i.e. common controls version 5.82 are being used (see statusbar text in the two attached executables)
- SB_SETBKCOLOR does not work if an XP manifest is being used (version 6.16 in the statusbar text).

In the last case, subclassing will still work, see the if 0 under .code in the source.

Unless Micros**t provides a credible excuse for this behaviour, I call it a Windows bug :P

P.S.: The manifest:
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>MasmBasic</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
/>
</dependentAssembly>
</dependency>
</assembly>

AW

  • Member
  • *****
  • Posts: 2583
  • Let's Make ASM Great Again!
Re: Change the color of the statusbar/window
« Reply #17 on: May 06, 2019, 07:20:21 PM »
Compatibility section in Manifest has no influence.

jj2007

  • Member
  • *****
  • Posts: 10322
  • Assembler is fun ;-)
    • MasmBasic
Re: Change the color of the statusbar/window
« Reply #18 on: May 06, 2019, 07:29:15 PM »
Right. Exactly the same behaviour with this manifest (MS docs):
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>MasmBasic</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
        <!--The ID below indicates app support for Windows Vista -->
        <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
        <!--The ID below indicates app support for Windows 7 -->
        <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
        <!--The ID below indicates app support for Windows 8 -->
        <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
    </application>
</compatibility>
</assembly>

And as soon as you take away the common controls version="6.0.0.0" stuff, the message starts working again. Subclassing works always, of course. It's a Windows bug, that's all :P

TimoVJL

  • Member
  • ****
  • Posts: 525
Re: Change the color of the statusbar/window
« Reply #19 on: May 06, 2019, 07:55:39 PM »
Owner Draw works too.
Code: [Select]
SendMessage(hStatus, SB_SETTEXT, SBT_OWNERDRAW, (LPARAM)"test");
...
void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem)
{
if (lpDrawItem->CtlID== IDC_STATUS) {
FillRect(lpDrawItem->hDC, &lpDrawItem->rcItem, (HBRUSH)3);
TextOut(lpDrawItem->hDC, 4, 4, (char*)lpDrawItem->itemData, 4);
}
return;
}
May the source be with you

clamicun

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #20 on: May 06, 2019, 08:26:54 PM »
Vortex,

Compiles and works with Windows 10 64b

.IF uMsg==WM_INITDIALOG
mov status_hnd,rv(CreateStatusWindow,WS_CHILD or WS_VISIBLE,"Some text",main_hwnd,status_ID)
RGB     200,210,50
invoke  SendMessage,status_hnd,SB_SETBKCOLOR,0,eax

If I don't build a dialog but a "normal" window and use


.if uMsg == WM_CREATE
mov status_hnd,rv(CreateStatusWindow,WS_CHILD or WS_VISIBLE,"Some text",main_hwnd,status_ID)
RGB     200,210,50
invoke  SendMessage,status_hnd,SB_SETBKCOLOR,0,eax

It doesn't work ???

clamicun

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #21 on: May 06, 2019, 08:28:37 PM »
jj,

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

Exactly

clamicun

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #22 on: May 06, 2019, 08:50:36 PM »
jj,
trying to compile MapViewerWithRedStatusBar.asm I get an error


E:\masm32\examples\jjs_beispiel\MapViewerWithRedStatusBar.asm(1): Main line code
## MasmBasic GUI build ##
## deb: excluded WM_MOUSEMOVE, WM_NCHITTEST, WM_SETCURSOR, WM_GETICON, WM_NCMOUSEMOVE, WM_MOVING, WM_ENTERIDLE ##
## creating 3 controls ##
MapViewerWithRedStatusBar.asm: 62 lines, 1 passes, 233 ms, 0 warnings, 1 errors
« Last Edit: May 06, 2019, 11:44:48 PM by clamicun »

clamicun

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #23 on: May 07, 2019, 12:24:47 AM »
Vortex,
this too is interessant.
If I don't use
invoke  DialogBoxParam
but
Dialog "Status Bar......  and
CallModalDialog

it works as well, but the status window has a SIZEGRIP without including SBARS_SIZEGRIP in the style

Here the source.

;-----------------------------------
include \masm32\include\masm32rt.inc

IDW_STATBAR equ 1000

.data

sbtext      db 'Status bar',0

.data?

hStatusBar  dd ?
hInstance   dd ?
.code

start:

    invoke  GetModuleHandle,0
    mov hInstance,eax

    call status_Testdialog
    invoke  ExitProcess,eax

;---------------------------------
status_Testdialog proc

Dialog "Status Bar...","Arial",12,WS_VISIBLE+DS_CENTER+WS_SYSMENU+WS_THICKFRAME,1,0,0,170,140,1024

DlgButton 'Cancel',WS_VISIBLE+BS_DEFPUSHBUTTON,   79,25,35,10,IDCANCEL
CallModalDialog hInstance,0,STATUS_TESTDIALOG,NULL   

ret
status_Testdialog endp
;---------------------------------

STATUS_TESTDIALOG proc,hwnd,uMsg,wparam,lparam

mov ebx,uMsg
   cmp   ebx,WM_COMMAND
   je   wm_command
   cmp   ebx,WM_CLOSE
   je   wm_close
   cmp   ebx,WM_INITDIALOG
   je   wm_initdialog
   jmp   finish


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
jmp finish

wm_command:
   cmp   [wparam],IDCANCEL
   je   wm_close

finish:
xor eax,eax
ret

wm_close:
INVOKE   EndDialog,hwnd,0
ret

ret

STATUS_TESTDIALOG endp
;================================

END start


jj2007

  • Member
  • *****
  • Posts: 10322
  • Assembler is fun ;-)
    • MasmBasic
Re: Change the color of the statusbar/window
« Reply #24 on: May 07, 2019, 12:40:24 AM »
trying to compile MapViewerWithRedStatusBar.asm I get an error

Which error? Assemblers produce typically something like "Tmp_File.asm(9) : Error A2210: Syntax error: bla"...

I also wonder why you see the "## deb: excluded ..." message, it appears only if you debug Windows messages.

TimoVJL

  • Member
  • ****
  • Posts: 525
Re: Change the color of the statusbar/window
« Reply #25 on: May 07, 2019, 12:43:12 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
...
May the source be with you

clamicun

  • Member
  • ***
  • Posts: 347
Re: Change the color of the statusbar/window
« Reply #26 on: May 07, 2019, 01:31:04 AM »
Which error? Assemblers produce typically something like "Tmp_File.asm(9) : Error A2210: Syntax error: bla"...

What can I say

*** MasmBasic version 02.05.2019 ***
\masm32\MasmBasic\Res\MbGui.asm(3441) : Error A2164: Empty (null) string
 repargA(85)[MasmBasic.inc]: Macro called from
  uChr$(1)[MasmBasic.inc]: Macro called from
   \masm32\MasmBasic\Res\MbGui.asm(3441): Included by
    E:\masm32\examples\jjs_beispiel\MapViewerWithRedStatusBar.asm(1): Main line code
## MasmBasic GUI build ##
## deb: excluded WM_MOUSEMOVE, WM_NCHITTEST, WM_SETCURSOR, WM_GETICON, WM_NCMOUSEMOVE, WM_MOVING, WM_ENTERIDLE ##
## creating 3 controls ##
MapViewerWithRedStatusBar.asm: 62 lines, 1 passes, 236 ms, 0 warnings, 1 errors
_
Assembly Error
Drücken Sie eine beliebige Taste . . .

Or the asc.file

** Start E:\masm32\MasmBasic\Res\bldallRM.bat **
**** 32-bit assembly ****

*** Assemble, link and run MapViewerWithRedStatusBar ***



MapViewerWithRedStatusBar.rc (4): error RC2135 : file not found: \Masm32\MasmBasic\Res\Europe.dmi


MapViewerWithRedStatusBar.rc (5): error RC2135 : file not found: \Masm32\MasmBasic\Res\Europe.map


MapViewerWithRedStatusBar.rc (6): error RC2135 : file not found: \Masm32\MasmBasic\Res\MapsInMasmBasic.asc
*** Resource "MapViewerWithRedStatusBar.rc" could not be created ***

jj2007

  • Member
  • *****
  • Posts: 10322
  • Assembler is fun ;-)
    • MasmBasic
Re: Change the color of the statusbar/window
« Reply #27 on: May 07, 2019, 02:03:13 AM »
Thanks a lot, clamicun. The rc missing files message is easy to solve, download what's missing. The Error A2164 is weird, though; it works fine here. It could be an issue with the assembler. What are you using, UAsm64, the default for RichMasm? Which version?

AW

  • Member
  • *****
  • Posts: 2583
  • Let's Make ASM Great Again!
Re: Change the color of the statusbar/window
« Reply #28 on: May 07, 2019, 02:08:05 AM »
I don't know what you are talking about but there are no differences in these respects between dialog and main window.


jj2007

  • Member
  • *****
  • Posts: 10322
  • Assembler is fun ;-)
    • MasmBasic
Re: Change the color of the statusbar/window
« Reply #29 on: May 07, 2019, 02:22:59 AM »
I don't know what you are talking about but there are no differences in these respects between dialog and main window.

Correct. As discussed above, it's not the difference between window and dialog (there isn't any), but rather the use of common controls version 5.82 (pre-XP) and version 6.16+ (Win7 and after). 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).