Creating a wx app when given a parent/top-level HWND?
Creating a wx app when given a parent/top-level HWND?
We're looking at creating a browser plugin and our codebase uses wxWidgets. I can see a wxApp class doesn't require a HWND, and it seems that a TopFrame isn't a requirement for an application either?
In a browser plugin (on Windows) you are essentially given a HWND to let you do your custom rendering. How (if possible) would one create wx controls or windows within this setup? Could you create a wx window that wraps an existing HWND, or in some way parent wx windows to a bare HWND?
I know that Win32 controls can be used in plugins, so the question seems to be more about how wx exposes functionality than about the Win32 API itself.
In a browser plugin (on Windows) you are essentially given a HWND to let you do your custom rendering. How (if possible) would one create wx controls or windows within this setup? Could you create a wx window that wraps an existing HWND, or in some way parent wx windows to a bare HWND?
I know that Win32 controls can be used in plugins, so the question seems to be more about how wx exposes functionality than about the Win32 API itself.
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Do you manage yourself main()? I guess I have not understood your question! Is the Host wx application or the plugin is wx based?JohnD wrote:I think the question can be simplified to:
If I have a HWND passed in from someplace, can I use this as the basis for a wx-based application? I imagine there are a few scenarios where this could be the case, browser plugins are just one example.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
That's the whole point, the host is unknown and there is no main(). So imagine I have a DLL project with an API method:
Code: Select all
//Application passes main window handle in
//This method initializes wxWidgets using this HWND
void Init(HWND handle);
-
- Ultimate wxWidgets Guru
- Posts: 672
- Joined: Tue Aug 31, 2010 6:22 am
- Location: Belgium
If your application is not a GUI one, you are not obliged to create a TopFrame, indeed.I can see a wxApp class doesn't require a HWND, and it seems that a TopFrame isn't a requirement for an application either?
There is a function that allows you to retrieve the HWND Window Hanlde (wxWindow::GetHandle). From this point, you should be able to use standard windows functions API to do what you want.or in some way parent wx windows to a bare HWND?
-
- Ultimate wxWidgets Guru
- Posts: 672
- Joined: Tue Aug 31, 2010 6:22 am
- Location: Belgium
We do indeed want to use wx GUI, it's just we are given a bare HWND from an external source, i.e wx cannot create the top window as a wxWindow.briceandre wrote:If your application is not a GUI one, you are not obliged to create a TopFrame, indeed.I can see a wxApp class doesn't require a HWND, and it seems that a TopFrame isn't a requirement for an application either?
That's the opposite to what I want I have a HWND and want to create wx windows either wrapping it or creating children from it.There is a function that allows you to retrieve the HWND Window Hanlde (wxWindow::GetHandle). From this point, you should be able to use standard windows functions API to do what you want.or in some way parent wx windows to a bare HWND?
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
JohnD,JohnD wrote:We do indeed want to use wx GUI, it's just we are given a bare HWND from an external source, i.e wx cannot create the top window as a wxWindow.briceandre wrote:If your application is not a GUI one, you are not obliged to create a TopFrame, indeed.I can see a wxApp class doesn't require a HWND, and it seems that a TopFrame isn't a requirement for an application either?
That's the opposite to what I want I have a HWND and want to create wx windows either wrapping it or creating children from it.There is a function that allows you to retrieve the HWND Window Hanlde (wxWindow::GetHandle). From this point, you should be able to use standard windows functions API to do what you want.or in some way parent wx windows to a bare HWND?
What creates top frame, your app or host? Where is main, in your app or host? Can you give a clue as to how your app relates to host?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
-
- Ultimate wxWidgets Guru
- Posts: 672
- Joined: Tue Aug 31, 2010 6:22 am
- Location: Belgium
I think I understand what you want to do. The question, now, is : do you have enough information to try implementing your app or are you still waiting something ?Sorry I can't think of any way to make my question clearer!
Personnaly, I think that, with post from DoubleMax explaining you how to assign a HWND to a wxWindow, and mine explaining how to initialise wxWidgets without instantiating a wxApp, it should be OK. But if you still wait for info, just tell what you are still missing.
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
I can think of few scenarios:JohnD wrote:Sorry I can't think of any way to make my question clearer!
1. wx application (Having IMPLEMENT_APP and main Frame) and non wx DLLs
2. non wx Application with main, having wx DLLs with GUI components
.......
Which one is likely yours?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
-
- Ultimate wxWidgets Guru
- Posts: 672
- Joined: Tue Aug 31, 2010 6:22 am
- Location: Belgium
This one. For instance in a browser plugin you create a DLL for your 'app' and the browser passes your DLL a HWND to render in... obviously the browser is non-wx but we want to put wx controls belonging to the HWND we are given.evstevemd wrote: 2. non wx Application with main, having wx DLLs with GUI components