Link to home
Start Free TrialLog in
Avatar of alexandram
alexandram

asked on

Onscreen keyboard

I want to add an onscreen keyboard to an application used with a touch screen monitor. Is there a component that will do that ?
Avatar of inthe
inthe

here is one TKeyboard displays an alphanumeric, calculator or numeric keyboard on the screen. TKeyboard is especially usefull when writing Touch-Screen applications that have to be used without hardware keyboard. TKeyboard generates an event for each key pressed. Every descendent of TWinControl can be linked to TKeyboard and will then automatically get messages for the keys pressed. (ver. 1.10, added 2/21/99, updated 3/7/99)  

ftp://ftp.cdrom.com/pub/delphi_www/ftp/d20free/keyboard.zip
Avatar of alexandram

ASKER

I tried it but it won't work if it is not a descendant of TWinControl. This is a major problem because I use TWebBrowser a lot in my application.
it should work it sounds like you havent wrote a message handler for the webbrowser.
for a twebbrowser to get many of te normal windows messages it needs a message handler and here is an example:


unit Unit1;


interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, OleCtrls, SHDocVw_TLB,ActiveX;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    WebBrowser1: TWebBrowser;
    procedure Button1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormDeactivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
  procedure MyMessageHandler(var Msg: TMsg; var Handled: Boolean);

    { Public declarations }
  end;

var
  Form1: TForm1;
  FOleInPlaceActiveObject: IOleInPlaceActiveObject;
  SaveMessageHandler: TMessageEvent;


implementation

{$R *.DFM}

procedure TForm1.MyMessageHandler(var Msg: TMsg; var Handled: Boolean);
var
  iOIPAO: IOleInPlaceActiveObject;
  Dispatch: IDispatch;
begin
  { exit if we don't get back a webbrowser object }
  if WebBrowser1 = nil then
  begin
    Handled := False;
    Exit;
  end;

  Handled:=(IsDialogMessage(WebBrowser1.Handle, Msg) = True);

  if (Handled) and (not WebBrowser1.Busy) then
  begin
    if FOleInPlaceActiveObject = nil then
    begin
      Dispatch := WebBrowser1.Application_;
      if Dispatch <> nil then
      begin
        Dispatch.QueryInterface(IOleInPlaceActiveObject, iOIPAO);
        if iOIPAO <> nil then
          FOleInPlaceActiveObject := iOIPAO;
      end;
    end;

    if FOleInPlaceActiveObject <> nil then
      if ((Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP)) and
         ((Msg.wParam = VK_BACK) or (Msg.wParam = VK_LEFT) or (Msg.wParam = VK_RIGHT)) then
        //nothing - do not pass on Backspace, Left or Right arrows
      else
        FOleInPlaceActiveObject.TranslateAccelerator(Msg);
  end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  SaveMessageHandler := Application.OnMessage;
  Application.OnMessage := MyMessageHandler;

end;

procedure TForm1.FormDeactivate(Sender: TObject);
begin
Application.OnMessage := SaveMessageHandler;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Application.OnMessage := SaveMessageHandler;
  FOleInPlaceActiveObject := nil;
end;

procedure TForm1.Button1Click(Sender: TObject);
var a,b,c,d:OleVariant;
begin
     WebBrowser1.Navigate(Edit1.Text,a,b,c,d);
end;

initialization
  OleInitialize(nil);

finalization
  OleUninitialize;

end.


it should work after adding that,let me know
Regards Barry
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
inthe:

This doesn't work, I think I accidentally accepted your solution., sorry, but appreciate your time.

MyMessageHandler is entered, but doesn't even reach the   Handled:=(IsDialogMessage(wbCRMagic.Handle, Msg) = True);

Any ideas?

Steve