aker13
|
опубликован 12-10-2001 13:23 MSK
Private Sub Form_Load() Me.ScaleMode = vbPixels withFrameFlag = True toggleFrame withFrameFlag End Sub Private Sub toggleFrame(inFlag As Boolean) Dim w As Single, h As Single Dim edge As Single, topEdge As Single Dim mLeft, mTop Dim i As Integer Dim r As Long Dim outer As Long, inner As Long mFormRegion = CreateRectRgn(0, 0, 0, 0) w = ScaleX(Width, vbTwips, vbPixels) h = ScaleY(Height, vbTwips, vbPixels) edge = (w - ScaleWidth) / 2 topEdge = h - edge - ScaleHeight If inFlag Then outer = CreateRectRgn(0, 0, w, h) inner = CreateRectRgn(edge, topEdge, w - edge, h - edge) CombineRgn mFormRegion, outer, inner, RGN_DIFF End If For i = 0 To Me.Controls.Count - 1 mLeft = ScaleX(Me.Controls(i).Left, Me.ScaleMode, vbPixels) + edge mTop = ScaleX(Me.Controls(i).Top, Me.ScaleMode, vbPixels) + topEdge r = CreateRectRgn(mLeft, mTop, _ ScaleX((Me.Controls(i).Width), Me.ScaleMode, vbPixels) + mLeft, _ ScaleY((Me.Controls(i).Height), Me.ScaleMode, vbPixels) + mTop) CombineRgn mFormRegion, r, mFormRegion, RGN_OR Next SetWindowRgn hwnd, mFormRegion, True End Sub и модуль
Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 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 Const RGN_OR = 2 Public Const RGN_DIFF = 4 |