delphi - Why does arrow key navigation not work in TWebBrowser? -
here simple program hosts twebbrowser
control in vcl application:
unit1.pas
unit unit1; interface uses winapi.windows, winapi.messages, system.sysutils, system.variants, system.classes, vcl.graphics, vcl.controls, vcl.forms, vcl.dialogs, vcl.olectrls, shdocvw; type tform1 = class(tform) procedure formcreate(sender: tobject); end; var form1: tform1; implementation {$r *.dfm} procedure tform1.formcreate(sender: tobject); var browser: twebbrowser; begin browser := twebbrowser.create(self); tolecontrol(browser).parent := self; browser.align := alclient; browser.navigate('http://www.bbc.co.uk/'); end; end.
unit1.dfm
object form1: tform1 left = 0 top = 0 caption = 'form1' clientheight = 587 clientwidth = 928 color = clbtnface font.charset = default_charset font.color = clwindowtext font.height = -11 font.name = 'ms sans serif' font.style = [] oldcreateorder = false oncreate = formcreate pixelsperinch = 96 textheight = 13 end
when run program, able scroll through page using arrow keys, up/down/left/right. however, these keys have no effect. can use page , page down, not up/down/left/right.
i re-created equivalent application in .net winforms application using webbrowser
control , behaviour identical. seem suggest issue underlying control.
can these keys work? or lost cause?
i believe form interpreting these keys dialog navigation keys. changed control's response wm_getdlgcode
message request control handles these keys:
type twebbrowser = class(shdocvw.twebbrowser) protected procedure wmgetdlgcode(var msg: twmgetdlgcode); message wm_getdlgcode; end; procedure twebbrowser.wmgetdlgcode(var msg: twmgetdlgcode); begin inherited; msg.result := msg.result or dlgc_wantarrows; end;
this appears resolve issue.
Comments
Post a Comment