久久―日本道色综合久久,亚洲欧美精品在线,狼狼色丁香久久婷婷综合五月,香蕉人人超,日本网站黄,国产在线观看不卡免费高清,无遮挡的毛片免费

2023信創(chuàng)獨(dú)角獸企業(yè)100強(qiáng)
全世界各行各業(yè)聯(lián)合起來(lái),internet一定要實(shí)現(xiàn)!

VB中制作半透明窗體

2004-02-20 eNet&Ciweek

  AnimateWindow是一個(gè)窗口打開和關(guān)閉時(shí)產(chǎn)生動(dòng)畫效果的新函數(shù),因?yàn)槭且粋€(gè)新的函數(shù), 所以在 API Viewer中是找不到的,必需自己定義:

   Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

  注釋:具體可以使用的常量及其用法

  Const LWA_ALPHA=&H2 注釋:表示把窗體設(shè)置成半透明樣式
  Const LWA_COLORKEY=&H1 注釋:表示不顯示窗體中的透明色


  具體例子

  程序代碼

  Module1

Public 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


  Form1

Private Sub Form_Load()
Dim rtn As Long

  rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE) 注釋:取的窗口原先的樣式
rtn = rtn Or WS_EX_LAYERED 注釋:使窗體添加上新的樣式WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, rtn 注釋:把新的樣式賦給窗體

  SetLayeredWindowAttributes me.hwnd, 0, 192, LWA_ALPHA

    注釋:把窗體設(shè)置成半透明樣式,第二個(gè)參數(shù)表示透明程度
    注釋:取值范圍0--255,為0時(shí)就是一個(gè)全透明的窗體了

  End Sub


  第二種使用方法

  SetLayeredWindowAttributes Me.hWnd, &H0, 0, LWA_COLORKEY
  注釋:表明不顯示窗體中的透明色
  注釋:而第二個(gè)參數(shù)表示透明色為黑色,并且你可以用RGB函數(shù)來(lái)指定顏色值

相關(guān)頻道: eNews

您對(duì)本文或本站有任何意見,請(qǐng)?jiān)谙路教峤?,謝謝!

投稿信箱:tougao@enet16.com