| 日時: 2011/04/05 13:20名前: 花ちゃん
 
************************************************************************************ カテゴリー:[描画・画像][フォーム][]                                        *
 * キーワード:透過処理,透明,半透明,グラフィック,ウィンドウ,                       *
 ***********************************************************************************
 
 ---------------------------------------------------------------------
 Layered Window その2 - 魔界の仮面弁士  2003/12/25-18:23 No.7335
 ---------------------------------------------------------------------
 
 今度は、完全に切り抜くのではなく、半透明にするサンプルです。
 
 フォームに、水平スクロールバーコントロールを貼っておいてください。
 
 '====================
 Option Explicit
 
 Private Declare Function SetWindowLongW Lib "user32" _
 (ByVal hWnd As Long, _
 ByVal Index As Long, _
 ByVal NewLong As Long) As Long
 Private Declare Function SetLayeredWindowAttributes Lib "user32" _
 (ByVal hWnd As Long, _
 ByVal Key As Long, _
 ByVal Alpha As Byte, _
 ByVal Flag As Long) As Long
 
 Private Sub Form_Load()
 HScroll1.Min = 0
 HScroll1.Max = 255
 HScroll1.Value = 180
 Caption = "スクロールバーを左端まで移動させると、えらいことになります(泣)"
 End Sub
 
 Private Sub Form_Paint()
 Const GWL_EXSTYLE As Long = -20&
 Const WS_EX_LAYERED As Long = &H80000
 Const LWA_ALPHA As Long = 2&
 
 SetWindowLongW hWnd, GWL_EXSTYLE, WS_EX_LAYERED
 SetLayeredWindowAttributes hWnd, 0&, CLng(HScroll1.Value), LWA_ALPHA
 End Sub
 
 Private Sub HScroll1_Change()
 Refresh
 End Sub
 
 
 -----------------------------------------------------
 上記の実行結果は、先頭の記事の右側の図になります。
 by 花ちゃん
 -----------------------------------------------------
 
 
 |