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

TimoVJL

#15
compatibility section in manifest ?

EDIT: RGB macro
;#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
May the source be with you

jj2007

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:<?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>

aw27

Compatibility section in Manifest has no influence.

jj2007

Right. Exactly the same behaviour with this manifest (MS docs):
<?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

Owner Draw works too.
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

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

jj,

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

Exactly

clamicun

#22
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

clamicun

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

Quote from: clamicun on May 06, 2019, 08:50:36 PM
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

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
...
May the source be with you

clamicun

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

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?

aw27

I don't know what you are talking about but there are no differences in these respects between dialog and main window.


jj2007

Quote from: AW 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.

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).