Results 1 to 6 of 6

Draw shape on userform

This is a discussion on Draw shape on userform within the Excel Questions forums, part of the Question Forums category; greets all, i have been searching around for a method to draw an angled line onto a userform. must be ...

  1. #1
    Board Regular diddi's Avatar
    Join Date
    May 2004
    Location
    Shepparton, Australia
    Posts
    2,430

    Default Draw shape on userform

    greets all, i have been searching around for a method to draw an angled line onto a userform. must be programatic as the line angle and length changes. any suggestions?
    TIA
    The more you learn, the more you realise how little you know. Excel 2003 and 2010 / Win7
    Code:
    Sub HintForGoodResults( )
        If yourcode Is indented Then
            "it is easier to for everyone to understand" AND "others are more likely to give assistance"
        Else
            "errors are much harder to find" OR "others dont bother"
        End If
    End Sub

  2. #2
    Board Regular
    Join Date
    Sep 2004
    Posts
    512

    Default Re: Draw shape on userform

    diddi
    Have a look here:

    http://www.andypope.info/vba/userformdraw.htm

    HTH
    John
    There are people who work a lot and make many mistakes. There are people who work a little and make few mistakes. I know people who don't make any mistakes.

  3. #3
    Board Regular diddi's Avatar
    Join Date
    May 2004
    Location
    Shepparton, Australia
    Posts
    2,430

    Default Re: Draw shape on userform

    thx for link
    i have had alook and modified the code. nearly got it to work except that it draws to the back-most layer on the window and i had a backgroud pic which had to stay as back layer and i couldnt work out how to incorporate the background. so reluctantly i had to give up. thx anyway
    The more you learn, the more you realise how little you know. Excel 2003 and 2010 / Win7
    Code:
    Sub HintForGoodResults( )
        If yourcode Is indented Then
            "it is easier to for everyone to understand" AND "others are more likely to give assistance"
        Else
            "errors are much harder to find" OR "others dont bother"
        End If
    End Sub

  4. #4
    Board Regular
    The other chart guy
    Andy Pope's Avatar
    Join Date
    Dec 2003
    Location
    UK
    Posts
    340

    Default Re: Draw shape on userform

    Hi,

    I the example file you can download I do use the userforms picture property to display any shapes drawn, which will replace any background image you are trying to use.

    But there is a way to display drawings on any control that has a picture property.
    Instead of using the CanvasUserform property you can make use of the CanvasGeneric property.
    Code:
        ' Will use the userforms picture property
        Set m_objDrawing.CanvasUserform = Me
    
        ' will use Image1 picture property
        Set m_objDrawing.CanvasGeneric = Me.Image1
    So you just need to add a control and position it in the area where you what the drawings to appear. You will have to revise the Left and Top properties as these will now be relative to the top left corner of the control rather than the userform.
    Your choice of control may be important as controls can appear on different layers and even changing the z-order will not allow 1 control type to appear infront of another.
    For example, labels will not appear in front of listboxes.
    Cheers
    Andy

  5. #5
    Board Regular diddi's Avatar
    Join Date
    May 2004
    Location
    Shepparton, Australia
    Posts
    2,430

    Default Re: Draw shape on userform

    gee i wish i was smart. i will have another go at it.

    since you are following the thread, i have a map of australia and select two towns from comboboxes which are plotted on to the map. there is also a movable intermediate point which allows me to plan a route between the points and calculate a straight line distance between them. what i was wanting to achieve was to be able to draw two flat arcs or lines indicating the route. when i drew the canvas, my map ended up lost.

    but now i shall try again.
    Thx for your help
    The more you learn, the more you realise how little you know. Excel 2003 and 2010 / Win7
    Code:
    Sub HintForGoodResults( )
        If yourcode Is indented Then
            "it is easier to for everyone to understand" AND "others are more likely to give assistance"
        Else
            "errors are much harder to find" OR "others dont bother"
        End If
    End Sub

  6. #6
    Board Regular diddi's Avatar
    Join Date
    May 2004
    Location
    Shepparton, Australia
    Posts
    2,430

    Default Re: Draw shape on userform

    hey andy, do you have any pdfs or links to more info about this topic? just a thought

    thx
    The more you learn, the more you realise how little you know. Excel 2003 and 2010 / Win7
    Code:
    Sub HintForGoodResults( )
        If yourcode Is indented Then
            "it is easier to for everyone to understand" AND "others are more likely to give assistance"
        Else
            "errors are much harder to find" OR "others dont bother"
        End If
    End Sub

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com