much confusion about forms

C

cwineman

Hello,

I've been trying to do something which I think should be very simple. I
posted about it a few days ago in this group -- "swapping controls within a
form". I think my problem is that I don't really understand how the whole
windows forms painting-updating-hiding-showing process works.

I'm looking for documentation on any of the following topics:

-When to call paint(), invalidate(), refresh() and the differences between
the calls
-When to make calls on a parent control versus a child control
-What to do when a change doesn't seem to be taking place on the GUI
-What to expect when I call Hide() or Show()
-When is it necessary to drop into lower level Win32 API calls?
-How do UI threads work? When do I need to be in one if ever?
-If I'm not in a UI thread and I need to do an update that should only be
done within a UI thread, how?

I have a couple of books on windows forms, but they really aren't that much
help. Most of the things described in these books I can figure out by
playing around with the properties of different widgets in the VS.NET IDE.
But when I run into a problem (a control isn't showing up, or isn't
updating, or is flickering), I usually don't know where to look, and I end
up fixing the problem with a lot of trial and error. Assuming I fix the
problem at all.

So any pointers to some decent documentation would be appreciated.

Thanks,

-cwineman
 
G

Guest

- Paint? im not sure i understand what you are talking about. Not a .net
standard method. There is an OnPaint() that is called by .net from internal
wndproc
- Refresh is used to invalidate the control and any child controls in it
- Invalidate is used for a more controled invalidation. u can invalidate a
specific region and can optionally invalidate all children.
- I dont understand what you mean by parent child calls
- you can expect your control / form to be hidden when you call the Hide()
method
- you can expect your control / form to be shown when you call the Show()
method
- unless you are doing subclassing of a native control you will never need
to "drop into lower level Win32"
- UI thread is the main application thread. You don't need to worry about
this unless you have a multithreaded application. In that case if you are not
in the UI thread you and you want to update the UI u have to use the
Control.Invoke() method to accomplish that.

If you are just looking to learn more about creating a custom drawn control
take a look at a few articles on www.codeproject.com. There are plenty of
useful resources.
 
C

cwineman

Thanks, Alex.

I apologize for the rambling, unclear questions. My vague understanding of
how these things work make it hard to phrase my questions better. Plus I was
frustrated with something that should have been simple, and it turns out it
was.

In my post I didn't necessarily want answers to those specific questions,
but pointers to FAQs, guidelines and examples. Like the one you provided.
Documentation on general things like what causes the screen to flicker, why
don't controls show up sometimes, why did I lose focus, "you should follow
this guideline for doing XYZ", or "if you mess with this method and don't
know what you are doing you are asking for trouble". Again, I don't
necessarily want answers, just point me to the sources of information.
Basically, so I don't waste people's time on things that have been answered.

As far as parent/child calls, you sort of refer to it in your response to
what Invalidate() does. I just mean, in what circumstances do you need to
call, say Invalidate(), on a parent control versus a child control.
Sometimes a child control is either not showing up, or doesn't look right. A
call to child.Invalidate() doesn't work. But a call to parent.Invalidate()
sometimes fixes things. I usually can never figure out why. Situations like
that are why I hoped to find some better documentation.
 

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