Как сделать окно неправильной формы
Arkadiy Olovyannikov:
ИМХО, проще и красивее создавать регионы через
Path. Hу что можно сделать через Create...Region? Эллипс? А
вот как можно использовать Path:
Private Declare Function SelectClipPath Lib "gdi32" _
(ByVal hdc As Long, ByVal iMode As Long) As Long
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc 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 Const RGN_COPY = 5
Private Sub Form_Load()
' Don't forget to set Form.BorderStyle property to None !
Const TXT = " Cool programm" & vbCrLf & " from" & vbCrLf & _
"Cool Company" & vbCrLf & "CopyLeft by Ark"
Dim hRgn As Long
Font.Name = "Times New Roman"
Font.Bold = True
Font.Size = 60
Width = TextWidth(TXT)
Height = TextHeight(TXT)
BeginPath hdc
CurrentX = 0
CurrentY = 0
Print TXT
' Здесь вместо текста можно рисовать фигуры
EndPath hdc
hRgn = PathToRegion(hdc)
SetWindowRgn hWnd, hRgn, False
' Hачинаем фантазировать с формой. Можно так
Picture = LoadPicture("c:\windows\облака.bmp")
' А можно так
' dclr = 256 / (TextHeight(TXT) / 30)
' clr = 0
' For i = 120 To 120 + TextHeight(TXT) Step 30
' Line (0, i)-Step(5000, 0), RGB(0, 0, clr)
' clr = clr + dclr
' Next i
' Можно дать форме градиентную заливку и т.д.
' Двигаем к центру, а можно в таймере крутить
Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
End Sub
|