Building JuceBrowserPluginDemo with Visual Studio 2005

Just to note that the JuceBrowserPluginDemo won’t build with Visual Studio 2005. If I hack the version number (from 9 to 8!) in the .vcproj file, I can load it, but there are a handful of compilation errors…

c:\juce\extras\browser plugins\wrapper\juce_activex_gluecode.cpp(571) : error C2664: ‘VerQueryValueW’ : cannot convert parameter 2 from ‘juce::String’ to 'LPWSTR’
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
c:\juce\extras\browser plugins\wrapper\juce_activex_gluecode.cpp(575) : error C2664: ‘VerQueryValueW’ : cannot convert parameter 2 from ‘juce::String’ to 'LPWSTR’
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
c:\juce\extras\browser plugins\wrapper\juce_activex_gluecode.cpp(724) : error C2061: syntax error : identifier '__RPC__deref_out_opt’
c:\juce\extras\browser plugins\wrapper\juce_activex_gluecode.cpp(729) : error C2065: ‘phwnd’ : undeclared identifier
c:\juce\extras\browser plugins\wrapper\juce_activex_gluecode.cpp(785) : error C2259: ‘JuceActiveXObject’ : cannot instantiate abstract class



Ah, I don’t have VS2005 any more, so can’t try this, but it looks like just adding a couple of extra casts in front of the queryStr: “(LPTSTR) (LPCTSTR) queryStr”, and getting rid of the unnecessary “__RPC__deref_out_opt” should do the trick.[/code]

Jules, you are a genius - that worked. :smiley:

The plug-in demo page worked fine with firefox (once I’d removed the classid line as you suggested in the comments in the html file).

However, the Active X control didn’t display anything when using IE 7.

To fix this, I modified the project Build Events -> Post-Build Event setting, to add a regsvr32 line…:

copy /Y “(TargetPath)" "C:\Program Files\Mozilla Firefox\plugins" [b] regsvr32 "(TargetPath)”[/b]

Hope that helps - it’d be useful to put in your the SDK so other punters will have it work out of the box. :slight_smile:

BTW: this is a really nice bit of coding by you, you’ve excelled yourself - again :slight_smile: - many congrats!

Best wishes,


Thanks! I didn’t add a regsvr32 call because I was having trouble with it on vista - it needs admin privileges, so I had to run it manually.

Vista - aarrrggghhh! :shock:

BTW the mechanism you’ve used for implementing plug-in methods (setMethod) is brilliant…


BTW Jules, if you change the test.html file to have the object tag as follows, it’ll work automatically with both IE and Firefox. Spot the embed tag that I’ve added…

BTW: the plug-in doesn’t work quite right with Safari on Windows (haven’t tried yet on Mac) … you have to force the main Safari window to repaint before you can see the Juce component (e.g. by resizing the Safari window) (and there is a funny band on the right too) … any ideas how to solve it?



<object id="plugin"
        width="80%" height="400">
        <embed src="" type="application/npjucedemo-plugin" width="80%" height="400"></embed>

Ah, thanks for the cunning html trick…

I’ve not tried it in win32 safari yet, it’s quite a low priority, but will check it out when I get time!

No worries Jules.

We’re hoping to release a product in the next 3-4 weeks that leverages the Juce web browser plug-in addition … ! … so I’m sure we’ll fix this between us by then. :slight_smile:

I used to do lots of web plug-in development back in the days of the SSEYO Koan Plug-in … nice to be getting my oar in again!

Best wishes,


Wow - you’ve checked it in already. :slight_smile:


Here is the fix to get the plug-in to display properly on Safari. I’ve checked with Windows: Safari/Firefox/Internet Explorer.

In juce_NPAPI_Glue_Code.cpp …

First bit:

    void resizeToParentWindow(int width = 0, int height = 0)
        if (IsWindow (parentHWND))
            RECT r;
            GetWindowRect (parentHWND, &r);

            int lUseWidth = r.right - r.left;
            int lUseHeight = r.bottom -;

            // On Safari, the width and height of the HWND can be zero!
            // If this is true, then force the window to use the size specified
            // by the NPAPI API parameters.
            if ((lUseWidth == 0) || (lUseHeight == 0))
                lUseWidth = width;
                lUseHeight = height;

            setBounds (0, 0, lUseWidth, lUseHeight);

Second bit:

    void setWindow (NPWindow* window)

                // Change the call to resizeToParentWindow, to pass in 
                // the width/height specified by the NPAPI plug-in...
                resizeToParentWindow(window->width, window->height);



Ah! Great stuff! Many thanks Pete, I’ll roll that in there today…

No worries Jules! :slight_smile:

For my next trick, I’ll try to figure-out why scripting doesn’t work for Firefox on the Mac … I’ll keep you posted!

I’ve moved this discussion to the Mac forum…


Hi Jules,

Can you please give me a pointer on how to get the properties passed-in to the browser plugin? Looks to me like you might not have done this yet, but thought I should check. What you have done is very powerful btw - many congrats. I’ve only had to tweak it a bit to get it working the way I want it.


<embed… src=“whatami” …>


(I'd guess this'd be via some sort of property bag query, but am not sure!)

Best wishes,


No, sorry, I didn’t get round to adding parameters…

Ah, OK, no worries; I’ll have to figure-out how to do it!


Hi Jules,

Here is an even better solution - this allows scripting to work properly on the various browser variants (some of them otherwise get confused by the <object… tag!) …:

var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer")
  document.write('<object id="plugin" type="application/npjucedemo-plugin" classid="CLSID:F683B990-3ADF-11DE-BDFE-F9CB55D89593" width="80%" height="400"></object>');
  document.write('<embed id="plugin" src="" type="application/npjucedemo-plugin" width="80%" height="400"></embed>');
<noscript><embed id="plugin" src="" type="application/npjucedemo-plugin" width="80%" height="400"></embed></noscript> 



Nice one, thanks!

No worries Jules, always happy to share what I can. :slight_smile:

BTW: I don’t actually need support for parameters in the browser plug-ins at the moment, as I can set all the values I need through JavaScript method calls.