Differenze tra le versioni di "Simulare il posizionamento di alcuni ToolButton sulla barra del titolo della finestra"

Da Gambas-it.org - Wikipedia.
(Creata pagina con " Private x As Short Private y As Short Private wn As Window Private w As Watcher Private tb As ToolButton Private ta As TextArea Public Sub _n...")
 
 
(Una versione intermedia di uno stesso utente non è mostrata)
Riga 1: Riga 1:
    Private x As Short
+
Mostriamo un possibile codice, per simulare il posizionamento di alcuni ''ToolButton'' (o di altri Controlli grafici) sulla barra del titolo di un ''Form'':
    Private y As Short
+
Private x As Short
    Private wn As Window
+
Private y As Short
    Private w As Watcher
+
Private wn As Window
    Private tb As ToolButton
+
Private w As Watcher
    Private ta As TextArea
+
Private tb As ToolButton
 +
Private ta As TextArea
 +
 
      
 
      
    Public Sub _new()
+
Public Sub _new()
     
+
      With wn = New Window As "Wndw"
+
  With wn = New Window As "Wndw"
        .W = Me.W
+
    .W = Me.W
        .H = 40
+
    .H = 40
        .X = (Screen.AvailableWidth / 2) - (.W / 2)
+
    .X = (Screen.AvailableWidth / 2) - (.W / 2)
        .Y = (Screen.AvailableHeight / 4) - (.H / 2)
+
    .Y = (Screen.AvailableHeight / 4) - (.H / 2)
        .Border = Border.None
+
    .Border = Border.None
        .Background = &D9D9D9
+
    .Background = &D9D9D9
        .Show
+
    .Show
      End With
+
  End With
      With Me
+
  With Me
        .X = wn.X
+
    .X = wn.X
        .Y = wn.Y + wn.H
+
    .Y = wn.Y + wn.H
        .Border = Border.None
+
    .Border = Border.None
        .Margin = True
+
    .Margin = True
        .Padding = 5
+
    .Padding = 5
        .Arrangement = Arrange.Fill
+
    .Arrangement = Arrange.Fill
      End With
+
  End With
     
+
      For b As Byte = 1 To 4
+
  For b As Byte = 1 To 4
        With tb = New ToolButton(wn) As "Toolb"
+
    With tb = New ToolButton(wn) As "Toolb"
          .W = wn.W * 0.1
+
      .W = wn.W * 0.1
          .X = .W + (b * 60)
+
      .X = .W + (b * 60)
          .Y = wn.H * 0.15
+
      .Y = wn.H * 0.15
          .H = wn.H * 0.8
+
      .H = wn.H * 0.8
          .Border = Border.Plain
+
      .Border = Border.Plain
          .Background = Color.Yellow
+
      .Background = Color.Yellow
          .Text = CStr(b)
+
      .Text = CStr(b)
        End With
+
    End With
      Next
+
  Next
   
+
    End
+
End
   
+
    Public Sub Form_Open()
+
   
+
Public Sub Form_Open()
      ta = New TextArea(Me) As "TextA"
+
      w = New Watcher(wn) As "Osserva"
+
  ta = New TextArea(Me) As "TextA"
     
+
  w = New Watcher(wn) As "Osserva"
    End
+
   
+
End
    Public Sub Toolb_Click()
+
     
+
      ta.Text &= Last.Text
+
Public Sub Toolb_Click()
   
+
    End
+
  ta.Text &= Last.Text
   
+
    Public Sub Wndw_MouseDown()
+
End
   
+
    x = Mouse.X  
+
    y = Mouse.Y  
+
Public Sub Wndw_MouseDown()
   
+
    End
+
  x = Mouse.X  
   
+
  y = Mouse.Y  
    Public Sub Wndw_MouseMove()
+
   
+
End
      wn.Move(Mouse.ScreenX - x, Mouse.ScreenY - y)
+
   
+
    End
+
Public Sub Wndw_MouseMove()
   
+
    Public Sub Osserva_Move()  ' Cuando se mueve el objeto gráfico "Window" con el ratón...
+
  wn.Move(Mouse.ScreenX - x, Mouse.ScreenY - y)
   
+
    ' ...también se mueve el Form:
+
End
      Me.Move(wn.X, wn.Y + wn.H)
+
     
+
    End
+
Public Sub Osserva_Move()  <FONT Color=gray>' ''Quando viene spostato il Controllo "Window" con il mouse...''</font>
 +
 +
<FONT Color=gray>' ''...si sposta anche il "Form:"''</font>
 +
  Me.Move(wn.X, wn.Y + wn.H)
 +
 +
End

Versione attuale delle 05:41, 17 lug 2024

Mostriamo un possibile codice, per simulare il posizionamento di alcuni ToolButton (o di altri Controlli grafici) sulla barra del titolo di un Form:

Private x As Short
Private y As Short
Private wn As Window
Private w As Watcher
Private tb As ToolButton
Private ta As TextArea

    
Public Sub _new()

 With wn = New Window As "Wndw"
   .W = Me.W
   .H = 40
   .X = (Screen.AvailableWidth / 2) - (.W / 2)
   .Y = (Screen.AvailableHeight / 4) - (.H / 2)
   .Border = Border.None
   .Background = &D9D9D9
   .Show
 End With
 With Me
   .X = wn.X
   .Y = wn.Y + wn.H
   .Border = Border.None
   .Margin = True
   .Padding = 5
   .Arrangement = Arrange.Fill
 End With

 For b As Byte = 1 To 4
   With tb = New ToolButton(wn) As "Toolb"
     .W = wn.W * 0.1
     .X = .W + (b * 60)
     .Y = wn.H * 0.15
     .H = wn.H * 0.8
     .Border = Border.Plain
     .Background = Color.Yellow
     .Text = CStr(b)
   End With
 Next

End


Public Sub Form_Open()

 ta = New TextArea(Me) As "TextA"
 w = New Watcher(wn) As "Osserva"

End


Public Sub Toolb_Click()

 ta.Text &= Last.Text

End


Public Sub Wndw_MouseDown()

 x = Mouse.X 
 y = Mouse.Y 

End


Public Sub Wndw_MouseMove()

 wn.Move(Mouse.ScreenX - x, Mouse.ScreenY - y)

End


Public Sub Osserva_Move()  ' Quando viene spostato il Controllo "Window" con il mouse...

' ...si sposta anche il "Form:"
 Me.Move(wn.X, wn.Y + wn.H)

End