Embedding CEF3 with existing application - chromium-embedded

I have a running WIN32 application. There a window in this application where I want to show web content using CEF3. But, I am facing problems and the entire window becomes white without showing any web page content. So I have the following questions:
Is it possible to use CEF3 with existing message loop in application? I dont want to call the CEF message loop, it may impact other things in my application.
Is it absolutely necessary to use a message window as in the sample application? I am not able to understand its objective.
When CEF3 launches multiple processes, how does it show in the task manager? If my application name is A.exe, does it show A.exe multiple times in task manager?
Any help is much appreciated.

For windows users there is possible to use multi threaded message loop (CefSettings). It is allow maintain browser windows via own message loop. But there is good practice use single threaded message loop, - you can call CefDoMessageLoopWork periodiacally on idle or some additional events. It is possible even with existing message loop.
I'm not sure what you mean.
CefSettings.BrowserSubprocessPath specifies which executable will be used for child processes. While you are integrating it in other process, looks like it is one possible solution and in task manager you will see processes as you named it.

About the question number 2:
every windows application has its own "main window" and wndProc that receives all the messages sent by his children.
And the sample win32 cefclient shows how to integrate cef message loop inside the application's message loop.
And if you don't handle and dispatch cef messages in proper way the browser window becomes white.

Related

Selectively disable Process features

I've been trying to create a WPF application which will be a proactive filter trying to limit user activity. I've controlled mouse and keyboard through Win32 API. Now another requirement is to let the user open every other application/file through the WPF one.
I don't want to disable the user's clicking ability while he's inside a process. I've tried to disable file access but with no luck.
I have control over the user while launching a new process but what if he opens a file within the process?
Can I just disable 'New' and 'Open' options or the complete file menu in any other process like Microsoft Word?
You can try this. But the problem is, that this just tells what files are currently being accessed by the given process. So you can maybe kill the process in that moment:D Or warn the user. But as far as i know, you cannot create a semi-layer between another process and his system requests (like is the file [read/write] access request).
EDIT: Maybe there is another option. If these restricted files are known to you, and there is just small amount of them... then you can just lock them for your process and disable access to them for every other processes.

Parent window not receiving window's messages (Key Events)

I have a GUI application that is written using win API's
and we need to launch a new GUI application when the user selects some command menu items.
We decided to write the new application in PyQt and launch the PyQt application usig Python C Api.
Everything is working fine except that the Parent window, through which we launch the PyQt Application, is not responding to some of the events when PyQt application is open. Once we close the PyQt Application it starts responding again to the key events.
I guess, that once the PyQt Gui application is launched, somehow the messages are not passed to the Parent window.
Inspecting with Spy++ I've found the following result:
Receives messages for:
- ALT key
- F1, F2 keys
- Mouse events
Does NOT receive messages for:
- CTRL key
- All other Fn keys
- All letter keys
- SHIFT, CAPS keys
Any thoughts to solve this problem would be appreciated
I believe what you are trying to do -- operate two separate GUIs within a single process -- is not supported by any major operating system. A while back, I searched for a long time for ways to do this and never came up with any advice except "don't".
I'm surprised that missing keys are the only problem you have.. I recommend finding a different solution before you discover more trouble (unless you can find some good evidence that this is at least supposed to work).
Could you perhaps spawn a new process to run the Qt event loop instead? Since you already have python embedded in the main process, this should be fairly easy--use python's built-in IPC to handle the communication between processes.
One solution is to build the QtWinMigrate module to create a QWinHost which supports parenting to a native HWND but unfortunately it is not part of the PyQt distribution.
You can find some sources here: https://github.com/glennra/PyQtWinMigrate.
This is what had to be done for Python integration in 3ds Max by Blur studio. I am currently studying the C++ source code of QWinWidget too see if I can work out an alternative solution using Win32 calls.

WPF application calls an API that needs a message pump; Dispather.Run() causes problems

I have a WPF app that uses a non-WPF vendor library. My app does not receive any events that the library fires. I've been told that this is because I need a message pump.
In another (very similar) question, the accepted answer suggested using System.Windows.Threading.Dispatcher.Run().
When I add in that call, however, my window won't pop up-- the app is effectively backgrounded and I have to shut it down with Task Manager.
I'm really stumped here, and I'm not even sure how to investigate it. Any help would be greatly appreciated.
You already have one if you use WPF, there's no other way that it can get any Windows notifications. Every WPF app starts life with a call to Application.Run() on the main thread. It is usually well hidden, auto-generated in the bin\debug\app.g.cs source code file. Application.Run() in turn calls Dispatcher.Run()
Your vendor is correct, without a message loop many COM components go catatonic. But since you have one you need to look for the problem elsewhere. Don't use the component on threads.

Is it possible for an application to take ownership of a window from another application?

Basically, I have two applications that run sequentially (second is started by the first, and the first exits immediately after.) I'd like to pass ownership of a window the first application created to the second application. The actual contents of the window don't need to be passed along, it's just being drawn in by DirectX.
Alternatively, but less desirably, is it possible to at least disable the window closing/opening animation, so it at least looks like the desired effect is achieved?
(This is in C, using the vanilla Win32 API.)
Instead of separated application make a DLL that will be loaded by the first application and run within it.
I suspect that you're going to run into problems because the WindowProc function is located in the memory address space of the program that you're closing.
Also, a quick look at the second remark at the bottom of the documentation for RegisterClass doesn't seem to offer up much hope.
The only work around that I can suggest for what you've described is to not close the first application until the second application is finished with the window in question.
you can use API hooking to make your DLL capture API windows calls sent by the application window and respond as if your DLL is the windows DLL
for more information about hooking check :
Hooks Overview

WPF Application that Listens for Commands Even When not the Active Application

I would like to configure a WPF application to function in a similar way to SlickRun. I would like to be able to minimize the application to the taskbar, then while in any other program, press a key command (ex: ALT + X) and have my application appear to the user.
Can someone point me in the right direction?
Your best bet is to use RegisterHotKey(). That works by sending the WM_HOTKEY message to the HWND you passed in. Since WPF doesn't expose its windows' message loop to developers, you'll probably need to get your hands dirty with some interop and create a message only window to receive the hot key messages.

Resources