is it possible to add an instance of a java application as a child form a .NET Form?
Thanks
I don't think it is. A Java program will have to run in its own process. A window from one process cannot be the child of a window of another process.
EDIT: Apparently I was wrong, it is possible to have a window from one process be a child of a window from another process, for example here
It might work with Java, depending on how the Java GUI framework the application uses works with Windows controls. The Windows Spy can help you figure out a little more about your Java application.
There is no easy and straightforward way todo that, at least that I'm aware of. One of possible solutions could be to make from your Java application an Applet and recall it inside embedded in Windows Form WebBrowser control. After you need to care about communication between your application and applet.
Some hints can find here
Hope this helps.
Related
I have a GLFW3 OpenGL project written in C++. I was looking to create a modern GUI to go with it. I have limited experience with XAML and windows WPF but it is intuitive to work with so I really want this to work.
I found 'WpfUnmanagedOpenGL' template from Github https://github.com/kopaka1822/WpfUnmanagedOpenGL and it runs great with a C++ DLL communicating with the Csharp OpenGL host window that is already working within the form using GLAD, not GLFW.
I managed to create a GLFW window with my existing code and it displays as a second popup window when the WPF form is compiled and run. See:
How can I embed this correctly?
I found this question on StackOverflow: embed window(glfwCreateWindow) as child to C++ MFC parent form .
Essentially it says I can set the GLFW window to be a child window of the WPF form. However I cannot get the WPF parent window handle to set it all up.
PLEASE help.
Thanks,
You may want to try to do the opposite. Rather than embedding your Win32 app inside your WPF form, embed your WPF form within your Win32 app instead.
Official docs:
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-wpf-content-in-win32?view=netframeworkdesktop-4.8
A really neat tutorial:
https://www.codeproject.com/Articles/5253279/Create-An-Awesome-WPF-UI-for-Your-Cplusplus-QT-App
This is for the legacy .NET Framework though. I have no clue if the same technique can be applied in the new .NET Core framework though.
I have an interesting case to solve:
I have a native (winapi) application, which uses MDI. This application allows me to extend itself with a simple scripting language. The scripts are launched on different thread than UI thread (although I can get the UI thread ID with appropriate functions). The scripting language also allow me to launch any c++ code (through LoadLibrary).
What I would like to achieve is to create a new window inside this application, which could host WPF and "attach it" as a MDI child window to MDI client (mdi area). Also, I would like this window to properly "talk" to MDI area, for example update list of windows in mdi menu.
So far, my first guess was to just create a WinForms window, host WPF inside, and then try to make it mdi child window by setting MDI client as it's parent (because my hosting application is not written in c#, I only have a handle, so I did this with User32.SetParent() P/Invoke). This worked almost well, after I attached my script thread to GUI thread, but I had few problems with it: the MDI menu with active windows did not update, the window did not interact correctly (it stayed on stop when it shouldn't etc.).
Then, I tried to set flags (style, exStyles) with SetWindowLongPtr. It changed my window's behavior a bit, but that was still not it.
Now I'm considering using CreateMDIWindow function, or doing it by SendMessage, according to docs sending message should create a window, even if I send it from different thread. The problem is, that this way would give me a native handle only, and I could not find (yet) any way of hosting WinForms / WPF inside it.
I'm curious if anyone tried to do something similar and had any results with it? Which way would be the best - trying to create a WinForms window and add it to MDI client, or create a native window and try to host WinForms in it (any particular way of doing that)?
Most answers for this question I have found are dealing with situation where hosting application is managed, so you can just set .MDIParent property, which won't work in this case I'm afraid.
Is it possible to insert one application for example to another application window using WinForms .NET application. I need application A to run in application B in a window of application B.
UPD
I would like to run .exe file in window of my program.
if you have not its source code, i think it is impossible
Possible duplicate answer: Embedding a winform within a winform (c#)
As stated in the answer to that question, you would be better moving your logic into a UserControl and hosting that control from either application in one WinForms window.
I have a process which I break into multiple processes and even when using threading it takes a very long time to complete.
I'd like to give the user an indication of the status of the execution in a cute way (for each process % complete). Maybe betting on the right horse will ease the pain :)
I found this project long ago: A Guided Tour of WPF (XAML)
I have two questions:
This article was written in 2007. Is there better way to achieve this graphic effect?
I have not understood yet, how the application is started, so I'd like to know if I can integrate such "window" in my window application?
Adam Robinson pointed out that the second question is not clear:
The application generates a window as in the picture below - I like to know if it possible to insert it in my "normal" windows application.
This article was written in 2007, is there better way to achieve this graphic effect?
WPF is the current "best" (or at least most feature-rich) way to develop a Windows Application for the desktop.
I have not understood yet, how the application is started, so I'd like to know if I can
integrate such "window" in my window application?
Make your application a WPF Application. This will automatically give you an application, Window class, and everything else you need to get started. Making a WPF application is just like any other application, except that you need to start the message pump, create the application, setup your startup window, etc. The "WPF Application" template in Visual Studio does all of that for you...
Until you understand what all is happening, I'd recommend starting with that, and customizing from there.
If you choose to stick with a win form for the main app, you can still host the desired window/control via an ElementHostControl. (hosts wpf inside winform).
Blessings,
Jeff
Assume i have an empty form 100px by 100px at 0,0 coordinates on the screen. It has no border style. Is there any way to have this positioned BEHIND the desktop icons?
I would assume this would involve the process Progman because thats what contains the desktop icons. But no matter what i try... getting window handles and changing parents etc, i cant seem to get the window to appear behind the icons.
Any ideas?
Essentially you want to draw on the desktop wallpaper. The desktop hierarchy looks like this:
"Program Manager" Progman
"" SHELLDLL_DefView
"FolderView" SysListView32
It's the SysListView32 that actually draws the desktop icons, so that's what you have to hook. And you can't just stick your form on top of it; you have to grab a WindowDC to that handle and draw on the DC.
It can be done - it has been done, but you're going to be using a lot of interop. Forget about doing this with a traditional Winforms Form. I don't think I've even seen it done in C#, although somebody did it in python, if that helps. I'm not a python coder myself, but the code is pretty short and easy to understand.
There is a solution to this problem, at least for Windows 8. I postet it in form of an article on CodeProject, so you can read about it here:
http://www.codeproject.com/Articles/856020/Draw-behind-Desktop-Icons-in-Windows
This works for simple drawing, windows forms, wpf, directx, etc. The solution presented in that article is only for Windows 8.
Google-fu led me to this MSDN forum question:
http://social.msdn.microsoft.com/Forums/en/winformsdesigner/thread/c61d0705-d9ec-436a-b0a6-6ffa0ecec0cc
And this is a blog post regard the major pitfalls with using GetDesktopWindow() or dealing with the desktop handle (as per your other question: C# Position Window On Desktop)
http://blogs.msdn.com/oldnewthing/archive/2004/02/24/79212.aspx
You also don't want to pass GetDesktopWindow() as your hwndParent. If you create a child window whose parent is GetDesktopWindow(), your window is now glued to the desktop window. If your window then calls something like MessageBox(), well that's a modal dialog, and then the rules above kick in and the desktop gets disabled and the machine is toast.
Anyway, I suspect that it probably CAN be done, but whether you should is another question.