CAFE

vb6 api

GetClipBox

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

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" _
        (ByVal nIndex As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
        (ByVal hObject As Long) As Long
Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
Private Declare Function FrameRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, _
        ByVal hBrush As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" _
        (ByVal X1 As Long, ByVal Y1 As Long, _
         ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function GetClipBox Lib "gdi32" (ByVal hdc As Long, _
        lpRect As RECT) As Long
Private Declare Function SelectClipRgn Lib "gdi32" _
        (ByVal hdc As Long, ByVal hRgn As Long) As Long

 

Private Sub cmdGetClipBox_Click()
    Dim nRgn As Long
    Dim nhDC As Long
    Dim nRect As RECT
   
    Const BLACK_BRUSH = 4
    Const RGN_COPY = 5
   
    Picture1.Cls
    '/ DC 생성
    nhDC = GetDC(Picture1.hwnd)
    nRgn = CreateRectRgn(10, 10, 100, 100)
    '/주어진 영역을 클리핑영역으로 선택한다.
    SelectClipRgn nhDC, nRgn
    '/클리핑박스를 구하고 테두리를 그린다.
    GetClipBox nhDC, nRect
    '/사각형의 테두리를 그린다.
    FrameRect nhDC, nRect, GetStockObject(BLACK_BRUSH)
    '/생성된 영역을 삭제한다.
    DeleteObject nRgn
    '/ DC 해제
    ReleaseDC Picture1.hwnd, nhDC

End Sub

Private Sub Form_Load()
    Me.Left = (Screen.Width - Me.Width) / 2
    Me.Top = (Screen.Height - Me.Height) / 2
End Sub

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

댓글

댓글 리스트
맨위로

카페 검색

카페 검색어 입력폼