|
|
|
|
|
Dicas
|
|
Visual Basic (Forms/MDI)
|
|
|
Título da Dica: Desenhar um form usando formas complexas (Bomba, avião, relógio...)
|
|
|
|
Postada em 30/10/2003 por PC
'Copie o codigo para um form. Controles só serão visíveis dentro da área de desenho. 'Para descobrir as formas abra o MAPA DE CARACTERES na letra WINDINGS, ou outra q vc ajustar no codigo.
'Declarações Private Type RECT Left As Long Top As Long Right As Long bottom As Long End Type Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount 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 GetRgnBox Lib "gdi32" (ByVal hRgn As Long, lpRect As RECT) As Long Private Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As RECT) 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 Const RGN_AND = 1 Private Const RGN_OR = 2 Private Const RGN_XOR = 3 Private Const RGN_DIFF = 4 Private Const RGN_COPY = 5 Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject 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 ReleaseCapture Lib "user32" () As Long 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 Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2
'Codigo: Private Function GetTextRgn() As Long Dim hRgn1 As Long, hRgn2 As Long Dim rct As RECT BeginPath hdc '************************** 'mude a letra de M para outra ou use chr$(ValorASC) PARA MUDAR A FORMA TextOut hdc, 10, 10, "M", 1 '************************** EndPath hdc hRgn1 = PathToRegion(hdc) GetRgnBox hRgn1, rct hRgn2 = CreateRectRgnIndirect(rct) CombineRgn hRgn2, hRgn2, hRgn1, 1 DeleteObject hRgn1 GetTextRgn = hRgn2 End Function Private Sub Form_DblClick() Unload Me End Sub Private Sub Form_Load() Dim hRgn As Long Me.Font.Name = "Wingdings" Me.Font.Size = 300 hRgn = GetTextRgn() SetWindowRgn hwnd, hRgn, 1 End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) ReleaseCapture SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0& End Sub
|
|
|
|
|