在屏幕中,我在一个按钮上按下MOUSE,再移动,屏幕上要出现这个按钮的半透明图像,MOUSE移动时,这个半透明图像也跟着移动.
半透明图像要求它的样子和被拖动的控件图像要一样,例如:如果按钮上有"Command1"的标题,这个半透明图像也要有这个标题.如何实现这种特殊效果呢?请各位大虾位旨教...谢谢..
半透明图像要求它的样子和被拖动的控件图像要一样,例如:如果按钮上有"Command1"的标题,这个半透明图像也要有这个标题.如何实现这种特殊效果呢?请各位大虾位旨教...谢谢..
解决方案 »
- VB6 窗体模式问题
- [求助]如何批量删除FTP服务器里面多个文件?
- 请教一下这个SQL语句该怎么写?
- 菜的不能再菜的问题:怎么调用API????
- 请问一下,下面的话中用户指什么?是指不同的客户机还是指数据库中不同的用户。???
- MSFlexGrid/MSHFlexGrid控件进行数据显示滚动条到处乱跑
- 谁有在VB上编DLL的经验? 帮帮我!
- 这是用什么控件的?
- 请问如何读写USB设备?
- 寻找了多日没有遂心!(大家也可以分享的问题!)
- DTPicker控件在KeyPress事件中,日期格式为 2004-08-14,回车后,焦点自动移到2004上,再回车,焦焦点移到08,在回车转移到14
- Q:MSFlexgrid能动态绑定字段吗?
与上次你问的画线问题一样,需要窗体的ClipControls = False
Me.ScaleMode = 3 在窗体上放个命令按钮,你会很容易地将其改为一个过程,为过程传递控件的hwnd即可。Option ExplicitPrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End TypePrivate Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As LongPrivate Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongDim ox As Long, oy As Long
Dim hdcControl As Long
Dim recControl As RECT
Dim hdcForm As LongPrivate Sub CreateHdc(hwnd As Long)
Dim mbitmap As Long
hdcControl = CreateCompatibleDC(Me.hdc)
GetClientRect hwnd, recControl
mbitmap = CreateCompatibleBitmap(Me.hdc, recControl.Right - recControl.Left, recControl.Bottom - recControl.Top)
SelectObject hdcControl, mbitmap
BitBlt hdcControl, 0, 0, recControl.Right - recControl.Left, recControl.Bottom - recControl.Top, GetDC(hwnd), 0, 0, vbSrcCopy
DeleteObject mbitmap
hdcForm = CreateCompatibleDC(Me.hdc)
mbitmap = CreateCompatibleBitmap(Me.hdc, Me.ScaleWidth, Me.ScaleHeight)
SelectObject hdcForm, mbitmap
BitBlt hdcForm, 0, 0, Me.ScaleWidth, Me.ScaleHeight, Me.hdc, 0, 0, vbSrcCopy
DeleteObject mbitmap
End SubPrivate Sub Command1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
CreateHdc Command1.hwnd
End SubPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim p As POINTAPI
If Button = vbLeftButton Then
BitBlt Me.hdc, ox, oy, recControl.Right - recControl.Left, recControl.Bottom - recControl.Top, hdcForm, ox, oy, vbSrcCopy
GetCursorPos p
ScreenToClient Me.hwnd, p AlphaBlend Me.hdc, p.x, p.y, recControl.Right - recControl.Left, recControl.Bottom - recControl.Top, hdcControl, 0, 0, recControl.Right - recControl.Left, recControl.Bottom - recControl.Top, CLng(Val("&h" & Hex(75) & "00" & "00")) ox = p.x: oy = p.y
End If
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
BitBlt Me.hdc, ox, oy, recControl.Right - recControl.Left, recControl.Bottom - recControl.Top, hdcForm, ox, oy, vbSrcCopy
End SubPrivate Sub Form_Unload(Cancel As Integer)
DeleteDC hdcForm
DeleteDC hdcControl
End Sub
但是这个使用什么函数呢?
如果你想使label这些轻量控件也达到此效果的话也可以,但需要变通一下,方法是先获得窗口的句柄,这在我写的过程中已经有了。然后求出label控件在窗口中的位置,这可以通过label的left、top、width和height属性计算出来,这样用bitblt从窗口句柄中绘制相应位置的图像就可以了。