Differenze tra le versioni di "Sapere via codice se il tasto 'Blocco Maiuscole' è attivo"
Da Gambas-it.org - Wikipedia.
Riga 1: | Riga 1: | ||
E' possibile sapere mediante il codice, se il tasto [https://it.wikipedia.org/wiki/Blocco_maiuscole Blocco maiuscole] è attivo, utilizzando alcune risorse della libreria ''SDL''. | E' possibile sapere mediante il codice, se il tasto [https://it.wikipedia.org/wiki/Blocco_maiuscole Blocco maiuscole] è attivo, utilizzando alcune risorse della libreria ''SDL''. | ||
− | Per poter utilizzare tali risorse sarà necessario installare nel sistema ed utilizzare nell'applicazione Gambas la libreria | + | Per poter utilizzare tali risorse sarà necessario installare nel sistema ed utilizzare nell'applicazione Gambas la libreria condivisa: "''libSDL-1.2.so.0.11.4'' ". |
Riga 32: | Riga 32: | ||
'''Public''' Sub Main() | '''Public''' Sub Main() | ||
− | + | Dim i, modifiers As Integer | |
− | + | Dim sf As Pointer | |
− | + | ||
i = SDL_Init(0) | i = SDL_Init(0) | ||
If i <> 0 Then Error.Raise("Impossibile inizializzare la libreria SDL !") | If i <> 0 Then Error.Raise("Impossibile inizializzare la libreria SDL !") | ||
− | + | ||
sf = SDL_SetVideoMode(1, 1, 0, 0) | sf = SDL_SetVideoMode(1, 1, 0, 0) | ||
− | If sf = 0 Then Error.Raise("Impossibile impostare una modalità video !") | + | If sf == 0 Then Error.Raise("Impossibile impostare una modalità video !") |
− | + | ||
modifiers = SDL_GetModState() | modifiers = SDL_GetModState() | ||
− | + | ||
If modifiers And KMOD_CAPS Then | If modifiers And KMOD_CAPS Then | ||
Print "Tasto 'Blocco Maiuscole': attivo !" | Print "Tasto 'Blocco Maiuscole': attivo !" | ||
Wait 3 | Wait 3 | ||
Endif | Endif | ||
− | + | ||
<FONT Color=gray>' ''Va in chiusura:''</font> | <FONT Color=gray>' ''Va in chiusura:''</font> | ||
SDL_FreeSurface(sf) | SDL_FreeSurface(sf) | ||
SDL_Quit() | SDL_Quit() | ||
− | + | ||
'''End''' | '''End''' | ||
− | |||
Versione delle 12:15, 6 gen 2022
E' possibile sapere mediante il codice, se il tasto Blocco maiuscole è attivo, utilizzando alcune risorse della libreria SDL.
Per poter utilizzare tali risorse sarà necessario installare nel sistema ed utilizzare nell'applicazione Gambas la libreria condivisa: "libSDL-1.2.so.0.11.4 ".
Mostriamo un semplice codice:
Library "libSDL-1.2:0.11.4" Private Const KMOD_CAPS As Integer = 8192 ' int SDL_Init(Uint32 flags) ' Initialize the SDL library. Private Extern SDL_Init(flags As Integer) As Integer ' SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) ' Set up a video mode with the specified width, height and bits-per-pixel. Private Extern SDL_SetVideoMode(width As Integer, height As Integer, bitsperpixel As Integer, flags As Integer) As Pointer ' SDL_Keymod SDLCALL SDL_GetModState(void) ' Get the current key modifier state for the keyboard. Private Extern SDL_GetModState() As Integer ' void SDL_FreeSurface(SDL_Surface* surface) ' Free an RGB surface. Private Extern SDL_FreeSurface(surface As Pointer) ' void SDL_Quit(void) ' Clean up all initialized subsystems. Private Extern SDL_Quit() Public Sub Main() Dim i, modifiers As Integer Dim sf As Pointer i = SDL_Init(0) If i <> 0 Then Error.Raise("Impossibile inizializzare la libreria SDL !") sf = SDL_SetVideoMode(1, 1, 0, 0) If sf == 0 Then Error.Raise("Impossibile impostare una modalità video !") modifiers = SDL_GetModState() If modifiers And KMOD_CAPS Then Print "Tasto 'Blocco Maiuscole': attivo !" Wait 3 Endif ' Va in chiusura: SDL_FreeSurface(sf) SDL_Quit() End