By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,971 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,971 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

Sep 26 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
te******@hotmail.com wrote:
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.

Sep 27 '06 #2

P: n/a
Brian Tkatch wrote:
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. :)

Sep 28 '06 #3

P: n/a

te******@hotmail.com wrote:
Brian Tkatch wrote:
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. :)
Kewl. Glad i could help.

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

B.

Sep 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.