1、如何在form上指定位置写字?例如在坐标为(100,100)的位置显示hello
2、当form画的线段变化后,原来的线段更新掉,显示当前的图画
不清楚的地方,我在线回答

解决方案 »

  1.   

    1.
    form1.Currentx = 100
    form1.Currenty = 100
    form1.print "hello"2.
    form1.cls(不知是不是这样,没太明白)
      

  2.   

    (1)form.CurrentX=100
    form.CurrentY=100
    form.Print "hello"
    (2)form.cls
       call DrawLine()
      

  3.   

    放在moduel:Option ExplicitPublic Const DT_BOTTOM = &H8
    Public Const DT_CALCRECT = &H400
    Public Const DT_CENTER = &H1
    Public Const DT_EXPANDTABS = &H40
    Public Const DT_EXTERNALLEADING = &H200
    Public Const DT_LEFT = &H0
    Public Const DT_NOCLIP = &H100
    Public Const DT_NOPREFIX = &H800
    Public Const DT_RIGHT = &H2
    Public Const DT_SINGLELINE = &H20
    Public Const DT_TABSTOP = &H80
    Public Const DT_TOP = &H0
    Public Const DT_VCENTER = &H4
    Public Const DT_WORDBREAK = &H10Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End TypeType SIZE
            cx As Long
            cy As Long
    End TypeDeclare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
    Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hDC As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hDC As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As SIZE) As Long
    放在form:
    Option ExplicitConst LongStr = "Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text."Private Sub Command1_Click()
        Dim r As RECT, s As SIZE
        
        r.Left = 50: r.Top = 20
        DrawText Me.hDC, "Draw Text Test", 14, r, DT_CALCRECT
        Line (r.Left, r.Top)-(r.Right, r.Bottom), RGB(255, 255, 0), BF
        DrawText Me.hDC, "Draw Text Test", 14, r, 0
        
        r.Left = 50: r.Top = 50: r.Right = 300
        DrawText Me.hDC, LongStr, Len(LongStr), r, DT_CALCRECT Or DT_WORDBREAK
        Line (r.Left, r.Top)-(r.Right, r.Bottom), RGB(255, 255, 0), BF
        DrawText Me.hDC, LongStr, Len(LongStr), r, DT_WORDBREAK
    End Sub