I'm using this code to get the child windows of all open processes.
The code itself is working correctly, I get a 2 dimensional list of handles. Each index has a list of handles to the child windows of a specific process.
I'm trying to get a child window of a game. The game itself is inside window. It appears in the task manager and in my task bar. There is a button inside the game I press that opens a new window. The new window does not appear in the task manager but it does appear on the task bar.
The problem is the code in the link above will not return any child windows for the game even though a new window has opened and it can be seen in the task bar.
Any Ideas what I could be doing wrong?
Ok found the solution, should have used GetWindowText instead.
Related
I have recently migrated a project of mine to WebView2 and the last part I can't figure out is how to intercept the Windows Messages for the webview. My code is very similar to webview/webview but I was unable to find help on their GitHub.
Previously, I was able to find the hWnd for the webview and use SetWindowSubclass to add my own wndproc to the webview. However, I've used Spy++ and tried SetWindowSubclass on all the windows that showed up there (see below) but none of them had any windows messages in my wndproc other than some window management ones I did not think were useful - The best I got was WM_PARENTYNOTIFY, but I am interested in WM_MOUSEMOVE and WM_NCHITTEST - neither of which I could find.
My goal is to create a borderless, draggable, resizeable WebView2 based app.
The problem is, that the real window that controls and gets all this input is in another process. You just see a window that shows the output in your process.
Look into Spy++. Everything below Chrome_WidgetWin_0 belongs to a new process (MSEDGEWEBVIEW2) and is not part of your process. So you can't subclass such a window with the normal techniques.
So if you want to subclass this window. You need to inject a new DLL into this new process. This DLL might subclass the real window. And this DLL might communicate with you hosting program via any IPC.
OK, so a noob question here: How do you code this functionality that browsers have for example? You open a chrome browser for example and you can open multiple tabs open. Then you can move one tab out of the window and it becomes another window, having its own separate process. Then you can drag that tab into another window and they become one frame? Similar to docking in windows applications, but how do you do it with executables?
Windows-specific answer, though I think other OSs work pretty much the same: the HWND handle that you get for a window is global. If you send its numeric value to a different process, that process can use it to do things with the window: get its information, resize it, even draw on it. What it can't do is replace its event handler function.
To get process separation like browsers have nowadays, the key is to create a container window and send the handle to the child. The child then creates its own window as a child of the container. The child window simply fills out the entire content area of the container.
This way, the content process is contained within the parent's window, but can handle events.
Now, if you want to drag out a tab into its own top-level window, the parent process creates a new top-level window with all the UI inside, and then re-parents the content container to this new top-level window. The content child follows along.
I can't tell you how to code it, you should search the feature inside the chromium code to know how it's coded but I can tell you how it works:
Inside chromium every tab, extension, utility, etc is a process, each one of these processes is child of the "Browser" process, the "Browser" process manages everything (creating new windows, opening new tabs, closing tabs, destroying windows etc) so, for example, whenever you open a new instance of chromium you are telling the "Browser" process to create a new tab and put it inside a new window.
Every window is managed by the "Browser" process and every tab is managed by a process that is child of the main process.
Now to reply your question: when you drag & drop a tab outside a window you're triggering an event that is caught by the "Browser" process which then create a new window and assign the tab to the new window.
Those informations should give you a hint on how you could develop this feature yourself.
If you want to know more about the chromium architecture I suggest you to read how chromium is designed at https://www.chromium.org/developers/design-documents
I'm working on a personal project where I need to invoke my function after an menu item in another process is clicked.
I'm using
BOOL enumeratingWindowsSucceeded = ::EnumWindows(enumWindowsProc, NULL);
to retrieve the handles to all of the currently open windows on my computer and using
GetSystemMenu(...)
and
AppendMenu(...)
to add an item into all the window's title bar context menu.
Now the problem is when the menu item is clicked in the other window's context menu, my program does not know about it.
Is there a way to override the WindowsProc of another window so that my process can execute some piece of code? Or is there a better way to make the menu item communicate with my program?
Thanks!
I have a dialog based MFC application and I want to get notified when the complete application becomes active or inactive. When the user switches to another application and comes back to my application I need to execute some code.
How can I do this?
I already tried OnActivate but that doesn't help me much. The main window will also becomes inactive when another window of the same application will open. That is not what I need.
You receive WM_ACTIVATEAPP when another window gets active that doesn't belong to your application.
I have the following situations where I would like to display some widgets.
My main windows is mostly a text editor.
I have an action called 'Run', which interprets the text and does something.
One of the possible results is that a window needs to be opened.
It works, but the window is only displayed after the run function (which I have as a slot)returns.
Another situation I have to open a window is that I want to be abe to same interpreter to run from console input.
But opening the window in this case results in errors like:
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0xee2d90), parent's thread is QThread(0xda53b0), current thread is QThread(0x7f2178004000)
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
What can I do to somehow 'centralize' window operations so that this does not happen ?
All GUI objects are to be created within your main thread. You can get access to QMainWindow instance from any place in your code using static method QApplication::topLevelWidgets()