Oppure

Loading
30/09/09 8:37
maurizio74
Salve a tutti mi chiedevo se è possibile realizzare un form
con tutti 4 gli angoli arrotondati.... Grazie per le eventuali risposte
aaa
30/09/09 13:49
GrG
non ho capito bene... prova a vedere se shape creator (che è un programma) ti può servire...
aaa
30/09/09 14:04
Louis
Ciao Maurizio,
prova questo codice del Balena:
Option Explicit
' Dal libro di Francesco Balena "I Trucchi di Viasual Basic 6"
Sub SetWindowShape(ByVal hWnd As Long, ByVal Shape As Long)
    Dim lpRect As Rect
    Dim wi As Long, he As Long
    Dim hRgn As Long
    
' Legge le dimensioni della Frm in pixel:
    GetWindowRect hWnd, lpRect
    wi = lpRect.Right - lpRect.Left
    he = lpRect.Bottom - lpRect.Top
' Crea una regione:
    Select Case Shape
        ' Cerchio o ellisse:
        Case 0
            hRgn = CreateEllipticRgn(0, 0, wi, he)
        ' Rettangolo arrotondato:
        Case 1
            hRgn = CreateRoundRectRgn(0, 0, wi, he, 20, 20)
        ' Rombo:
        Case 2
            Dim lpPoints(3) As Pointapi
            lpPoints(0).x = wi \ 2
            lpPoints(0).y = 0
            lpPoints(1).x = 0
            lpPoints(1).y = he \ 2
            lpPoints(2).x = wi \ 2
            lpPoints(2).y = he
            lpPoints(3).x = wi
            lpPoints(3).y = he \ 2
            hRgn = CreatePolygonRgn(lpPoints(0), 4, 1)
        End Select
            
' Applica la regione alle Frms:
    SetWindowRgn hWnd, hRgn, True
    DeleteObject hRgn

End Sub
'------------------------------------------------------
Private Sub Form_Load()
' Mostra la Frm con i bordi arrotondati
' Rettangolo arrotondato:
    SetWindowShape Me.hWnd, 1
End Sub


In Un modulo Bas:

Option Explicit
Type Pointapi
    x As Long
    y As Long
End Type
Type Rect
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
                
Declare Function CreateEllipticRgn Lib "gdi32" (ByVal x1 As Long, _
    ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Pointapi, _
    ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Declare Function CreateRoundRectRgn Lib "gdi32" (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
Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, _
    lpRect As Rect) As Long
Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, _
    ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long


:k:
aaa
01/10/09 16:43
maurizio74
Ciao Louis grazie per la risposta ed anche per la dritta..
tutto sommato potrebbe andarmi anche bene... ho solamente un piccolo problemino
se imposto il form nelle proprietà bordstyle none non riesco a muoverlo mi rimane fisso
lì dove si trova, ma questo vale anche per un form normale... come posso riuscire a solvere questo problema?????? grazie anticipatamente...
aaa
01/10/09 17:18
GrG
prova questo codice:
Const HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1
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 Long) _
        As Long

Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, _
        Y As Single)
    If Button = 1 Then
        Dim RetVal As Long
        X = ReleaseCapture()
        RetVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
    Else
        Unload Me
        ' or what you like better
    End If
End Sub
aaa
01/10/09 17:46
maurizio74
Grazie grg mi 6 stato di aiuto....ultima cosa ma se io volessi spostare il form
tramite un button perche' cosi' non lo fa... devo cambiare qualcosa nel codice????
grazie anticipatamente....
aaa
01/10/09 18:54
GrG
devi inserire il codice semplicemente nella sub mousedown del commandbutton interessato...
aaa
02/10/09 6:33
Louis
Molto interessante il tuo codice GrG, che completa quello postato del Balena, complimenti. :k:
aaa