809
社区成员
发帖
与我相关
我的任务
分享
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim RGBColor As Long, Red As Long, Green As Long, Blue As Long
x1 = X: y1 = Y
RGBColor = GetPixel(Me.hdc, X, Y)
GetRGBColors RGBColor, Red, Green, Blue
lblInfo.Caption = "(" & Red & "," & Green & "," & Blue & ")"
Dim Info As String
Screen.MousePointer = vbCrosshair
If Button = 1 Then
Shape1.Visible = False
LblPos.Visible = False
If Status = "draw" Then
If X > OriginalX And Y > OriginalY Then
Shape1.Move OriginalX, OriginalY, X - OriginalX, Y - OriginalY
ElseIf X < OriginalX And Y > OriginalY Then
Shape1.Move X, OriginalY, OriginalX - X, Y - OriginalY
ElseIf X > OriginalX And Y < OriginalY Then
Shape1.Move OriginalX, Y, X - OriginalX, OriginalY - Y
ElseIf X < OriginalX And Y < OriginalY Then
Shape1.Move X, Y, OriginalX - X, OriginalY - Y
End If
Info = Shape1.Width & "x" & Shape1.Height
LblPos.Move Shape1.Left + 2, Shape1.Top + 2
LblPos.Caption = Info
Screen.MousePointer = vbCrosshair
Else
Screen.MousePointer = 5
Shape1.Left = OriginalX - (NewX - X)
Shape1.Top = OriginalY - (NewY - Y)
If Shape1.Left < 0 Then Shape1.Left = 0
If Shape1.Top < 0 Then Shape1.Top = 0
If Shape1.Left + Shape1.Width > Screen.Width / 15 Then Shape1.Left = Screen.Width / 15 - Shape1.Width
If Shape1.Top + Shape1.Height > Screen.Height / 15 Then Shape1.Top = Screen.Height / 15 - Shape1.Height
LblPos.Move Shape1.Left + 2, Shape1.Top + 2
End If
Call ImageMove
Shape1.Visible = True
LblPos.Visible = True
End If
End Sub
Private Sub Form_DblClick()
If PtInRect(rc, NewX, NewY) Then
Picture1.Visible = False
Sleep 10
DoEvents
Shape1.Visible = False
ScrnCap Shape1.Left, Shape1.Top, Shape1.Left + Shape1.Width, Shape1.Top + Shape1.Height
'MsgBox "图象已经保存到剪贴板中", vbInformation, "提示"
Unload Me
End If
End Sub
Public Sub ScrnCap(Left As Long, Top As Long, Right As Long, Bottom As Long)
Dim i As Integer
Shape1.Visible = False
LblPos.Visible = False
For i = 0 To 7
Image1(i).Visible = False
Next
DoEvents
Dim rWidth As Long
Dim rHeight As Long
Dim SourceDC As Long
Dim DestDC As Long
Dim BHandle As Long
Dim Wnd As Long
Dim DHandle As Long
rWidth = Right - Left
rHeight = Bottom - Top
SourceDC = CreateDC("DISPLAY", 0, 0, 0)
DestDC = CreateCompatibleDC(SourceDC)
BHandle = CreateCompatibleBitmap(SourceDC, rWidth, rHeight)
SelectObject DestDC, BHandle
BitBlt DestDC, 0, 0, rWidth, rHeight, SourceDC, Left, Top, &HCC0020
Wnd = GetDesktopWindow
OpenClipboard Wnd
EmptyClipboard
SetClipboardData 2, BHandle
CloseClipboard
DeleteDC DestDC
ReleaseDC DHandle, SourceDC
End Sub
Public Sub MDown(X As Single, Y As Single)
End Sub
Public Function CutdSave()
Dim sFile As String
Dim SaveOpen As OPENFILENAME
SaveOpen.lStructSize = Len(SaveOpen)
SaveOpen.hwndOwner = 0&
SaveOpen.lpstrFile = String$(255, 0)
SaveOpen.nMaxFile = 255
SaveOpen.lpstrInitialDir = App.Path
SaveOpen.lpstrFilter = "位图文件(*.bmp)" + Chr$(0) + "*.bmp" + Chr$(0) + "JPEG文件(*.jpg)" + Chr$(0) + "*.jpg" + Chr$(0) + "所有文件(*.*)" + Chr$(0) + "*.*" + Chr$(0)
SaveOpen.lpstrTitle = "保存为"
SaveOpen.nFilterIndex = 2
SaveOpen.lpstrDefExt = "bmp" '初始化扩展名
If GetSaveFileName(SaveOpen) <> 0 Then
sFile = Left(SaveOpen.lpstrFile, InStr(SaveOpen.lpstrFile, Chr$(0)) - 1)
Else
Exit Function
End If
SavePicture Clipboard.GetData(), sFile
Clipboard.Clear ' 清除剪贴板
End Function
Private Sub Image2_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Integer
For i = 0 To 3
Shape3(i).Visible = False
Next
Shape3(Index).Visible = True
End Sub
Private Sub Label1_Click(Index As Integer)
End Sub
Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Screen.MousePointer = 1
For i = 0 To 3
Shape3(i).Visible = False
Next
End Sub
Public Function ImageMove()
Dim i As Integer
Image1(0).Move Shape1.Left - (Image1(0).Width / 2), Shape1.Top - (Image1(0).Height / 2)
Image1(1).Move (Shape1.Left + (Shape1.Width / 2)) - (Image1(0).Width / 2), Shape1.Top - (Image1(0).Height / 2)
Image1(2).Move (Shape1.Left + (Shape1.Width)) - (Image1(2).Width / 1.5), Shape1.Top - (Image1(2).Height / 2)
Image1(3).Move Shape1.Left - (Image1(3).Width / 2), Shape1.Top + (Shape1.Height / 2) - (Image1(3).Height / 2)
Image1(4).Move Shape1.Left - (Image1(4).Width / 2), Shape1.Top + (Shape1.Height) - (Image1(4).Height / 2)
Image1(5).Move (Shape1.Left + (Shape1.Width / 2)) - (Image1(5).Width / 2), Shape1.Top + (Shape1.Height) - (Image1(5).Height / 2)
Image1(6).Move (Shape1.Left + (Shape1.Width)) - (Image1(6).Width / 2), Shape1.Top + (Shape1.Height) - (Image1(6).Height / 2)
Image1(7).Move (Shape1.Left + (Shape1.Width)) - (Image1(7).Width / 2), Shape1.Top + (Shape1.Height / 2) - (Image1(7).Height / 2)
For i = 0 To 7
Image1(i).Visible = True
Next
End Function