dimanche 30 novembre 2014

How to make graphics created with CreateGraphics() always visible on control without flickering


Vote count:

0




I have custom control. I have OnPaint() event defined there. Let's say it's a text editing control. I want to display custom caret overlay. I created a Graphics object with CreateGraphics(). If on each blink timer tick I call the code which draws caret - it's visible. After some painting in OnPaint() my caret disappears. It can be redrawn, but when I tried to put DrawCaret() invocation at the end of main OnPaint() handler nothing happens. The caret is not drawn, or it's drawn and cleared.


Forcing DrawCaret() in various places in code causes ugly flickering at best, does nothing at worst. When I have DrawCaret() in blinkTimer_Tick() event handler - it's drawn, but it flickers irregularly.


And no, I don't want to use Win32 Caret - its color cannot be set. I need to draw my own caret and it has to blink.


If it has to blink, I assume I can't use control's OnPaint() event handler.



asked 21 secs ago

Harry

634






How to make graphics created with CreateGraphics() always visible on control without flickering

Aucun commentaire:

Enregistrer un commentaire