1,486
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
'************************************************
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = (-16)
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
Font = "黑体"
ForeColor = &HFF&
FontSize = 72
CurrentX = 500
CurrentY = 1000
Me.Print "我爱你,中国!"
Dim rtn As Long
rtn = GetWindowLong(hWnd, GWL_EXSTYLE) '取窗口原先的样式
rtn = rtn Or WS_EX_LAYERED '使窗体添加上新的样式WS_EX_LAYERED
SetWindowLong hWnd, GWL_EXSTYLE, rtn '把新的样式赋给窗体
SetLayeredWindowAttributes hWnd, &HFF0000, 0, &H1
Me.Refresh
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim nRet1, nRet2
nRet1 = ReleaseCapture
nRet2 = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End Sub