CEF display current window - chromium-embedded

so i'm a beginner with CEF and i wanted to ask you people, if it's possible to draw an html file with CEF on the current window
The thing is that I don't have the executable source so i'm injecting a DLL in it.
So is it possible to inject a DLL in a program to display an html on the current window using CEF.If so, with which function?
Thank you in advance,
swiftiq

If you can get the hWnd window handle, you can open the CEF browser into it.
CefBrowserHost::CreateBrowser() takes a CefWindowInfo as the first parameter. Use CefWindowInfo::SetAsChild() to set the desired window.

Related

C GTK - How to set :display.screen for gtk application window to appear

I am using gtk.h for a C application under GNU/Linux and I would like to open my gtk window under a specific display.screen without exporting any environmental variables. The reason I don't want to set the DISPLAY variable and export it is I don't want to lose control of what was the default display in the first place.
I thought about wrapping the application with an X window and mapping it in the display.screen I want but I dont know if thats a good idea. Right now I am trying to set the display via gdk, but unfortunately I can only get x properties like windowid or current display number with my current knowledge. Also, I dont have a problem with the solution being linux specific.
Another crucial detail about why Im not setting the DISPLAY environmental variable is maybe I want to open multiple gtk windows from the application at :2.0 & :2.1.
It was in the gtk documentation after all, I guess I missed it because I was trying to find a native xlib solution. Here is the related documentation page:
For GTK 4:
https://docs.gtk.org/gtk4/method.Window.set_display.html
For GTK 2.2 - 3:
https://docs.gtk.org/gtk3/method.Window.set_screen.html
So in the end, you'll have to set GdkDisplay / GdkScreen somehow and pass it to gtk.

Win32 : Create tab control from a DLG file. How is it possible?

Good morning,
In our company, we use again WIN32 with dialog box who has been created in DLG file extension.
Let me tell you.
In DLG file, we define set of dialog box and windows who is gonna be used in our application.
And in the code C or C++, to call one or another DialogBox, we use the standard function DialogBox or again DialogBoxParam. For every dialog box, we use a file as controller who contains a WinMain with events loop in order to manage button clicks, hidding components, and so on.
There is a dialog box wherein I would like to use tab control. Is it possible to put every tab control with its components in my '*.DLG' file and to call it in my code C++ in order to be used not as window but tab control ?. If yes, how ? Otherwise, I stay opened to each other possibilities.
Thank you

Use a control in MainWindow from a nested page WPF VB.NET

I have a program in visual basic .net and WPF that uses a series of pages displayed in a Frame control on my main Window, pages are navigated from controls in the main Window outside of the frame and I have all that working ok.
I also have a MediaElement control on that main Window and I need to be able to change the source property of this control from the user clicking on elements in the pages. Every time I have tried to do this so far i have run into an error.
Right now I have a Public Shared function within main Window that is called from the control in the page, the code on the control passes on the URL to be loaded into the source property to the function, then the function is supposed to pass the url into the source property and tell the MediaElement to play.
The error I am getting when trying to achieve this is:
Cannot refer to an instance member of a class from within a shared
method or shared member initializer without an explicit instance of
the class.
Please help, how could I achive this?
Are you getting an instance of the main window or the media element inside of your shared function? If not, this is you problem.
You might stick the media element into a shared variable when the main window is loaded or you can access your main window using the rootvisual of your application.current.app.rootvisual.
If your issue is something else, please post the code in your shared function that causes the error.
Thank you very much Steve for your answer, however I found how to do what I need on another post after idly trying some different search terms today.
Someone known as Jean on another post: https://stackoverflow.com/a/16781963/2668533 suggested something that worked for me, by using application.current.windows:
Dim parent As MainWindow = Application.Current.Windows(0)
parent.player.Source = New Uri(url)
Apologies for seeming such a novice but WPF is completely new to me and I have never encounterd a need for anything similer using WindowsForms.

Launch WPF executable and set parent?

I have a WPF executable and I want another program to launch it and set this launching program as the parent windows of my WPF executable (The main purpose is that when the launching program is closed the WPF executable is also shut down). I thought I could make it like this: I pass the Hwnd as one command line parameter (as integer-string), and I can call the SetParent or whatever function inside my WPF executable code to specify the parent. However, I can't make it work. Can anybody tell me how to do that, or any other way to do that? Thanks!
You can't. Window handles are per-process.
Besides, you wouldn't want to. It's problematic enough to have a parent window in another thread -- that causes the message queues of the two threads to become attached, i.e., they effetively share the same message queue from then on. So now if either thread locks up, or does some lengthy processing, both threads are frozen. (And there's no way to later detach the message queues, as far as I'm aware.) Imagine trying to extend this cross-process.
If you must start some new code and use an existing window as a parent, you can't go cross-process. You would have to load the WPF code into your process and call a method in it, passing your parent window as a parameter. The simplest way to load that code into your process would be to change your WPF application to a class library (.dll), and either add a reference to that .dll, or load it dynamically using Reflection.
As #Joe White said you cannot achieve this straightaway ... I think I can "guess" what you are getting at ....
You probably have a WinForm MDI parent (its exe already) and you want to launch another WPF window (another exe) as its child. Am I correct?
Hmmmm then you would have to create a new WinForm child window with WinFormWPFHostApp in it and then refer the WPF assemblies to this project and try to host the Content of the MainWindow from that other WPF application.
refer this article...

How to let the parent window of a child window (a.k.a. owned window) stay active with winapi?

I am writing a small C application using winapi. There I've got a window with a child window (toolbox). I am able to keep it inside this window and so on, but my question is: How to keep the main window active, if the child window gets focused?
The main window gets grayed out in this moment.
The windows get created by:
hMainWindow = DialogBoxParam(.......);
hChildWindow = CreateDialogParam(..., hMainWindow, ...);
ShowWindow (hChildWindow, SW_SHOW);
Here a little image of the behaviour of the two windows:
I've found out that simply creating it as WS_CHILD and explicitly NOT as WS_POPUP solves that. It also turns the absolute window coordinates to relative ones so that I dont have to care about the window position anymore by moving the parent window.
// Solved
Create the child window as a modeless dialog box instead of a modal one. So instead of using DialogBox, use CreateDialog
Sorry, that's just the way Windows works: one active window at a time.
You can see this in Visual Studio if you bring up Find and Replace as a tool window, you'll see that it gets activated and the main VS window goes inactive.
Trying to have them both active at the same time could confuse users and accessibility tools like screen readers.

Resources