Board index » cppbuilder » Copy (ctrl+C) in TCppWebBrowser

Copy (ctrl+C) in TCppWebBrowser


2004-02-18 10:03:40 AM
cppbuilder36
Hello. I have two projects that use this ax control. They both seem to
have about the same properties. Yet in one, Copy (ctrl+C) "works" and
in the other Copy does not work. I've made the non-working application
have the same KeyPreview value as is used in the working application.
And both have keypress events assigned but in neither case is ctrl+C a
value of interest to the method.
I'm sure that in the long run I ought to use the IHTMLSelectElement (?)
to get the right text. But right now I'd just like to understand this
difference under the assumption it's likely some simple thing I'm not
thinking of right now.
PS: both applications use the same library to create and feed
IHTMLDocument2.
Thanks.
 
 

Re:Copy (ctrl+C) in TCppWebBrowser

I am pretty sure TCppWebrowser (actually the MSHTML component it wraps)
grabs the keystroke. MSHTML supports copying to clipboard via CTRL+C on its
own. I assume you want to override its behavior. KeyPreview on your form
will most likely not due the trick. I have had to work around this as well.
The solutions I have used are:
1. Look into IDocHostUIHandler and TranslateAccelerator. You can tell
MSHTML to ignore the keystroke and handle it yourself.
or
2. Drop a TApplicationEvents component on your form and look for KEYDOWN /
UP messages being sent to the MSHTML window and intercept them.
Both methods work, but #2 may be easier / more straight forward.
Mark Finkle
"Frank Burleigh" < XXXX@XXXXX.COM >wrote in message
 

Re:Copy (ctrl+C) in TCppWebBrowser

Thanks Mark. I'd actually *like* mshtml to handle the key. I don't
understand why in one app it gets it and does, but *not* in the other app.
Mark Finkle wrote:
Quote
I am pretty sure TCppWebrowser (actually the MSHTML component it wraps)
grabs the keystroke. MSHTML supports copying to clipboard via CTRL+C on its
own. I assume you want to override its behavior. KeyPreview on your form
will most likely not due the trick. I have had to work around this as well.
The solutions I have used are:

1. Look into IDocHostUIHandler and TranslateAccelerator. You can tell
MSHTML to ignore the keystroke and handle it yourself.

or

2. Drop a TApplicationEvents component on your form and look for KEYDOWN /
UP messages being sent to the MSHTML window and intercept them.

Both methods work, but #2 may be easier / more straight forward.

Mark Finkle

"Frank Burleigh" < XXXX@XXXXX.COM >wrote in message
news:4032c7fa$ XXXX@XXXXX.COM ...


--
Frank Burleigh
Indiana University School of Law
XXXX@XXXXX.COM
 

{smallsort}

Re:Copy (ctrl+C) in TCppWebBrowser

Are you using any hot keys in your menus for Copy? Like "Copy Ctrl+C" in
your edit menu. If so, Builder may be eating the keypresses so IE can't get
them.
Mark Finkle
"Frank Burleigh" < XXXX@XXXXX.COM >wrote in message
Quote
Thanks Mark. I'd actually *like* mshtml to handle the key. I don't
understand why in one app it gets it and does, but *not* in the other app.
 

Re:Copy (ctrl+C) in TCppWebBrowser

I add this in my application to make my Copy can work:
OleInitialize(NULL);
"Frank Burleigh" < XXXX@XXXXX.COM >????
Quote
Hello. I have two projects that use this ax control. They both seem to
have about the same properties. Yet in one, Copy (ctrl+C) "works" and
in the other Copy does not work. I've made the non-working application
have the same KeyPreview value as is used in the working application.
And both have keypress events assigned but in neither case is ctrl+C a
value of interest to the method.

I'm sure that in the long run I ought to use the IHTMLSelectElement (?)
to get the right text. But right now I'd just like to understand this
difference under the assumption it's likely some simple thing I'm not
thinking of right now.

PS: both applications use the same library to create and feed
IHTMLDocument2.

Thanks.