Board index » delphi » graphics API questions (brushes, pens)

graphics API questions (brushes, pens)

I've been messing around a bit with bitmapped brushes, and have come
across a curiousity - I can't seem to change the foreground color of a
bitmapped brush.  If I select one of the stock brush styles, I can
change its color via brush.color.  Also can change the background via
a call to setBkColor() api call.  Works great.

However, If I define a bitmapped brush (8x8 monochrome), I can set the
background color OK, but as soon as I specify a foreground color for
the brush the bitmap definition seems to be lost, as the brush paints
a solid color.  Is this standard Windows behavior? Seems to me you
should be able to change both the foreground and background colors for
a brush.

Any suggestions?

-- Second question --

I would like to be able to draw lines on a canvas using any
combination of pen styles and line widths.  However, changing the
width to any value but 1 (or 0) creates a solid pen.  I have seen
packages (Visio, for example) that are able to create heavy dashed
(dotted, etc.) lines - How is this accomplished?  

Also, is it possible to define new pen styles? If I wanted to create a
'dash dot dot dot dot dash' line style, how would I go about it?

Any input would be greatly appreciated.

- Steve

---------------------------------------------
Opinions expressed do not necessarily reflect
those of my employer.

Steve Davidson
sdpi...@wolfenet.com

Para/Matrix Solutions, Inc.
Specialists in Application Development
and Training
---------------------------------------------

 

Re:graphics API questions (brushes, pens)


Answered my own question.  Seems that bitmapped brushes use the font
color for the current DC to draw the foreground color of a brush.  
- WIERD. -

Oh, well - seems to be standard windows behavior.

So, to recap:

If you use a standard brush with a style of, say, bsCross,  you change
the colors as follows:
        foreground: brush.color
        background: setBkColor(...)

If you create a brush with a bitmap, the colors are changed via:
        foreground: font.color
        background: setBkColor(...)

If anyone has a better way, PLEASE let me know.

- Steve
---------------------------------------------
Opinions expressed do not necessarily reflect
those of my employer.

Steve Davidson
sdpi...@wolfenet.com

Para/Matrix Solutions, Inc.
Specialists in Application Development
and Training
---------------------------------------------

Other Threads