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 ?
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(va r 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( WebBrowser 1.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(IO leInPlaceA ctiveObjec t, 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.Tr anslateAcc elerator(M sg);
end;
end;
procedure TForm1.FormActivate(Sender : TObject);
begin
SaveMessageHandler := Application.OnMessage;
Application.OnMessage := MyMessageHandler;
end;
procedure TForm1.FormDeactivate(Send er: 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
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(va
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(
if (Handled) and (not WebBrowser1.Busy) then
begin
if FOleInPlaceActiveObject = nil then
begin
Dispatch := WebBrowser1.Application_;
if Dispatch <> nil then
begin
Dispatch.QueryInterface(IO
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.Tr
end;
end;
procedure TForm1.FormActivate(Sender
begin
SaveMessageHandler := Application.OnMessage;
Application.OnMessage := MyMessageHandler;
end;
procedure TForm1.FormDeactivate(Send
begin
Application.OnMessage := SaveMessageHandler;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Application.OnMessage := SaveMessageHandler;
FOleInPlaceActiveObject := nil;
end;
procedure TForm1.Button1Click(Sender
var a,b,c,d:OleVariant;
begin
WebBrowser1.Navigate(Edit1
end;
initialization
OleInitialize(nil);
finalization
OleUninitialize;
end.
it should work after adding that,let me know
Regards Barry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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(
Any ideas?
Steve
ftp://ftp.cdrom.com/pub/delphi_www/ftp/d20free/keyboard.zip