Hello everybody,

I'm trying to make gradient titlebar in windows 98. The following code should work and doesn't return any errors but nothing happens:

invoke GetWindowRect,hWnd ,ADDR rect

invoke GetWindowDC,hWnd
mov hdc,eax

invoke DrawCaption,hWnd ,hdc,ADDR rect,DC_GRADIENT
invoke ReleaseDC,hWnd ,hdc


Any help or suggestions appreciated.

best regards,


czDrillard
Posted on 2003-04-20 11:08:43 by czDrillard
Well, the window DC is originated at the upper left corner of the window, while the rectangle returned is relative to the screen. Use GetWindowExtEx instead.
This could maybe work:


push esi
invoke GetWindowDC,hWnd
mov esi,eax
invoke GetWindowExtEx,esi,ADDR rect+8
xor eax,eax
mov [rect],eax
mov [rect+4],eax
mov dword ptr [rect+12],16
invoke DrawCaption,hWnd,esi,ADDR rect,DC_GRADIENT
invoke ReleaseDC,hWnd,esi
pop esi
Posted on 2003-04-20 11:34:00 by Sephiroth3
Thanks for your reply Sephiroth3,

I tried your code (had to typecast rect and rect+4 to assemble without error) but still title bar is not filled with gradient color :confused: Any ideas?

best regards,

czDrillard
Posted on 2003-04-20 22:05:39 by czDrillard
Hmm. What code does MASM actually generate for this? Does it alter the offsets in any way?
Posted on 2003-04-21 06:22:28 by Sephiroth3
Well I suppose is rect.top in MASM, is rect.left, is rect.bottom.
Posted on 2003-04-21 07:14:59 by roticv
Hello everybody,

By replying to my own question I'm indicating that I didn't research the subject thoroughly enough the first time:o I was looking through a copy of a very old knowledge base from Microsoft and found a complete explanation under Q99046 For those interested the proceedure is as follows:

1) Get the current window's rectangle using GetWindowRect()

2) Get device context to window using GetWindowDC()

3) Calculate dimensions of caption bar

4) Render the caption

It is also necessary to respond to the messages WM_NCPAINT, WM_NCATIVATE, WM_SETTEXT, and WM_SYSCOMMAND after the message has been passed to DefWindowProc()

best regards,

czDrillard
Posted on 2003-04-21 09:09:41 by czDrillard