Fórum Teclado Virtual :: Falta Pouco #232419
14/05/2004
0
Vamos tentar finalizar este divã...
TForm
Name = frmTecladoVirtual
BorderStyle = bsDialog
Caption = ´Teclado Virtual´
FormStyle = fsStayOnTop
TSpeedButton´s das letras/números/caracteres
Caption = ´a´ ... ´z´
Tag = 0
TSpeedButton´s das funcionalidades
Caption = Esc/Ins/Del/PgUp/...
Tag = *Código da tecla* (27=esc/13=enter)
procedure TfrmTecladoVirtual.SpeedButton37Click(Sender: TObject); var Texto, NovoTexto, Letra: String; Posicao: Integer; begin with TCustomEdit(Componente) do begin if (TSpeedButton(Sender).tag = 0) then begin Texto := Text; Posicao := SelStart; Letra := TSpeedButton(Sender).Caption; if Posicao = Length(Texto) then NovoTexto := Texto + Letra else if Posicao = 0 then NovoTexto := Letra + Texto else NovoTexto := Copy(Texto, 1, Posicao) + Letra + Copy(Texto, Posicao + 1, Length(Texto) - Posicao); Text := NovoTexto; SelStart := Posicao + 1; end else ; end; end; procedure TfrmTecladoVirtual.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; end;
Exemplo para utilização do componente TTecladoVirtual.
TForm
Name = Form1;
TEdit
Name = Edit1;
TSpeedButton
Name = SpeedButton1;
OnClick = SpeedButton1Click;
procedure TForm1.SpeedButton1Click(Sender: TObject); begin Application.CreateForm(TfrmTecladoVirtual, frmTecladoVirtual); frmTecladoVirtual.Componente := ActiveControl; frmTecladoVirtual.Show; end;
PS: Aroldo! Cadê você com seus paradigmas orientados a objeto para nos ajudar?
Tinorj
Curtir tópico
+ 0Posts
14/05/2004
Tinorj
[url]http://www.tinojpa.kit.net/download/tecladovirtual.zip[/url]
Gostei + 0
18/05/2004
Tinorj
Gostei + 0
18/05/2004
Nildo
Gostei + 0
18/05/2004
Tinorj
[]´s
Gostei + 0
21/05/2004
Tinorj
Gostei + 0
23/05/2004
Tinorj
Gostei + 0
23/05/2004
Zoom
Gostei + 0
27/05/2004
Braytiner Heggendorn
Estou trabalhando com um form, onde preciso tratar na OnKeyDown a tecla TAB, mas essa tecla não gera eventos de teclado, vc tem alguma idéia de como poderia faze-lo/
Obrigado
Braytiner
Gostei + 0
27/05/2004
Tinorj
Gostei + 0
27/05/2004
Otto
altere a propriedade Keypreview do form pra true, e no evento OnKeyPress do form do teclado vc faz:
var i : Integer; begin if PodeDigitar then // if true [bool] begin if key = 13 then btnEnviar.Click; // Enter if Ord(Key) = 32 Then btnEspaco.Click // espaço else if Ord(Key) = 8 Then btnbackspace.Click // backspace else // se nao for nenhuma dessas, entao for i := 0 to ComponentCount - 1 do if Components[i] is TSpeedbutton then if (Components[i] as TSpeedButton).Caption = Uppercase(Key) Then Begin (Components[i] as TSpeedButton).Click; Break; End else // se nao tiver a recla digitada ele da um beep Beep; end else // se nao poder digitar. Beep; end;
a variavel PodeDigitar é uma que eu coloquei la pra saber se o carinha pode digitar ou nao, dai é so remove-la se quiser.
e se perceber, tem algumas teclas la que eu me referi a alguns botoes...
flw...
Gostei + 0
27/05/2004
Otto
[img:f30fc8119e]http://www.seek.srv.br/otto/delphi/tecladinho.gif[/img:f30fc8119e]
::IMG
Gostei + 0
31/05/2004
Tinorj
Isto já está pronto, falta implementar éas teclas ALT, CTRL, SHIFT, CAPS LOCK, NUN LOCK, ...
Mas valeu pela tentativa... :lol:
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)