How do you make a dialog that has a watermark background image?

I know that is possible, because I saw it on NVIDIA detonator drivers, question is How?
Posted on 2002-01-08 14:15:05 by dxantos
I've never done this before, but I would try to do it this way....

When you create the window class, use a NULL brush.

Then in response the the WM_PAINT, bitblit a bitmap of the image to the client area of the dialog.

This way your bitmap becomes the "Background Brush" that the window uses to paint its client area

try it and see if it works for you
Posted on 2002-01-08 14:46:24 by Rockinronstar
Would WM_PAINT be the ideal message to do this on, as it doesn't pass you a dc?

And in any case, if you are going to manually get the dc, would it not be better to do it in the WM_CREATE, then you would only be doing it once, not several times a second.

Anyone have any comments on that method? Is there some kick-ass way to do it?
Posted on 2002-01-08 14:59:35 by sluggy
This simple RadASM project shows how to add bitmaps and icons to dialogbox.

Posted on 2002-01-08 15:18:11 by KetilO
The WM_PANIT message would be the ideal one to use, just call the usual Begin & End Paint functions so you get the DC, these are also alot safer for use with a Dialog than GetDC and ReleaseDC. Also make sure to return 0 in eax to ensure any controls on the dialog are drawn properly.

As for that type of watermark effect play around with greyscaled bitmaps and try using SRCAND, or possibly SRCPAINT in the BitBlt flags.

Here's an example Dialog Proc to do this
DlgProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

mov eax,uMsg
mov eax,0

invoke LoadBitmap,gIst,103
mov hBmp,eax
invoke CreateCompatibleDC,0
mov bmpDc,eax
invoke SelectObject,eax,hBmp
mov eax,1

invoke GetClientRect,hWnd,addr rect
invoke BeginPaint,hWnd,addr ps
invoke BitBlt,ps.hdc,0,0,rect.right,rect.bottom,bmpDc,0,0,SRCAND
invoke EndPaint,hWnd,addr ps
xor eax,eax

invoke DeleteObject,hBmp
invoke DeleteDC,bmpDc
invoke EndDialog,hWnd,0
mov eax,1
DlgProc EndP
Posted on 2002-01-08 15:29:33 by Eóin
Now I just saw something that threw me off....

You gotta throw that Macro my way.

Never even heard of someone creating a Case Macro for use in MAsm.

Could you post the include file for it, thanx
Posted on 2002-01-08 15:58:33 by Rockinronstar
WM_PAINT and a bitmap could work, except that in the case of the driver, when I change the color scheme the watermark changes too. I suppose its a grayscale bitmap. In openGL I could use vertex colors for doing this, but on Windows, this eludes me.

Anyone has an idea on how to do this?

Anyway, thanks for the ideas and sample code.
Posted on 2002-01-08 16:16:25 by dxantos
Change the pallete data in bitmap structure based on system metric parameters.
Posted on 2002-01-08 16:40:44 by bitRAKE
Thanks bitRake, got it.

Guess I have spent too much time using 24 bit bitmaps, I forgot about the palletized ones :grin:
Posted on 2002-01-08 16:49:01 by dxantos
It worked, except that now Im having problems with the text of the dialog. The text is drawing boxes. The image illustrates the problem,

Now, Is there any way to set the background of the text labels of a dialog, so it doesn't draw the rectangles. Because of later possible design changes, I really with to use dialogs label text, and not TextOut for doing this.
Posted on 2002-01-08 17:04:12 by dxantos
It can be done and it is also easy. Look at this old post
you will find the full explanation.
Posted on 2002-01-08 17:40:14 by LuHa
Thanks LuHa, it works :)
Posted on 2002-01-08 18:04:43 by dxantos