Exemplum simplex (teneis que poner sobre el Forum dos Button):
Private id As Long
Private pr As Process
Library "libX11:6.3.0"
' Display *XOpenDisplay(char *display_name)
' Opens a connection to the X server that controls a display.
Private Extern XOpenDisplay(display_name As String) As Pointer
' int XReparentWindow(Display *display, Window w, Window parent, int x, int y)
' Removes a window from its current position in the hierarchy, and inserts it as the child of the specified parent.
Private Extern XReparentWindow(display As Pointer, w As Long, parent As Long, x As Integer, y As Integer) As Integer
' int XMoveWindow(Display *display, Window w, int x, int y)
' Moves the specified window to the specified x and y coordinates.
Private Extern XMoveWindow(display As Pointer, w As Long, x As Integer, y As Integer) As Integer
' int XCloseDisplay(Display *display)
' Closes the connection to the X server for the display specified in the Display structure and destroys all windows.
Private Extern XCloseDisplay(display As Pointer) As Integer
Public Sub Form_Open()
With Me
.Border = False
.Show
.Y = 100
End With
With Button1
.W = 60
.H = 20
.Text = "Movet !"
End With
With Button2
.W = 60
.H = 20
.Text = "Cessat !"
End With
' Carga dinamicamente el Componente "gb.desktop":
Component.Load("gb.desktop")
' Abre el programa "gedit":
pr = Shell "gedit"
' Ejecuta el bucle, hasta que no se abre la ventana de "gedit":
Do
Wait 0.01
Loop Until Desktop.FindWindow(Null, "*gedit*", Null).Count > 0
' Hace falta conocer el numero identificativo de la ventana de "gedit":
id = Desktop.FindWindow(Null, "*gedit*", Null)[0]
' Cambia el color del Formulario del programa Gambas:
Me.Background = Color.Red
X11(True)
End
Public Sub Button1_Click() ' Para desplazar el Form
X11(False)
End
Public Sub Button2_Click() ' Para cerrar el programa gambas y "gedit"
' Mata el proceso:
pr.Kill
Me.Close
End
Private Procedure X11(veritas As Boolean)
Dim disp As Pointer
' Conexión a el server X con configuración por defecto:
disp = XOpenDisplay(Null)
If veritas Then
' Engloba el Formulario del programa gambas en la ventana de "gedit":
XReparentWindow(disp, Me.Id, id, 10, Me.Y)
Else
' Desplaza el Formulario por la ventana de "gedit":
XMoveWindow(disp, Me.id, 10, Me.Y + 10)
Endif
' Cerra la libreria:
XCloseDisplay(disp)
End
Private pr As Process
Library "libX11:6.3.0"
' Display *XOpenDisplay(char *display_name)
' Opens a connection to the X server that controls a display.
Private Extern XOpenDisplay(display_name As String) As Pointer
' int XReparentWindow(Display *display, Window w, Window parent, int x, int y)
' Removes a window from its current position in the hierarchy, and inserts it as the child of the specified parent.
Private Extern XReparentWindow(display As Pointer, w As Long, parent As Long, x As Integer, y As Integer) As Integer
' int XMoveWindow(Display *display, Window w, int x, int y)
' Moves the specified window to the specified x and y coordinates.
Private Extern XMoveWindow(display As Pointer, w As Long, x As Integer, y As Integer) As Integer
' int XCloseDisplay(Display *display)
' Closes the connection to the X server for the display specified in the Display structure and destroys all windows.
Private Extern XCloseDisplay(display As Pointer) As Integer
Public Sub Form_Open()
With Me
.Border = False
.Show
.Y = 100
End With
With Button1
.W = 60
.H = 20
.Text = "Movet !"
End With
With Button2
.W = 60
.H = 20
.Text = "Cessat !"
End With
' Carga dinamicamente el Componente "gb.desktop":
Component.Load("gb.desktop")
' Abre el programa "gedit":
pr = Shell "gedit"
' Ejecuta el bucle, hasta que no se abre la ventana de "gedit":
Do
Wait 0.01
Loop Until Desktop.FindWindow(Null, "*gedit*", Null).Count > 0
' Hace falta conocer el numero identificativo de la ventana de "gedit":
id = Desktop.FindWindow(Null, "*gedit*", Null)[0]
' Cambia el color del Formulario del programa Gambas:
Me.Background = Color.Red
X11(True)
End
Public Sub Button1_Click() ' Para desplazar el Form
X11(False)
End
Public Sub Button2_Click() ' Para cerrar el programa gambas y "gedit"
' Mata el proceso:
pr.Kill
Me.Close
End
Private Procedure X11(veritas As Boolean)
Dim disp As Pointer
' Conexión a el server X con configuración por defecto:
disp = XOpenDisplay(Null)
If veritas Then
' Engloba el Formulario del programa gambas en la ventana de "gedit":
XReparentWindow(disp, Me.Id, id, 10, Me.Y)
Else
' Desplaza el Formulario por la ventana de "gedit":
XMoveWindow(disp, Me.id, 10, Me.Y + 10)
Endif
' Cerra la libreria:
XCloseDisplay(disp)
End