Пикчербокс нестандартной формы - не работает - VB
Формулировка задачи:
Здравствуйте! С Новым Годом всех!
Скачал пример из сети - PictureBox нестандартной формы. Но не работает. Подскажите, в чём моя ошибка?
SetWindowRgn с CreateEllipticRgn работает нормально, а вот с CreatePolygonRgn - ноль реакции
Решение задачи: «Пикчербокс нестандартной формы - не работает»
textual
Листинг программы
Option Explicit Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode 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 CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Type POINTAPI X As Long Y As Long End Type Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Sub ReleaseCapture Lib "user32" () Dim P(50) As POINTAPI Dim Rgn As Long Private Sub cmdCreatePolygon_Click() P(0).X = 132: P(0).Y = 6 P(1).X = 173: P(1).Y = 64 P(2).X = 303: P(2).Y = 71 P(3).X = 213: P(3).Y = 123 P(4).X = 291: P(4).Y = 241 P(5).X = 157: P(5).Y = 154 P(6).X = 5: P(6).Y = 239 P(7).X = 78: P(7).Y = 103 P(8).X = 10: P(8).Y = 58 P(9).X = 100: P(9).Y = 60 P(10).X = 132: P(10).Y = 6 Dim i As Integer, rNew Rgn = CreatePolygonRgn(P(0), 11, 1) For i = 1 To 10 rNew = CreatePolygonRgn(P(i), 11, 1) CombineRgn Rgn, Rgn, rNew, 2 DeleteObject rNew Next i Call SetWindowRgn(Picture1.hwnd, Rgn, True) End Sub
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д