Invisible panel control events...

  • Thread starter Thread starter shumaker
  • Start date Start date
S

shumaker

How do I make a panel control invisible, but still recieve events?

I have a panel that I set visible= false, and over it I am using GDI+
to paint a grid of rectangles. It has to be invisble or else it covers
up the GDI+. However, it is not firing the mousedown and up events
while it is not visible. I am setting the visible property using VS
through the properties window.

I kind of anticipated that an invisble control would still recieve the
click events, but I guessed wrong. I'm not sure how to proceed on
this. Maybe if there is a way to set the control to 100% transparent?
 
How do I make a panel control invisible, but still recieve events?

I have a panel that I set visible= false, and over it I am using GDI+
to paint a grid of rectangles. It has to be invisble or else it covers
up the GDI+. However, it is not firing the mousedown and up events
while it is not visible. I am setting the visible property using VS
through the properties window.

I kind of anticipated that an invisble control would still recieve the
click events, but I guessed wrong. I'm not sure how to proceed on
this. Maybe if there is a way to set the control to 100% transparent?

You can't. Just make the panel visible and make it the same size as what you
are painting and then paint onto the panel only. If you need mouse movements
for a subsection of your painting then do that in code.

Michael
 
"paint onto the panel only"

I don't guess I understand that part...
When I paint my rectangles with GDI+ they don't show up if the panel is
visible. It's like the panel is getting painted after my GDI+ does
when the onpaint event is fired.

Thanks for your help.
 
"paint onto the panel only"

I don't guess I understand that part...
When I paint my rectangles with GDI+ they don't show up if the panel is
visible. It's like the panel is getting painted after my GDI+ does
when the onpaint event is fired.

The form will have the WS_CLIPCHILDREN style which will mean that any
painting to the form will not paint over any of the controls. It's not that
the panel paints over it, it's that painting never occurs over the panel to
start with. What you should be doing is painting to the panel, not the form.
You can use the panel's paint event instead of the forms OnPaint override,
or if you want to use the panel's OnPaint override you'll need to inherit
it.

Michael
 
Michael C,

What is more simple than hittesting against a pixel (point)? Just compare
the mouse coordinates with the point location . For better user experiance
you can add some interval around the point.
 
Thanks Michael. I didn't reallize there was an onpaint event just for
the panel.

OnPaint comes from Control which all controls and forms inherit from.

Michael
 

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

Back
Top