BagiAn HidupKu

Selasa, 14 Juni 2011

VB Combine Region




module 1 :

Option Explicit
Public Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Public Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, _
ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Public Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const HTCAPTION = 2
Public Const WM_NCLBUTTONDOWN = &HA1
Public Const WM_SYSCOMMAND = &H112

Public Const RGN_AND = 1 'Creates the intersection of the two combined regions.
Public Const RGN_COPY = 2 'Creates a copy of the region identified by hrgnSrc1.
Public Const RGN_DIFF = 3 'Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
Public Const RGN_OR = 4 'Creates the union of two combined regions.
Public Const RGN_XOR = 5 'Creates the union of two combined regions except for any overlapping areas.


form :
Private Sub Form_Load()
llWidth = Me.Width / Screen.TwipsPerPixelX
llHeight = Me.Height / Screen.TwipsPerPixelY

lRet = CreateRoundRectRgn(0, 0, llWidth, llHeight, 35, 35)
lret2 = CreateRoundRectRgn(0, 0, llWidth, 150, 0, 0)
CombineRgn lret2, lRet, lret2, RGN_COPY
l = SetWindowRgn(Form1.hwnd, lret2, True)
End Sub