WIN32: Opening GetOpenFileName dialog _in_front_of_ browser window

208 views
Skip to first unread message

heinob

unread,
Feb 1, 2013, 12:58:27 PM2/1/13
to firebre...@googlegroups.com
Hi,

I am opening an GetOpenFilenName() dialog from within my plugin but FF, Chrome and Safari open the dialog behind the browser window. IE and Opera work fine. My idea is now to pass the browserHWND as OPENFILENAME.hwndOwner instead of passing NULL.

How can I get the hwnd of the browser? My research lead me to this:

FB::PluginWindowWin* w = (FB::PluginWindowWin*)(fb_win);
HWND hWndBrowser = GetAncestor( w->getHWND(), GA_ROOTOWNER );
But I do not know what "fb_win" is the the first line. And anyway is this the right way to get the dialog in front of the browser?

Thanks in advance,
Jochen

Richard Bateman

unread,
Feb 1, 2013, 6:16:52 PM2/1/13
to firebre...@googlegroups.com

This snippet assumes that you're using a windowed plugin (which is the default).  getWindow() in your PluginCore-derived class (main plugin class) will return that or NULL, depending on whether or not the plugin has a window at that point in the lifecycle.

Richard

--
 
---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Louis Beauchamp

unread,
Feb 1, 2013, 5:41:42 PM2/1/13
to <firebreath-dev@googlegroups.com>
Hi,

I had a similar issue where I found I had to call getHWND() for IE. In other browser, I used getBrowserHWND() instead which worked fine until we tested in IE. So now I use getBrowserHWND(), if it returns NULL then call getHWND(). In my context, I used the handle returned directly without calling GetAncestor().

Louis

heinob

unread,
Feb 2, 2013, 7:23:57 AM2/2/13
to firebre...@googlegroups.com
The snippet cannot not give a hint wether I have a "windowed" plugin, because I copied it from the stackoverflow link I posted below. Indeed I do not know what you exactly mean by "windowed". I thought my plugin is not windowed because it is an invisible container of service functions. No UI, besides some common win32 dialogues (as GetOpenFileName() ) that I call. But I thought too that this is the default. So now I am confused...

Taking your hint from below (and assuming I have no own plugin window), I exchanged "fb_win" with NULL and called the following


FB::PluginWindowWin* w = (FB::PluginWindowWin*)(NULL);
HWND hWndBrowser = GetAncestor( w->getHWND(), GA_ROOTOWNER );

But calling this makes my plugin crash! I have the feeling that I am completely on the wrong path. Please help!

Richard Bateman

unread,
Feb 2, 2013, 11:24:07 AM2/2/13
to firebre...@googlegroups.com

I'm not trying to be offensive, but if the idea of casting "NULL" to the pointer you need and then calling a method on that pointer didn't automatically set off alarm bells in your head then you really need to spend some time with a C++ primer.

There are two types of plugins: windowed and windowless.  Windowed plugins are what FireBreath creates by default.  Since you don't know otherwise, you have a windowed plugin (you would have had to intentionally change it). It doesn't matter whether your make your plugin visible or not, you are still windowed.  There is a possibility that if you have it completely hidden your window may never be given to you, depending on how you hide it; you need that window to make it work, however. I usually "hide" plugins by making them width="1" height="1" to make sure the browser doesn't get too creative about how it "hides" the plugin and that would probably do what you need.

Richard

heinob

unread,
Feb 2, 2013, 11:37:00 AM2/2/13
to firebre...@googlegroups.com
O.k., that seemed to be a kind of blackout. I have got it now:

FB::PluginWindow* pluginWindow = pluginAPI::getPlugin()->GetWindow();
FB::PluginWindowWin* w = (FB::PluginWindowWin*)(pluginWindow);
HWND hwndBrowser = GetAncestor( w->getHWND(), GA_ROOTOWNER );

Thanks for your patience....and not being offensive ;-)

Richard Bateman

unread,
Feb 2, 2013, 12:04:35 PM2/2/13
to firebre...@googlegroups.com

Again, let's go back to that C++ primer.  getPlugin is not a static method, you need to call it on your plugin instance.  pluginAPI::getPlugin() will not work.
 
Richard

Jochen Brüggemann

unread,
Feb 2, 2013, 12:23:50 PM2/2/13
to firebre...@googlegroups.com
hhhmmm. But it does! I have an implementation of getPlugin() in my class (I changed "my" to "plugin" in my last post - in my source "my" is the name of my project):

myPtr myAPI::getPlugin() {

    myPtr plugin(m_plugin.lock());
    if (!plugin) {
        throw FB::script_error("The plugin is invalid");
    }
    return plugin;
}



2013/2/2 Richard Bateman <ric...@batemansr.us>

Jochen Brüggemann

unread,
Feb 2, 2013, 12:43:27 PM2/2/13
to firebre...@googlegroups.com
I really seem to be in weekend mode...Of course you are right, but my code works anyway because I am within a member function while calling. So to be clear I changed the code:

FB::PluginWindow* pluginWindow = getPlugin()->GetWindow(); 

...and it still works :-) 



2013/2/2 Jochen Brüggemann <jochen...@gmail.com>

Richard Bateman

unread,
Feb 2, 2013, 7:34:56 PM2/2/13
to firebre...@googlegroups.com

Ahh.  That makes sense =] glad you figured it out.

Richard
Reply all
Reply to author
Forward
0 new messages