下午做了一个窗体,传上来 望大家多多指点(注:在Win98不能实现)
(第一次做特意做窗体,老鸟勿笑)
另外 还有一个问题没有解决
就是当按下"最小化"按钮后 程序并没有出现在任务栏 而是出现在开始菜单的上面 这可能是由于我修改了窗体的窗口扩展风格造成的 希望高手指点 我希望它出现在任务栏中
[此贴子已经被作者于2007-4-24 17:12:15编辑过]
下午做了一个窗体,传上来 望大家多多指点(注:在Win98不能实现)
(第一次做特意做窗体,老鸟勿笑)
[此贴子已经被作者于2007-4-24 17:12:15编辑过]
谢谢
为了实现这个窗体我可费了不少力 在.NET中有一个属性,经过设置可以使背景中的某种颜色变成透明的 但在6.0中 没有我查了资料 最后终于找到了一个函数 SetLayeredWindowAttributes 通过它也可以使背景的某种颜色透明
谢谢了
下面是我实现这个窗体所写的代码:
Option Explicit
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 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 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
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_COLORKEY = &H1
Private Sub Form_Load()
Dim sty As Long
sty = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
sty = sty Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, sty '修改窗体的扩展样式为层式结构
SetLayeredWindowAttributes Me.hwnd, &HFFFFFF, 0, LWA_COLORKEY '将窗体背景图片上的白色部分设置为透明(这是主要的 )
End Sub
'下面实现窗体的拖动(因为没有标题栏)
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, &HA1, 2, 0
End If
End Sub
Private Sub Image1_Click()'最小化按钮
Me.WindowState = 1
End Sub
Private Sub Image2_Click()'关闭按钮
Unload Me
End Sub
[此贴子已经被作者于2007-4-25 13:17:07编辑过]