Страница: 1 |
|
Вопрос: Вопрос о перетаскивании PictureBox
|
Добавлено: 08.12.08 20:49
|
|
Автор вопроса: busha
|
У меня есть PictureBox, я хочу его перетаскивать с места на место, для этого есть Form.DragOver, делаю Picture.DragMode = Automatic, при перетаскивании появляется рамка, а как заменить эту рамку на саму картинку, вернее ее дубликат
Ответить
|
Номер ответа: 9 Автор ответа: Father
Вопросов: 0 Ответов: 159
|
Профиль | | #9
|
Добавлено: 10.12.08 15:19
|
Можно сделать в курсоре его уменьшенную копию
Можно.
-
- Option Explicit
-
- Private Type GUID
- Data1 As Long
- Data2 As Integer
- Data3 As Integer
- Data4(7) As Byte
- data5(16) As Byte
- End Type
-
- Private Type BITMAP
- bmType As Long
- bmWidth As Long
- bmHeight As Long
- bmWidthBytes As Long
- bmPlanes As Integer
- bmBitsPixel As Integer
- bmBits As Long
- End Type
-
- Private Type ICOPICTDESC
- cbSize As Long
- picType As Long
- hicon As Long
- End Type
-
- Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (lpPictDesc As ICOPICTDESC, riid As Any, ByVal fOwn As Long, ipic As IPicture) As Long
- Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, ByVal lpBits As Long) As Long
- Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
- Private Declare Function CreateIcon Lib "user32" (ByVal hInstance As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Byte, ByVal nBitsPixel As Byte, lpANDbits As Byte, lpXORbits As Byte) As Long
-
- Private Const OBJ_BITMAP = 7
-
-
- Private Sub Picture1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
- Dim myBmp As BITMAP
- Dim bmp() As Byte
- Dim guidstr As GUID
- Dim oleico As ICOPICTDESC
- Dim stdpic As StdPicture
- Call GetObject(Picture1.Image.Handle, LenB(myBmp), myBmp)
- ReDim bmp(myBmp.bmHeight * myBmp.bmWidthBytes)
- Call GetBitmapBits(Picture1.Image.Handle, myBmp.bmWidthBytes * myBmp.bmHeight, VarPtr(bmp(0)))
- With oleico
- .cbSize = LenB(oleico)
- .hicon = CreateIcon(App.hInstance, myBmp.bmWidth, myBmp.bmHeight, myBmp.bmPlanes, myBmp.bmBitsPixel, bmp(0), bmp(0))
- .picType = vbPicTypeIcon
- End With
- With guidstr
- .Data1 = &H20400
- .Data4(0) = &HC0
- .Data4(7) = &H46
- End With
- Call OleCreatePictureIndirect(oleico, guidstr, True, stdpic)
- Set Picture1.DragIcon = stdpic
-
- End Sub
Можно и всю картинку таскать, может позже напишу, если нужно.
Ответить
|
Страница: 1 |
Поиск по форуму