Results 1 to 12 of 12

Thread: Oval UserControl

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    8

    Oval UserControl

    I would like to create a VB usercontrol that contains an oval shape. I want a dragover event to occur when the source touches the oval shape rather than the rectangular extent of themy usercontrol. It this possible? Many thanks in advance

    Jeffow

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Oval UserControl

    I can think of two ways to handle this. The first one is very easy but requries the oval to be in one solid colour. The second requires some math calculation to check if the mouse X and Y position is inside the shape.

    Let me know if you have the shape filled with a solid color or not.

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Oval UserControl


  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    8

    Re: Oval UserControl

    In reply to the question raised by Joacim - yes, the shape will always be solid filled, so I would like to hear your idea.

    many Thanks

    Jeffow

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Oval UserControl

    Quote Originally Posted by jeffow
    In reply to the question raised by Joacim - yes, the shape will always be solid filled, so I would like to hear your idea.
    In that case you could simply check the the color of the point the mouse is over in the MouseMove event.
    VB Code:
    1. If UserControl.Point(X, Y) = Shape1.FillColor Then
    2.     'do whatever
    3. End If

  6. #6
    Addicted Member Max_aka_NOBODY's Avatar
    Join Date
    Jul 2004
    Location
    Amman, Jordan
    Posts
    179

    Re: Oval UserControl

    But if he uses an antialiased picture of the oval in an image control for example that won't work completely. Nonetheless, it wouldn't be much of a problem.

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Oval UserControl

    Quote Originally Posted by Max_aka_NOBODY
    But if he uses an antialiased picture of the oval in an image control for example that won't work completely. Nonetheless, it wouldn't be much of a problem.
    No it wouldn't. But he doesn't so it doesn't matter. I just provided a very simple solution without going in to any APIs or advanced mathematical code.

    Another solution would be to simply set the BackStyle of the UserControl to Transparant, since the mouse move event will not be fired while the mouse is over a transparent part.

  8. #8
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Oval UserControl

    Quote Originally Posted by Joacim Andersson
    No it wouldn't. But he doesn't so it doesn't matter. I just provided a very simple solution without going in to any APIs or advanced mathematical code.

    Another solution would be to simply set the BackStyle of the UserControl to Transparant, since the mouse move event will not be fired while the mouse is over a transparent part.
    Apparently, if you set the BackStyle to transparent... none of the components in it are visible (similar as if the usercontrol was invisible). Is there anything else that needed to be set to avoid this??
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Oval UserControl

    Quote Originally Posted by Mc Brain
    Apparently, if you set the BackStyle to transparent... none of the components in it are visible (similar as if the usercontrol was invisible). Is there anything else that needed to be set to avoid this??
    That's not true. Put a Shape control on a usercontrol, set the BackStyle to transparent and see for yourself. The Shape is still visible.

    EDIT: See the attached image, as you can see the UserControl is transparent but the Shape control is visible.
    Attached Images Attached Images  
    Last edited by Joacim Andersson; Apr 22nd, 2005 at 08:18 AM.

  10. #10
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Oval UserControl

    Ok, you're right. I opened a new project and was able to do it. I don't know why but I couldn't on the other one. However, if you use an Image (with transparent backgound), the effect is not seen.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  11. #11

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    8

    Re: Oval UserControl [closed]

    Many Thanks for all the input. I think I now consider this resolved.

    jeffow

  12. #12
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Oval UserControl

    When a question has been resolved please edit your origional post in the thread and add the word [RESOLVED] to the title. You should also use the green checkmark as the post icon.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width