Differenze tra le versioni di "Conoscere gli attributi della finestra di un programma con le funzioni esterne del API di X11"
Da Gambas-it.org - Wikipedia.
Riga 56: | Riga 56: | ||
disp = XOpenDisplay(Null) | disp = XOpenDisplay(Null) | ||
− | + | <FONT Color=#B22222>XGetWindowAttributes(disp, <FONT Color=gray>''num_ID_della_finestra''</font>, attr)</font> | |
− | <FONT Color=gray>' ''Mostra le dimensioni in pixel della finestra del programma, specificata dal suo ID nella funzione esterna precedente:''</font> | + | <FONT Color=gray>' ''Mostra le dimensioni in pixel della finestra del programma, specificata dal suo ID nella funzione esterna precedente:''</font> |
− | + | Print attr.width, attr.height | |
<FONT Color=gray>' ''Chiude la libreria:''</font> | <FONT Color=gray>' ''Chiude la libreria:''</font> |
Versione delle 10:38, 23 ott 2016
Ogni finestra di un programma possiede degli attributi specificati nella Struttura XWindowAttributes della libreria di X11.
Per conoscere tali attributi si può utilizzare la funzione XGetWindowAttributes( ) della libreria condivisa: "libX11.so.6.3.0"
Tale funzione esterna richiede, fra l'altro, la specificazione del numero identificativo della finestra del programma, della quale si intende conoscere gli attributi specificati nella predett Struttura XWindowAttributes.
Mostriamo un esempio essenziale:
Library "libX11:6.3.0" Public Struct XWindowAttributes x As Integer y As Integer width As Integer height As Integer border_width As Integer depth As Integer visual As Pointer root As Long classi As Integer bit_gravity As Integer win_gravity As Integer backing_store As Integer backing_planes As Long backing_pixel As Long save_under As Boolean colormap As Long map_installed As Boolean map_state As Integer all_event_masks As Long your_event_mask As Long do_not_propagate_mask As Long override_redirect As Boolean screenp As Pointer End Struct ' 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 ' Status XGetWindowAttributes(Display *display, Window w, XWindowAttributes *window_attributes_return) ' Returns the current attributes for the specified window to an XWindowAttributes structure. Private Extern XGetWindowAttributes(display As Pointer, w As Long, window_attr As XWindowAttributes) As Integer ' 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) Public Sub Main() Dim disp As Pointer Dim attr As New XWindowAttributes ' Connessione al server X con impostazione di default: disp = XOpenDisplay(Null) XGetWindowAttributes(disp, num_ID_della_finestra, attr) ' Mostra le dimensioni in pixel della finestra del programma, specificata dal suo ID nella funzione esterna precedente: Print attr.width, attr.height ' Chiude la libreria: XCloseDisplay(disp) End