locked
Forms and Custom Controls within Custom Controls, and Mouse clicks. RRS feed

  • Question

  • Hello there!
    I have a simple program that contains custom controls where they are like "tabs" and the can house other custom controls with a D&D like feature. So its the base form, you click on something to "play", this "tab" custom control pops up and in it the custom control the user selected pops up into the "tab" custom control. Its like a windows window. You have a tab and an exit button, and within it contains whatever. So to my problem. I want to make this "tab" custom control move when you click on it and drag it, and when you un-click, it stops following the mouse. It seems pretty simple, but here's the underlying BIG issue. When i tried to do this myself, i started off with a simple Mouse.Click() sub, and put a MsgBox("") in it to verify that the custom control was "able to be clicked". HOWEVER, no matter where i clicked on the custom control, it could not fire the Mouse.Click() sub and the MsgBox. So my question is, is this 1) possible? , or 2) do i have to create a new property, like a AllowMouseMovement, and in it reference the parent forms' position relative to this custom controls' "position"?(which to me this sounds and looks wayy to complicated...) But anyways, if you could help, much would be appreciated. If you need the custom control for your own purposes or tests, just shoot me a msg. Thanks in advance, Devic.
    Sunday, June 23, 2013 5:53 PM

Answers

  • You should start by putting similar code in the container control to see if the mouse click is being entercepted there.  Except that a label to show the click and the clicked position is better than a message box.

    If it is the container that is being clicked then the problem is the way that your container custom control is acting as a container for the contained custom control, so you will need to show the code for your controls.  For instance, if your container control is actually a user control you will get this behaviour. 

    • Marked as answer by Youen Zen Friday, June 28, 2013 7:44 AM
    Sunday, June 23, 2013 10:39 PM

All replies

  • You could probably find something on how to do that using this search engine.

    http://social.msdn.microsoft.com/Search/en-US?query=add%20mouse%20drag%20to%20custom%20control&beta=0&ac=5


    You've taught me everything I know but not everything you know. _________________________________________________________________________________________________________________ This search engine is for MSDN Library and has many features. http://social.msdn.microsoft.com/Search/en-US?query=search%20msdn%20library&beta=0&ac=8

    Sunday, June 23, 2013 7:22 PM
  • You should start by putting similar code in the container control to see if the mouse click is being entercepted there.  Except that a label to show the click and the clicked position is better than a message box.

    If it is the container that is being clicked then the problem is the way that your container custom control is acting as a container for the contained custom control, so you will need to show the code for your controls.  For instance, if your container control is actually a user control you will get this behaviour. 

    • Marked as answer by Youen Zen Friday, June 28, 2013 7:44 AM
    Sunday, June 23, 2013 10:39 PM