用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 );
自己标题上不是写了movetoex么, 难道没用?
我用了movetoex。不过还是在0,0那里开始画啊。
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
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
);
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