Results 1 to 9 of 9

Thread: [RESOLVED] Drawing shapes in a Panel with controls

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Resolved [RESOLVED] Drawing shapes in a Panel with controls

    I am trying to draw some shapes using GDI+ in a panel that has controls in it. I need for the drawn shapes to be on top of the controls that are currently in the panel. But right now the shapes are drawn under the controls. The panel is actually a user control that I have inherited the panel control for.

    Is there anythign I can do? The drawing has to take place in the user control. Not in the forms class.

    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Drawing shapes in a Panel with controls

    I'm no GDI+ guru so I'm not sure what the answer is to your question, but I wanted to comment on something you posted that sounds a bit odd. You say that you inherited the Panel class to create a user control. If you want to create a number of controls as a unit you are supposed to inherit the UserControl class. There's an option to do so on the context menu if you right click your project in the solution explorer.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Drawing shapes in a Panel with controls

    I've inherrited the panel because I need to use the functionality of the panel (i.e ability to add controls) plus add some of my own functionality.

  4. #4
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: Drawing shapes in a Panel with controls

    you have to actually draw over the controls as well, so for every drawing operation, you need to perform it on every control the drawing will effect, and change the co-ordinates to be relative.

    if you draw a black square at 0,0 for 10,10 and there is a textbox at 5,5
    you need to use .creategraphics o nthe textbox (and this has to be done EVERYTIME the control paints, so ALL drawing operations need to be remembered) you would draw a 10,10 black square at -5,-5 ontop of the textbox's image.

    that's the only way to do it without rendering your controls useless (if you used something like my vb.net shape controls transparency method you could dump an image right overtop of all the control.. but then they arent clickable)

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Drawing shapes in a Panel with controls

    Phill... can I get an example of your shape controls transparency method. My control won't have any actual controls in it. I just used it as a simple example. It's actually used as a window to display a video feed.
    Thanks

  6. #6
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: Drawing shapes in a Panel with controls

    so you want to draw over a movie?
    that's interesting, perhaps you should be drawing over whatever control it is that is displaying the video? for example, is it a picturebox?

    if it's directX it probably isnt possible, ud have to do it within directX

    Since it's just 1 object, my method isnt really neccessary, and would be too slow.

    id recommend something like
    VB Code:
    1. sub videocontrol_onPaint(sender args blah blah)
    2.   dim g as graphics = videocontrol.creategraphics()
    3.   g.fillellipse(etc..)
    4. end sub

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Drawing shapes in a Panel with controls

    It's actually a video feed from a camera. What I need to be able to do is have the user create a circle, and the camera will zoom in to that point. I'm using direct show and attaching the video using the panels handle.

  8. #8
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: Drawing shapes in a Panel with controls

    aaaah,

    well see that changes the question quite alot, it's not how to draw onto a panel or a control at all, with directshow you are drawing video straight to display, it will go ontop of absolutely everything. You will need to use directdraw to draw ontop of it.

    I suggest ask in the "games & graphics" forum, there are quite a few directx gurus that may be able to help you.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Drawing shapes in a Panel with controls

    Well I didn't get an answer in the Game and Dev section. But I talked with a friend who is somewhat an expert with direct x and essentially said it would be to much of a pain in the butt to do. I eventually figured out a way. It may not be the best way, or a good way for that matter, but it's working. What I did was create a form. Set the background to green with no border and set the transparency key to green and made it top most. Put a timer in the panel and to check to makesure the form is always ontop of the panel. Then draw on the form using the coordinated from the panel. Just an FYI if someone ever has this problem in the future.

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