Draw Triangle

Dear Sir ,
While searching MSDN , for the code for drawing triangle , I found relative functions like RECTANGLE() .......... POLYGON ()
...... as well as one LINETO() .........
This could be used to draw the triangle , but it does not specify the current position to start with . Can you plz guide me how to enter my curret / ptesent position , which shall be used for starting point of the first line , and finally the end_point for the third line.
MSDN is silent anout it , or at least I could not locate it.

I shall be highly thankfull , if a friend guides me to the code , or give one of his own to start with . The main objectivew is to draw one line and sum up to a triangle.

I do not want to use DDL function . Instead i want it to be a WIN32 application . like we create buttons , rectangles , list boxes etc.

Regards,
ah.

Comments

  • [b][red]This message was edited by DrMarten at 2006-8-3 16:53:51[/red][/b][hr]
    : Dear Sir ,
    : While searching MSDN , for the code for drawing triangle , I found relative functions like RECTANGLE() .......... POLYGON ()
    : ...... as well as one LINETO() .........
    : This could be used to draw the triangle , but it does not specify the current position to start with . Can you plz guide me how to enter my curret / ptesent position , which shall be used for starting point of the first line , and finally the end_point for the third line.
    : MSDN is silent anout it , or at least I could not locate it.
    :
    : I shall be highly thankfull , if a friend guides me to the code , or give one of his own to start with . The main objectivew is to draw one line and sum up to a triangle.
    :
    : I do not want to use DDL function . Instead i want it to be a WIN32 application . like we create buttons , rectangles , list boxes etc.
    :
    : Regards,
    : ah.
    ______________________________________________________________________

    Hi,

    Sounds like you want a TRIANGLE or POLYGON feature in the VB program like the one in MSPAINT right?

    If so i can't help you as you would probably have to create a DLL or CLASS to do this. Besides i mostly know VB.Net instead.

    This from HELP on the LINE command though.>>

    This example uses the Line method to draw concentric boxes on a form. To try this example, paste the code into the General section of a form. Then press F5 and click the form.
    [code]
    Private Sub Form_Click ()
    Dim CX, CY, F, F1, F2, I ' Declare variables
    ScaleMode = 3 ' Set ScaleMode to pixels.
    CX = ScaleWidth / 2 ' Get horizontal center.
    CY = ScaleHeight / 2 ' Get vertical center.
    DrawWidth = 8 ' Set DrawWidth.
    For I = 50 To 0 Step -2
    F = I / 50 ' Perform interim
    F1 = 1 - F: F2 = 1 + F ' calculations.
    Forecolor = QBColor(I Mod 15) ' Set foreground color.
    Line (CX * F1, CY * F1)-(CX * F2, CY * F2), , BF
    Next I
    DoEvents ' Yield for other processing.
    If CY > CX Then ' Set DrawWidth.
    DrawWidth = ScaleWidth / 25

    Else
    DrawWidth = ScaleHeight / 25
    End If
    For I = 0 To 50 Step 2 ' Set up loop.
    F = I / 50 ' Perform interim
    F1 = 1 - F: F2 = 1 + F ' calculations.
    Line (CX * F1, CY)-(CX, CY * F1) ' Draw upper-left.
    Line -(CX * F2, CY) ' Draw upper-right.
    Line -(CX, CY * F2) ' Draw lower-right.
    Line -(CX * F1, CY) ' Draw lower-left.
    Forecolor = QBColor(I Mod 15) ' Change color each time.

    Next I
    DoEvents ' Yield for other processing.
    End Sub
    [/code]


    Regards,

    Dr M.

  • : [b][red]This message was edited by DrMarten at 2006-8-3 16:53:51[/red][/b][hr]
    : : Dear Sir ,
    : : While searching MSDN , for the code for drawing triangle , I found relative functions like RECTANGLE() .......... POLYGON ()
    : : ...... as well as one LINETO() .........
    : : This could be used to draw the triangle , but it does not specify the current position to start with . Can you plz guide me how to enter my curret / ptesent position , which shall be used for starting point of the first line , and finally the end_point for the third line.
    : : MSDN is silent anout it , or at least I could not locate it.
    : :
    : : I shall be highly thankfull , if a friend guides me to the code , or give one of his own to start with . The main objectivew is to draw one line and sum up to a triangle.
    : :
    : : I do not want to use DDL function . Instead i want it to be a WIN32 application . like we create buttons , rectangles , list boxes etc.
    : :
    : : Regards,
    : : ah.
    : ______________________________________________________________________
    :
    : Hi,
    :
    : Sounds like you want a TRIANGLE or POLYGON feature in the VB program like the one in MSPAINT right?
    :
    : If so i can't help you as you would probably have to create a DLL or CLASS to do this. Besides i mostly know VB.Net instead.
    :
    : This from HELP on the LINE command though.>>
    :
    : This example uses the Line method to draw concentric boxes on a form. To try this example, paste the code into the General section of a form. Then press F5 and click the form.
    : [code]
    : Private Sub Form_Click ()
    : Dim CX, CY, F, F1, F2, I ' Declare variables
    : ScaleMode = 3 ' Set ScaleMode to pixels.
    : CX = ScaleWidth / 2 ' Get horizontal center.
    : CY = ScaleHeight / 2 ' Get vertical center.
    : DrawWidth = 8 ' Set DrawWidth.
    : For I = 50 To 0 Step -2
    : F = I / 50 ' Perform interim
    : F1 = 1 - F: F2 = 1 + F ' calculations.
    : Forecolor = QBColor(I Mod 15) ' Set foreground color.
    : Line (CX * F1, CY * F1)-(CX * F2, CY * F2), , BF
    : Next I
    : DoEvents ' Yield for other processing.
    : If CY > CX Then ' Set DrawWidth.
    : DrawWidth = ScaleWidth / 25
    :
    : Else
    : DrawWidth = ScaleHeight / 25
    : End If
    : For I = 0 To 50 Step 2 ' Set up loop.
    : F = I / 50 ' Perform interim
    : F1 = 1 - F: F2 = 1 + F ' calculations.
    : Line (CX * F1, CY)-(CX, CY * F1) ' Draw upper-left.
    : Line -(CX * F2, CY) ' Draw upper-right.
    : Line -(CX, CY * F2) ' Draw lower-right.
    : Line -(CX * F1, CY) ' Draw lower-left.
    : Forecolor = QBColor(I Mod 15) ' Change color each time.
    :
    : Next I
    : DoEvents ' Yield for other processing.
    : End Sub
    : [/code]
    :
    :
    : Regards,
    :
    : Dr M.
    : [blue]
    Dear sir,
    Many thanks for the reply .
    Your guideline referes to DDL algorthm , which does not give smooth lines. I managed to get a sample code from the web . It is for drawing a polygon of seven vertices. I intend to reduce it to three vertices for a triangle.
    Presently it has few bugs, so i am putting it on the board for help . Infact there are two conflicting variable , which I cannot manage to reconcile.
    Plz look into it . and help it going through.
    thanks again
    ah,
    [/blue]
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories