Deklaration: Declare Function SetWindowRgn Lib "user32.dll" ( _ ByVal hWnd As Long, _ ByVal hRgn As Long, _ ByVal bRedraw As Boolean) As Long Beschreibung: Parameter:
Rückgabewert: Beispiel: Private Declare Function CreateRoundRectRgn Lib "gdi32.dll" ( _ 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 Private Declare Function CreateEllipticRgnIndirect Lib "gdi32.dll" ( _ lpRect As RECT) As Long Private Declare Function GetWindowRgn Lib "user32.dll" ( _ ByVal hwnd As Long, _ ByVal hRgn As Long) As Long Private Declare Function SetWindowRgn Lib "user32.dll" ( _ ByVal hwnd As Long, _ ByVal hRgn As Long, _ ByVal bRedraw As Boolean) As Long Private Declare Function DeleteObject Lib "gdi32" ( _ ByVal hObject As Long) As Long Private Declare Function CreatePolygonRgn Lib "gdi32.dll" ( _ lpPoint As POINTAPI, _ ByVal nCount As Long, _ ByVal nPolyFillMode As Long) As Long Private Declare Function GetWindowRect Lib "user32" ( _ ByVal hwnd As Long, _ lpRect As RECT) As Long Private Declare Function CreateRectRgnIndirect Lib "gdi32.dll" ( _ lpRect As RECT) As Long Private Declare Function InflateRect Lib "user32.dll" ( _ lpRect As RECT, _ ByVal x As Long, _ ByVal y As Long) As Long Private Declare Function CopyRect Lib "user32.dll" ( _ lpDestRect As RECT, _ lpSourceRect As RECT) As Long Private Declare Function EqualRgn Lib "gdi32.dll" ( _ ByVal hSrcRgn1 As Long, _ ByVal hSrcRgn2 As Long) As Long Private Declare Function SetRect Lib "user32.dll" ( _ lpRect As RECT, _ ByVal X1 As Long, _ ByVal Y1 As Long, _ ByVal X2 As Long, _ ByVal Y2 As Long) As Long Private Type POINTAPI x As Long y As Long End Type Private Type RECT left As Long top As Long right As Long bottom As Long End Type ' CreatePolygonRgn nPolyFillMode-Konstanten Private Const ALTERNATE = 1 ' Alternative zwischen gefüllt und ungefüllt Private Const WINDING = 2 ' Das Dreieck normal gefüllt ' GetWindowRgn Rückgabe-Konstanten Private Const ERROR = 0 ' Die Funktion konnte nicht ausgeführt werden Private Const NULLREGION = 1 ' Es ist keine Region zugewiesen Private Const SIMPLEREGION = 2 ' Die Region ist eine Simple Region (RECT) Private Const COMPLEXREGION = 3 ' Die Region ist eine komplexe Region Dim RectRgn As Long, EllipticRgn As Long Dim PolygonRgn As Long, RoundRectRgn As Long Dim BufferRgn As Long ' Erstellt vier Regionen Private Function CreateRgns() Dim Retval As Long, WndRect As RECT Dim Polygon(2) As POINTAPI, TmpRect As RECT ' Fensterkoordinaten ermitteln und Breite und Höhe ausrechnen Retval = GetWindowRect(Me.hwnd, WndRect) Retval = SetRect(WndRect, 0, 0, WndRect.right - WndRect.left, _ WndRect.bottom - WndRect.top) ' Eine Region zum Empfangen von Regiondaten erstellen BufferRgn = CreateRectRgnIndirect(TmpRect) ' Kopie der Fensterkoordinaten anlegen und verkleinern Retval = CopyRect(TmpRect, WndRect) Retval = InflateRect(TmpRect, -50, -50) ' Rechteckige Region erstellen RectRgn = CreateRectRgnIndirect(TmpRect) ' Elliptische Region erstellen EllipticRgn = CreateEllipticRgnIndirect(WndRect) ' Region mit abgerundeten Ecken erstellen With WndRect RoundRectRgn = CreateRoundRectRgn(.left, .top, .right, .bottom, _ 50, 50) End With ' Dreieckige Region erstellen With Polygon(0) .x = 0 .y = 0 End With With Polygon(1) .x = WndRect.right .y = 0 End With With Polygon(2) .x = WndRect.right / 2 .y = WndRect.bottom End With PolygonRgn = CreatePolygonRgn(Polygon(0), 3, WINDING) End Function ' Regionen erstellen und Info ausgeben Private Sub Form_Load() ' Regionen erstellen Call CreateRgns ' Text auf die Form zeichnen für die Anweisungen Me.AutoRedraw = True Me.Print "Klicken sie mehrmals auf die Form" End Sub Private Sub Form_Click() Static NextOp As Long Dim Retval As Long ' Aktuell gesetzte Region ermitteln und alte entfernen Retval = GetWindowRgn(Me.hwnd, BufferRgn) NextOp = NextOp + 1 If NextOp < 5 Then NextOp = 1 ' neue Region setzen Select Case NextOp Case 1 Retval = SetWindowRgn(Me.hwnd, EllipticRgn, True) Case 2 Retval = SetWindowRgn(Me.hwnd, PolygonRgn, True) Case 3 Retval = SetWindowRgn(Me.hwnd, RoundRectRgn, True) Case 4 Retval = SetWindowRgn(Me.hwnd, RectRgn, True) Case 5 Retval = SetWindowRgn(Me.hwnd, 0&, True) ' Der Form keine Region 'zuweisen Call CreateRgns ' Regionen erneut erstellen End Select End Sub ' Erstellte Regionen wieder entfernen Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) DeleteObject EllipticRgn DeleteObject PolygonRgn DeleteObject RoundRectRgn DeleteObject StdRgn DeleteObject BufferRgn End Sub Diese Seite wurde bereits 11.024 mal aufgerufen. |
sevWizard für VB5/6 ![]() Professionelle Assistenten im Handumdrehen Erstellen Sie eigene Assistenten (Wizards) im Look & Feel von Windows 2000/XP - mit allem Komfort und zwar in Windeseile :-) Buchempfehlung Tipp des Monats ![]() Dieter Otter Zentrale Fehlerbehandlung (VB.NET) Dieser Tipp zeigt, wie man eine zentrale Fehlerbehandlungsroutine erstellt, um unerwartete Anwendungsfehler abzufangen und auszuwerten TOP Entwickler-Paket ![]() TOP-Preis!! Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1605.50 EUR... |
||||||||||||||||
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein. |