Detect right-click in MDI container's client area?

T

teslar91

I need to display a tiled image in the MDI container form's client
area, and also detect right-clicks in that area. How do you do that?

So far, I've unsuccessfully tried:

1) Placing my image in the form's BackgroundImage, and creating a
MouseUp event for the form. The event never fires.
2) Placing a Picturebox in the Form, docked to fill, and moving my
image and MouseUp event to that. Now the event fires, but the
Picturebox covers all my child forms. Sending the Picturebox to the
back didn't change anything.
3) Googling for the answer helped with dozens of my other silly VB.NET
questions, but I can't find a solution for this one.

Thanks in advance.
 
B

Brian Tkatch

I need to display a tiled image in the MDI container form's client
area, and also detect right-clicks in that area. How do you do that?

So far, I've unsuccessfully tried:

1) Placing my image in the form's BackgroundImage, and creating a
MouseUp event for the form. The event never fires.
2) Placing a Picturebox in the Form, docked to fill, and moving my
image and MouseUp event to that. Now the event fires, but the
Picturebox covers all my child forms. Sending the Picturebox to the
back didn't change anything.
3) Googling for the answer helped with dozens of my other silly VB.NET
questions, but I can't find a solution for this one.

Thanks in advance.

A wild guess, not sure if it makes sense:

Find the MDIClient object and add a Handler to get the mouse-up event
in the client area.

Dim The_MDIClient As MdiClient
For Each Current_Control As Control In Me.Controls
If TypeOf Current_Control Is MdiClient Then
The_MDI_Client = Current_Control
AddHandler The_MDIClient.MouseUp, AddressOf The_MDIClient_MouseUp
Exit For
End If
Next

Private Sub The_MDIClient_MouseUp(ByVal sender As Object, ByVal e As
System.EventArgs)
(put some code here)
End Sub

Obviously, the name "The_MDIClient_MouseUp" can be anything as long as
it is the same in both places. And, make sure to change the incoming
arguments to match a real MouseUp event.

HTH,
B.
 
T

teslar91

Brian said:
A wild guess, not sure if it makes sense:
-snip-

Works perfectly, thank you! I never considered the possibility that
the client area might be a separate control. VB.NET continues to
confuse and amaze me. :)
 
B

Brian Tkatch

-snip-

Works perfectly, thank you! I never considered the possibility that
the client area might be a separate control. VB.NET continues to
confuse and amaze me. :)

Kewl. Glad i could help.

Indeed, i got the MDIClient area trick from someone else when i needed
it. :)

B.
 

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