Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
SimpleData26-Feb-10 4:24
SimpleData26-Feb-10 4:24 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Dan Mos26-Feb-10 4:34
Dan Mos26-Feb-10 4:34 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
SimpleData26-Feb-10 4:40
SimpleData26-Feb-10 4:40 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Dan Mos26-Feb-10 4:47
Dan Mos26-Feb-10 4:47 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
SimpleData26-Feb-10 4:54
SimpleData26-Feb-10 4:54 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Dan Mos26-Feb-10 5:02
Dan Mos26-Feb-10 5:02 
GeneralRe: Drawing onto a Windows Form without freezing it [modified] Pin
Luc Pattyn26-Feb-10 6:44
sitebuilderLuc Pattyn26-Feb-10 6:44 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Saksida Bojan26-Feb-10 4:43
Saksida Bojan26-Feb-10 4:43 
Of course it keep freezing. In orther to respond, you need to make sure it only redraws once. And use timer.Tick event and forcfully call OnPaint by calling Invalidate(). Do not call OnPaint() directly. Invalidate works like a message pump (Or at least i think so). If it is called 3 times and redraw hasn't occourt, it will only redraw once, and clear quee.

other option is to put onto another thread. But i do not recomend. I would recomend a timer.

ps: Make sure to call dispose on a PEN, to clear unmanaged resources.
I would recomend you use only this code inside OnPaint. And make another Thread like a timer to Invalidate(), or OnPaint (Forcfully) as long as it doesn't call too frequent.

if (buff == 0)
    dc.DrawRectangle(CyanPen, x, y, 1, 1);
if (buff == 1)
    dc.DrawRectangle(MagentaPen, x, y, 1, 1);
if (buff == 2)
    dc.DrawRectangle(YellowPen, x, y, 1, 1);
if (buff == 3)
    dc.DrawRectangle(BlackPen, x, y, 1, 1);

GeneralRe: Drawing onto a Windows Form without freezing it Pin
SimpleData26-Feb-10 5:17
SimpleData26-Feb-10 5:17 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Saksida Bojan26-Feb-10 5:28
Saksida Bojan26-Feb-10 5:28 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
SimpleData26-Feb-10 5:44
SimpleData26-Feb-10 5:44 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Saksida Bojan26-Feb-10 7:00
Saksida Bojan26-Feb-10 7:00 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Luc Pattyn26-Feb-10 6:46
sitebuilderLuc Pattyn26-Feb-10 6:46 
QuestionQuad Tree With images Pin
mallikharjunrao8426-Feb-10 3:17
mallikharjunrao8426-Feb-10 3:17 
AnswerRe: Quad Tree With images PinPopular
RugbyLeague26-Feb-10 3:29
RugbyLeague26-Feb-10 3:29 
GeneralRe: Quad Tree With images Pin
Pete O'Hanlon26-Feb-10 5:15
mvePete O'Hanlon26-Feb-10 5:15 
GeneralRe: Quad Tree With images Pin
Keith Barrow26-Feb-10 5:27
professionalKeith Barrow26-Feb-10 5:27 
QuestionListView Column Sort Arrow Pin
#realJSOP26-Feb-10 3:17
mve#realJSOP26-Feb-10 3:17 
AnswerTry this Pin
Pete O'Hanlon26-Feb-10 5:39
mvePete O'Hanlon26-Feb-10 5:39 
GeneralRe: Try this Pin
#realJSOP26-Feb-10 9:02
mve#realJSOP26-Feb-10 9:02 
GeneralRe: Try this Pin
Pete O'Hanlon26-Feb-10 9:46
mvePete O'Hanlon26-Feb-10 9:46 
GeneralRe: Try this Pin
#realJSOP27-Feb-10 0:55
mve#realJSOP27-Feb-10 0:55 
GeneralRe: Try this Pin
#realJSOP27-Feb-10 3:58
mve#realJSOP27-Feb-10 3:58 
GeneralRe: Try this Pin
Pete O'Hanlon1-Mar-10 1:12
mvePete O'Hanlon1-Mar-10 1:12 
GeneralRe: Try this Pin
Pete O'Hanlon1-Mar-10 9:34
mvePete O'Hanlon1-Mar-10 9:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.