Click to See Complete Forum and Search --> : how to draw string with opaque background
jkristia
November 15th, 2005, 05:30 PM
This is probably really simple, I just can't figure it out right now.
I need to keep refreshing a string on a user defiend control, and now my problem is that I can't figure out how to set the DrawString to fill the background of the string with a backgrounbd color. The obvious way is to fill a rectangle before drawing the string, but this gives some flickering which of course I don't want, but I can I set the graphics to "DrawStringWithOpaqueBackground" ?
Jesper
darwen
November 16th, 2005, 12:01 AM
Try drawing the text to a bitmap, which has is background colour filled, and then draw the bitmap to screen.
Darwen.
jkristia
November 16th, 2005, 11:09 AM
I have enabled double buffering for my controls, so I'm trying to see if there is a way to 'suspend' the painting until I'm done and then tell it to refresh afterwards. After some searching I found an example where they say BeginUpdate tells the control to not perform and onscreen painting and EndUpdate tells it to refresh the screen with the buffer. But I'm not sure this is correct since I cant see any BeginUpdate on a control.
Any ideas as how to paint to the buffer instead of the screen and then force an update (note, I'm NOT calling Update or Refresh as I don't want to repaint the entire control)
Jesper
jkristia
November 16th, 2005, 11:26 AM
I have now optimized my Paint to only paint the area of the passed in e.ClipRectangle, instead of as before always repaint the entire control. So now when I need to refresh just the text, I can call Invalidate(rect) where the rect is the rectangle for the text. This works, but there must be an easier way of doing it.
Something like this would be nice.
BeginUpdate // lock all paint, and draw directly the the buffer
DrawText
EndUpdate // refresh screen
Any idea if that is possible?
Jesper
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.