un saluto a tutti quanti
sto cercando di convertire una mia applicazione da vb6 a vbnet
e mi trovo davanti ad un problema del quale non riesco a trovare
la soluzione; ho una maschera che, sfruttando le api di cui al titolo,
si apre dal centro e si allarga man mano; come e' possibile fare la
stessa cosa in vbnet?
allego il codice
creare Form1 che non contiene nessun campo e di dimensioni qualsiasi
come codice copiare il seguente
Option Explicit
Private Sub RitagliaForm(ByVal Incremento As Single)
Dim pts(1 To 57) As PosizioneCursore
Dim rgn As Long
Dim OldRgn As Long
Dim str As String
Dim str2 As String
Dim k As Integer
Dim J As Integer
Dim Sch As Variant
Dim Sch2 As Variant
str = "*327*296*254*237*185*182*123*134*71*96*32*70*8*56 *0*56*" & _
"8*70*32*96*71*134*123*182*185*237*254*296*327*358 *400*" & _
"417*469*472*531*520*583*558*622*584*646*598*654*5 98*646*" & _
"584*622*558*583*520*531*472*469*417*400*358*3 27*"
str2 = "*0*29*5*35*17*49*36*68*62*92*93*119*128*149*164*1 79*200*" & _
"209*235*236*266*260*292*279*311*293*323*299*328*2 99*323*" & _
"293*311*279*292*260*266*236*235*209*200*179*164*1 49*128*" & _
"119*93*92*62*68*36*49*17*35*5*29*0*"
Sch = Split(str, "*")
Sch2 = Split(str2, "*")
For k = 1 To 57
pts(k).Ascissa = CLng(Sch(k))
pts(k).Ordinata = CLng(Sch2(k))
Next k
Me.Cls
If Incremento > 1 Then Incremento = 1
For J = 1 To 57
pts(J).Ascissa = pts(J).Ascissa * Incremento + _
(Me.Width / 2 / Screen.TwipsPerPixelX) - _
(Me.Width / 2 / Screen.TwipsPerPixelX * Incremento)
pts(J).Ordinata = pts(J).Ordinata * Incremento + _
(Me.Height / 2 / Screen.TwipsPerPixelY) - _
(Me.Height / 2 / Screen.TwipsPerPixelY * Incremento)
Next J
rgn = CreatePolygonRgn(pts(1), 57, 2)
OldRgn = SetWindowRgn(hwnd, rgn, True)
Me.Refresh
End Sub
Private Sub Form_Resize()
Dim Start As Double
Dim Temp As Single
Dim Delay As Single
Me.Left = Screen.Width * (100 - 98) / 200
Me.Top = Screen.Height * (100 - 98) / 200
Me.Width = Screen.Width * 98 / 100
Me.Height = Screen.Height * 98 / 100 - 500
Me.BackColor = 255
Delay = 0.01
For Temp = 0.1 To 1.1 Step 0.01
Call RitagliaForm(Temp)
Start = Timer
Do While Timer < Start + 0.01
DoEvents
Loop
Next Temp
End Sub
in un modulo inserire poi il seguente codice
Public Type PosizioneCursore
Ascissa As Long
Ordinata As Long
End Type
Declare Function CreatePolygonRgn _
Lib "GDI32" ( _
lpPoint As PosizioneCursore, _
ByVal nCount As Long, _
ByVal nPolyFillMode As Long) _
As Long
Declare Function SetWindowRgn _
Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hRgn As Long, _
ByVal bRedraw As Boolean) _
As Long
scusate se non riesco a formattare il codice; non so come si fa