我想实现在桌面画两条线横竖两条。为什么我用lineto 画出来的起始点是0,0 。?能不能自己设置。?如果是画的虚线就更好了。如果能再设置下透明度。。

解决方案 »

  1.   

    要实现的效果。在屏幕中央画出一个十字的图案出来。不管是什么API 。只要能实现这个效果就成。
      

  2.   

    用MoveToEx移画笔位置
    The MoveToEx function updates the current position to the specified point and optionally returns the previous position. BOOL MoveToEx(
      HDC hdc,          // handle to device context
      int X,            // x-coordinate of new current position
      int Y,            // y-coordinate of new current position
      LPPOINT lpPoint   // pointer to old current position
    );
      

  3.   

    自己标题上不是写了movetoex么, 难道没用?
      

  4.   

    我用了movetoex。不过还是在0,0那里开始画啊。
      

  5.   

    Option Explicit
    Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As Long) As Long
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
    Private Const PS_SOLID = 0
    Private Sub Command1_Click()
    Dim re As Long
    Dim re1 As Long, re2 As Long, re3 As Long
    re = GetDC(0)
    re2 = MoveToEx(re, 512, 0, 0&)
    re2 = LineTo(re, 512, 768)
    re2 = MoveToEx(re, 0, 384, 0&)
    re2 = LineTo(re, 1024, 384)
    re1 = ReleaseDC(0, re)
    End Sub
      

  6.   

    http://download.csdn.net/source/2368159