I want to create several applications in c++, each one having its own GUI. All the applications will be launched by another app (app A). This app will open all the GUI apps. What I want is that the UI content of each app to be displayed in the same window. The user can browse the ui for each app using tabs. The user should only open app A, and A will open each UI app and displayed their interface in the same window. Can someone give me some direction in how to achive this? I'm developing in Visual Studio 2010 C++. (Windows applications)
问问题
243 次
1 回答
2
This can be done if your ui applications can communicate its windows handles to host application. And in your host application you will need to reparent those windows into the tabs. Something like this:
// hWnd is the window we want to embed
long style = ::GetWindowLong(hWnd, GWL_STYLE);
style |= WS_CHILD;
style &= ~WS_POPUP;
style &= ~WS_CAPTION;
style &= ~WS_THICKFRAME;
SetWindowLong(hWnd, GWL_STYLE, style);
SetParent(hWnd, hostHWnd() /* this returns HWND of the host window */);
SetWindowPos(hWnd, HWND_TOP, 0, 0, hostWidth(), hostHeight(), SWP_SHOWWINDOW);
ShowWindow(hWnd, SW_SHOW);
You can communicate windows handles via named pipes, for instance.
But be ready to experience some problems when doing this. For instance you will need to resize embedded windows when the host window is resized (by calling SetWindowPos as in example).
于 2013-08-22T12:06:33.403 回答