Some miscellaneous newbie 2005/.Net 2 questions

P

Peter Webb

These have all been bugging me for a while.

1. myBuffer.Render

I use manual double buffering, it works well (no flicker, and suits the
logic of my app). Accordingly my on_Paint override is:

protected override void OnPaint(PaintEventArgs pe)
{
//base.OnPaint(pe);
myBuffer.Render();
}

When the window is maximised from 1024x768 to 1024x1280, my application runs
at about half the speed, even if the larger area is not used. It appears
that my app must in fact be spending all its time rendering.

Now, I know which sections have changed - at the very least, I can determine
if the animation ever goes outside the 1024x768 box, and in practice I can
do much better.

What I want to be able to do is something like:

myBuffer.Render(a Rect providing the part to render);

or even better:

myBuffer.Render(a list of Rects of possibly overlapping areas I have
changed);

However, I can't find anything like this, it seems a very obviously useful
thing to have. What am I missing, and what can I do differently and
hopefully easily?

2. Wait for button click

I often need to wait for either a specific button to be pressed or for some
number of seconds.

Currently I just poll every 10 mS as follows:

private void waitforstop(int timer)
{
for (int icount = 0; icount < timer; icount += 10)
{ if (!stopflag) Thread.Sleep(10); Application.DoEvents(); };
}

(Where stopflag is set by clicking the stop button).

I know that polling a button is wrong. What is the right way? What if I want
to wait until *any* button is pressed (or other user interaction) or n
seconds elapses?

3. Movable Controls

I note that some controls - such as ColorDialog - are movable and hold focus
(much like MessageBox, though that is a method not a control). I would love
to be able to have a panel or groupbox that worked like that. Is there
something I can use as a base, or do I have to wrap it into a new form to
get this functionality? Or some other way to do it, staying within the
standard stuff in VS2005?

4. The IDE

I only use a small proportion of its facilities. Can anybody refer me to
some good documentation on how the IDE works, and even better a tutorial on
how to best use it for development and debugging?


Thanks.


Peter Webb
 
S

solandre

1. im not quiet sure if it is what you need (read about it, but never
used it): the PaintEventArg object (supposedly a control) has a
"ClipRectangel"-property, which should contain the area which to
repaint. in general read about the "clipping region".- maybe this
helps.

2. check for the button being clicked by the events. waiting some time
can be done by a different thread, which you put asleep for that
amount of time. if the button gets pressed earlier, the thread is
aborted. hmmmhmmm somehow this solution sounds expensive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top