The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Jimg on July 05, 2007, 06:40:41 PM

Title: Scroll Bar Pattern Brush
Post by: Jimg on July 05, 2007, 06:40:41 PM
Is there an api to get the brush handle of the system pattern brush used on scroll bars?  I'm drawing my own control, and I would like to use whatever the system is using for this pattern.  I think the color is COLOR_SCROLLBAR, but doing a get GetSysColorBrush with that color returns the handle to a solid brush.
Title: Re: Scroll Bar Pattern Brush
Post by: ramguru on July 05, 2007, 08:54:56 PM
I don't see any problem, the following code fills rectangle using brush that represents scrollbar color:

.elseif eax==WM_PAINT
invoke BeginPaint, hWin, ADDR ps
invoke GetSysColorBrush, COLOR_SCROLLBAR
mov    br, eax
invoke FillRect, ps.hdc, ADDR rc, br
invoke EndPaint, hWin, ADDR ps

There is no special pattern regarding regular scrollbar, only solid color & moving shapes. If you mean windows themes, you cannot get their brushes...
Title: Re: Scroll Bar Pattern Brush
Post by: Jimg on July 05, 2007, 10:19:26 PM
Yep, that's exactly what I did, and I got solid gray.  I want the pattern that windows uses when drawing a scrollbar.
Title: Re: Scroll Bar Pattern Brush
Post by: ramguru on July 06, 2007, 08:06:22 AM
I'm not sure what you mean, but maybe this is it...

.data
rc RECT <10,10,100,100>
br dd 0
pattern dd 4 dup (0)
...

.code
...
.if eax==WM_INITDIALOG
invoke GetSysColor, COLOR_SCROLLBAR
shl    eax, 8 ;
bswap  eax ; correction for bmp to match inside-out order ... opcode requires .486
mov    ecx, 0ffffffh
mov    [pattern+ 0], ecx
mov    [pattern+ 4], eax
mov    [pattern+ 8], eax
mov    [pattern+12], ecx
invoke CreateBitmap, 2, 2, 1, 32, ADDR pattern
invoke CreatePatternBrush, eax
mov    br, eax
.elseif eax==WM_PAINT
invoke BeginPaint, hWin, ADDR ps
invoke FillRect, ps.hdc, ADDR rc, br
invoke EndPaint, hWin, ADDR ps

Title: Re: Scroll Bar Pattern Brush
Post by: zooba on July 06, 2007, 08:14:42 AM
If ramguru's solution doesn't work for you, have a look at DrawFrameControl and maybe DrawThemeBackground (if you're targeting XP).

Cheers,

Zooba :U
Title: Re: Scroll Bar Pattern Brush
Post by: Jimg on July 06, 2007, 01:10:05 PM
Ok, thanks guys.  Since windows gives you the brush for everything else with a simple api call, I just thought there would be an api to get this brush handle that I just couldn't find.