Old 18th October 2014, 17:31   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
EmbedHTML plug-in

Embeds an HTML document anywhere in the installer window.



http://nsis.sourceforge.net/EmbedHTML_plug-in


This plug-in is similar to my nsFlash plug-in in that you specify a window handle of an existing place-holder control to show the HTML document over. The place-holder can be on the inner or outer window.

It also enables maximum browser emulation by default, so the installer will take advantage of IE11 rendering if it is available, or IE10 or IE9 etc.

Stu
Afrow UK is offline   Reply With Quote
Old 18th October 2014, 19:22   #2
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 528
Send a message via ICQ to Pawel
Works nice... Thx Stu.
External website document is showed in installer, but with some delay (as it need to be downloaded and displayed and this depends on user internet connection).

Ps: Is there any possibility to download the page when installer is loading/showing welcome page for example - to only display it (without any delay) in our page?

Tested with Win8.1 and NSIS 3.0b1
Pawel is offline   Reply With Quote
Old 18th October 2014, 21:22   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You can download the page yourself to a temporary file and load that instead but currently none of the downloader plug-ins will work asynchronously AFAIK.

I was actually trying to get the control to load in the background so it could be reused on multiple pages without creating a new control but I was unable to get it to work... Once the control is attached to a window I was unable to reattach it to another window.

Stu
Afrow UK is offline   Reply With Quote
Old 18th October 2014, 23:49   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,101
I created a similar plugin a while ago but I don't think I released it because I could not get tab to work correctly out of the control and back to the parent dialog.

Do you force scripting and images on? I remember I had to add a little hack so that JS and images are enabled even if the user set them to off in IE. Most of the settings are sadly registry only, MS have not been good at keeping CoInternetSetFeatureEnabled current.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th October 2014, 17:02   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
New version:
Quote:
1.0.0.1 - 19th October 2014
* Now suppresses JavaScript errors.
* Now uses default IE settings rather than user-configured settings.
Anders, did your plug-in have a message loop or did you sub-class the inner/outer window? I'm not receiving WM_KEYUP/DOWN in my window procs...

Stu
Afrow UK is offline   Reply With Quote
Old 19th October 2014, 20:51   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,101
Quote:
Originally Posted by Afrow UK View Post
Anders, did your plug-in have a message loop or did you sub-class the inner/outer window? I'm not receiving WM_KEYUP/DOWN in my window procs...
Neither? I probably just got some OLE hosting thing wrong or perhaps WS_EX_CONTROLPARENT is not doing its job. I think the problem was only with tabbing out of the IE control and onto the next button etc.

In the .nsi it looks like this
Quote:
nsDialogs::CreateControl STATIC ${DEFAULT_STYLES} ${WS_EX_CONTROLPARENT} 5u 5u -10u -10u ""
Pop $9
EmbedIE::Embed $9 "isB" ; no Interaction (right click etc), no Scrollbar, add Border
StrCpy $WBOC $0
${If} $WBOC <> 0
FileOpen $9 "$PluginsDir\a.htm" w
FileWrite $9 '<li><a href="#">This</a>'
FileWrite $9 '<li><a href="http://example.com">That</a>'
FileWrite $9 '<li><a href="http://example.org" target="_blank">_blank</a>'
FileWrite $9 '<li><script>document.write(navigator.userAgent)</script>'
FileClose $9
EmbedIE::Go $WBOC "$PluginsDir\a.htm"
GetFunctionAddress $9 EmbedIECallback
EmbedIE::SetNotify $WBOC $9
${EndIf}
and EmbedIECallback is called so you can block/eat clicks, force non file:// url's to use ShellExecute to open a real browser etc.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd November 2016, 19:49   #7
suwalski
Junior Member
 
Join Date: Nov 2016
Posts: 15
Hi! Sorry to raise such an old thread, but...

Quote:
Originally Posted by Anders View Post
Neither? I probably just got some OLE hosting thing wrong or perhaps WS_EX_CONTROLPARENT is not doing its job. I think the problem was only with tabbing out of the IE control and onto the next button etc.
I've spent the last year (on and off) trying to figure out how to make the Tab key work in EmbedHTML.

I can't get it to work at all. If it was just a matter of not being able to Tab-out of the control, that would not be much of a problem. But I can't get it to work even in a form within the HTML area, making my registration text form within really awkward.

I've tried using ${NSD_Add[Ex]Style} with ${WS_TABSTOP} and ${WS_EX_CONTROLPARENT} on both the embedded control and on the nsDialog I've created to hold it. No difference.

Once thing I did notice is that the UI_TranslateAccelerator() returns E_NOTIMPL instead of S_FALSE as the similar implementation gives in this project. I tried altering the return value and there is no change as well. In fact, putting some debugging actions in there suggests to me that UI_TranslateAccelerator() never even gets called.

Did the tabbing work in Anders' solution because of the EmbedIECallback() function? Is that something we could do in EmbedHTML? Does someone know if it is some kind of setting for the OleCreate() code? Any hints?

Many thanks.
suwalski is offline   Reply With Quote
Old 3rd November 2016, 21:27   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,101
Quote:
Originally Posted by suwalski View Post
Did the tabbing work in Anders' solution because of the EmbedIECallback() function? Is that something we could do in EmbedHTML? Does someone know if it is some kind of setting for the OleCreate() code? Any hints?
No, that callback was so you could handle clicks on links in a NSIS function, it says so right at the bottom of my previous post! I don't think I ever tested tabbing in HTML forms.

Maybe someone could look at some MS SDK samples and see if they implement a browser anywhere? ReactOS? Might be some useful information in the MSJ/MSDN magazine archives as well...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 4th November 2016, 13:53   #9
suwalski
Junior Member
 
Join Date: Nov 2016
Posts: 15
Quote:
Originally Posted by Anders View Post
No, that callback was so you could handle clicks on links in a NSIS function, it says so right at the bottom of my previous post! I don't think I ever tested tabbing in HTML forms.
I was paying attention; to me "so you can block/eat clicks" suggested the possibility of capturing input events.

Quote:
Originally Posted by Anders View Post
Maybe someone could look at some MS SDK samples and see if they implement a browser anywhere? ReactOS? Might be some useful information in the MSJ/MSDN magazine archives as well...
Could you verify if your EmbedIE allows for tabbing to work, as was insinuated a few posts back? Perhaps something in that code could simply be moved over to EmbedHTML if it works.

Thanks for looking!
suwalski is offline   Reply With Quote
Old 4th November 2016, 18:19   #10
suwalski
Junior Member
 
Join Date: Nov 2016
Posts: 15
I've been experimenting with this all day.

I came across an article that suggests that this is normal for the Tab key and accelerators in OLE objects:

http://stackoverflow.com/questions/2...rtcuts-support

One of the links there is even more apropos:

http://stackoverflow.com/questions/2...owser2-control

I've gotten as far as making the CEmbedHTMLBrowser object inherit from IOleInPlaceActiveObject, but it wasn't enough for a magic fix.

That second page suggests that the event loop needs to call the TranslateAccelerator call explicitly from outside. However, while I'm familiar with Qt and Gtk, the Win32 event loop is a black box to me. Would that explicit call be done in the NSIS plugin WndProc, or would it have to be done all the way out in the NSIS WndProc?

Does any of this help?
suwalski is offline   Reply With Quote
Old 4th November 2016, 19:48   #11
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,101
We are the frame/container/site, I think IOleInPlaceActiveObject is implemented by the browser, not us.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 4th November 2016, 21:22   #12
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,101
Having to deal with NSIS at the same time is a bit much so I tried a little test application but the result is not much better.

Calling IOleInPlaceActiveObject::TranslateAccelerator in the main message loop lets IE handle tab on the page and it works on links and form input elements but tabbing in and out of IE is problematic.

Looking at the way IE 6 does it (or any IE version without tab support (page tabs, not keyboard tab key)) it does not put the IE control in a container window like we do, it is a sibling of the statusbar etc but tabbing works correctly. If I open the history sidebar (Ctrl+H) and then click in the addressbar and then press tab then focus moves to the IE page and after tabbing to the last link/input on the page then the focus ends up in the sidebar and then back to the addressbar. I'm unable to replicate this behavior .

I don't know if it is the IE page control or the IE frame/container that does the tab magic.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 7th November 2016, 20:42   #13
suwalski
Junior Member
 
Join Date: Nov 2016
Posts: 15
Quote:
Originally Posted by Anders View Post
Calling IOleInPlaceActiveObject::TranslateAccelerator in the main message loop lets IE handle tab on the page and it works on links and form input elements but tabbing in and out of IE is problematic.
Not that everything you said in the message isn't important, but to me, this specific functionality is the most important.

Do you think there is a way to call that TranslateAccelerator method in EmbedHTML's message loop, or is that too deep into event stack? I wouldn't want to have to alter NSIS' message loop just to get this working.

Thanks for looking into this.
suwalski is offline   Reply With Quote
Old 7th November 2016, 22:22   #14
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,101
Try a hook (SetWindowsHookEx) on the GetWindowThreadProcessId($hwndparent) thread: WH_GETMESSAGE, WH_MSGFILTER or WH_SYSMSGFILTER probably since you need to eat or set the message to WM_NULL if TranslateAccelerator handled the message so it is not processed by the window...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 8th November 2016, 19:34   #15
suwalski
Junior Member
 
Join Date: Nov 2016
Posts: 15
Talking Working!

Took a lot of work, but your method ended up working quite well.

Here's my diff: embedhtml-tab.zip

What have I learned from all of this?
  • makes no difference if NSIS control has ${WS_EX_CONTROLPARENT} flag
  • if the message is not set to WM_NULL in GetMsgProc() it is possible to tab out of the HTML area, but it doesn't operate reliably (seems like event race on Tab key)
  • in GetMsgProc(), do not set all keyboard messages to NULL, or no keyboard input works
  • there is no way to Tab out of the HTML area, but accelerator alt-N still activates "Next"

After all of this, I'd love to see this diff patched into the official version. I'd also like feedback if there are any concerns with my patch.

Thanks a bunch!
suwalski is offline   Reply With Quote
Old 8th November 2016, 20:28   #16
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,101
Quote:
Originally Posted by suwalski View Post
I'd also like feedback if there are any concerns with my patch.
Only set the message to WM_NULL if IOleInPlaceActiveObject::TranslateAccelerator returns S_OK...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 8th November 2016, 20:31   #17
suwalski
Junior Member
 
Join Date: Nov 2016
Posts: 15
Quote:
Originally Posted by Anders View Post
Only set the message to WM_NULL if IOleInPlaceActiveObject::TranslateAccelerator returns S_OK...
According to all of the documentation I've seen, it seems to be important that TranslateAccelerator() returns S_FALSE, and the patch makes that change as well. Maybe it still comes back as S_OK? I'll take a look tomorrow.
suwalski is offline   Reply With Quote
Old 8th November 2016, 20:50   #18
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,101
Your code does not even look at the return value! I'm talking about ipao->TranslateAccelerator((LPMSG)lParam); If it returns S_OK then IE processed the key, otherwise we should let NSIS process it.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 8th November 2016, 20:56   #19
suwalski
Junior Member
 
Join Date: Nov 2016
Posts: 15
Quote:
Originally Posted by Anders View Post
Your code does not even look at the return value! I'm talking about ipao->TranslateAccelerator((LPMSG)lParam); If it returns S_OK then IE processed the key, otherwise we should let NSIS process it.
Good point. None of the examples online do anything with the return value, so I didn't realize there even was one.

Checking for S_OK is brilliant! Now the tabbing works exactly correctly, including tabbing out to the NSIS UI elements like the Next button!

Here is the revised patch: embedhtml-tab-2.zip

Cheers.
suwalski is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump