VB6 半透明: 将如下代码放置一个模块中 在你的form中调用 Transparence Form1.hwnd 至于编辑功能就更简单啦,不需要我啰嗦吧Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Public Const HWND_TOPMOST = -1 Public Const SWP_NOSIZE = &H1 Public Const SWP_NOMOVE = &H2 Declare Function GetWindowRect Lib "user32" _ (ByVal hwnd As Long, lpRect As RECT) As Long Public Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long Public Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Public Declare Function ReleaseCapture Lib "user32" () As Long Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Const WM_CLOSE = &H10Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Public Const WS_EX_LAYERED = &H80000 Public Const GWL_EXSTYLE = (-20) Public Const LWA_ALPHA = &H2 Public Const LWA_COLORKEY = &H1 Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Function Transparence(hwnd As Long) 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, 0, 192, LWA_ALPHA
工程中添加两个窗体,form1和form2, 下例是在form1中的代码,
Option Explicit
Dim frm As Form2
Private Sub Command1_Click()
Set frm = New Form2
frm.Show
End Sub
Private Sub Command2_Click()
Unload frm
Set frm = Nothing
End Sub
需要显示的数据实时从数据库中获取~~这个很简单吧?
循环数据库动态添加Label控件,将需要显示的数据显示在Label控件上~~
其实并不难~
半透明: 将如下代码放置一个模块中
在你的form中调用 Transparence Form1.hwnd
至于编辑功能就更简单啦,不需要我啰嗦吧Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const HWND_TOPMOST = -1
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long
Public Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Const WM_CLOSE = &H10Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Const WS_EX_LAYERED = &H80000
Public Const GWL_EXSTYLE = (-20)
Public Const LWA_ALPHA = &H2
Public Const LWA_COLORKEY = &H1
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Function Transparence(hwnd As Long)
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, 0, 192, LWA_ALPHA
'注释: 把窗体设置成半透明样式 , 第二个参数表示透明程度
'注释: 取值范围0 --255, 为0时就是一个全透明的窗体了
' 第二种使用方法 ' SetLayeredWindowAttributes hwnd, &H0, 0, LWA_COLORKEY
'注释: 表明不显示窗体中的透明色
'注释: 而第二个参数表示透明色为黑色 , 并且你可以用RGB函数来指定颜色值进入讨论组讨论?
End Function