CAFE

vb6 api

반투명폼ReleaseDC,GetDC,GetDesktopWindow,BitBlt

작성자올란도|작성시간09.01.29|조회수369 목록 댓글 1

1. 모듈에 다음의 API 및 상수를 선언합니다.

Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function BitBlt Lib "gdi32" _
              (ByVal hDestDC As Long, _
               ByVal X As Long, _
               ByVal Y As Long, _
               ByVal nWidth As Long, _
               ByVal nHeight As Long, _
               ByVal hSrcDC As Long, _
               ByVal xSrc As Long, _
               ByVal ySrc As Long, _
               ByVal dwRop As Long) As Long

Public Const SRCCOPY = &HCC0020

2. 폼에 하나의 버튼을 만들고 다음과 같이 코딩하시기 바랍니다.
   참고 - 폼의 속성중에 BorderStyle 을 0 (없음) 으로 해주시기 바랍니다.

Private Sub MakeTransparent(frmPass As Object, Optional tColor)
    Dim hw As Long, ha As Long
    Dim dx1 As Long, dy1 As Long
    Dim wdth As Long, higt As Long
    Dim s As Long

    If IsMissing(tColor) Then tColor = RGB(120, 255, 255)
   
    frmPass.AutoRedraw = True
    frmPass.Hide
   
    DoEvents
    ' 데스크탑의 윈도우 핸들값을 구한다.
    hw = GetDesktopWindow()
    ' 데스크탑의 윈도우 hDC 를 구한다.
    ha = GetDC(hw)
    dx1 = frmPass.Left / Screen.TwipsPerPixelX
    dy1 = frmPass.Top / Screen.TwipsPerPixelY
    wdth = frmPass.ScaleWidth
    higt = frmPass.ScaleHeight
       
    s = BitBlt(frmPass.hdc, 0, 0, wdth, higt, ha, dx1, dy1, SRCCOPY)
    frmPass.Picture = frmPass.Image
    frmPass.Show
    Call ReleaseDC(hw, ha)
    frmPass.DrawMode = 9
    frmPass.ForeColor = tColor
    frmPass.Line (0, 0)-(wdth, higt), , BF
End Sub

Private Sub Command1_Click()
    MakeTransparent Form1
End Sub

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
  • 작성자꼭미남강유 | 작성시간 09.04.10 종료버튼 하나 추가하는게 조을듯 하구요.. 버튼은 투명해 지지가 않는군요.. 여튼 쓰일데가 있을듯..
댓글 전체보기
맨위로

카페 검색

카페 검색어 입력폼