Creare un Form mediante la Classe Window: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
(Nuova pagina: Poiché l'oggetto ''Form'' appartiene alla categoria dell'oggetto ''Window'', è possibile pertanto creare un ''Form'' autonomo dichiarando ed istanziando un oggetto ''Window'' per mez...) |
Nessun oggetto della modifica |
||
| Riga 1: | Riga 1: | ||
Poiché l'oggetto ''Form'' appartiene alla categoria dell'oggetto ''Window'', è possibile pertanto creare un ''Form'' autonomo dichiarando ed istanziando un oggetto ''Window'' per mezzo di una variabile di tipo ''Window'', con la quale sarà anche gestito. | Poiché l'oggetto ''Form'' appartiene alla categoria dell'oggetto ''Window'', è possibile pertanto creare un ''Form'' autonomo dichiarando ed istanziando un oggetto ''Window'' per mezzo di una variabile di tipo ''Window'', con la quale sarà anche gestito. | ||
Detti ''Form'' creati mediante la Clase ''Window'' potranno contenere regolarmente degli oggetti. | |||
Nel seguente esempio creeremo diversi ''Form'' mediante la Classe ''Window'': | |||
'''Private''' w As Window | '''Private''' w As Window | ||
'''Private''' bt As Button | |||
'''Public''' Sub Button1_Click() | |||
Dim j As Byte | |||
''' | For j = 0 To 4 | ||
With w = New Window As "w" | |||
.W = 300 | |||
.H = 200 | |||
.Caption = "num. " & CStr(j) | |||
.Background = &111111 * (j + 1000) | |||
.Show | |||
End With | |||
<FONT color=#006400>' ''Poniamo su ciascun nuovo "Form" un "Button":''</font> | |||
creaTasto() | |||
With | Next | ||
.X = | |||
.Y = | '''End''' | ||
.W = | |||
.H = | |||
'''Public''' Sub w_Open() | |||
<FONT color=#006400>' ''Per ogni nuovo "From" creato, che si apre,'' | |||
' ''ne vediamo in console il nome:''</font> | |||
Print w.Caption | |||
'''End''' | |||
'''Public''' Sub creaTasto() | |||
With bt = New Button(w) As "bt" | |||
.X = 20 | |||
.Y = 20 | |||
.W = 100 | |||
.H = 40 | |||
.Background = Color.Yellow | .Background = Color.Yellow | ||
. | .Text = "Tasto " & w.Caption | ||
End With | End With | ||
'''End''' | '''End''' | ||
'''Public''' Sub | '''Public''' Sub bt_Click() <FONT color=#006400>' ''I "Button" presenti sui nuovi "Form" sono regolarmente funzionanti''</font> | ||
Print "Premuto " & Last.Text | |||
'''End''' | '''End''' | ||
Versione delle 07:38, 12 feb 2013
Poiché l'oggetto Form appartiene alla categoria dell'oggetto Window, è possibile pertanto creare un Form autonomo dichiarando ed istanziando un oggetto Window per mezzo di una variabile di tipo Window, con la quale sarà anche gestito.
Detti Form creati mediante la Clase Window potranno contenere regolarmente degli oggetti.
Nel seguente esempio creeremo diversi Form mediante la Classe Window:
Private w As Window
Private bt As Button
Public Sub Button1_Click()
Dim j As Byte
For j = 0 To 4
With w = New Window As "w"
.W = 300
.H = 200
.Caption = "num. " & CStr(j)
.Background = &111111 * (j + 1000)
.Show
End With
' Poniamo su ciascun nuovo "Form" un "Button":
creaTasto()
Next
End
Public Sub w_Open()
' Per ogni nuovo "From" creato, che si apre,
' ne vediamo in console il nome:
Print w.Caption
End
Public Sub creaTasto()
With bt = New Button(w) As "bt"
.X = 20
.Y = 20
.W = 100
.H = 40
.Background = Color.Yellow
.Text = "Tasto " & w.Caption
End With
End
Public Sub bt_Click() ' I "Button" presenti sui nuovi "Form" sono regolarmente funzionanti
Print "Premuto " & Last.Text
End