Integrate an existing program into a new GUI - c#

I would like to integrate an existing program (ex: notepad, explorer, etc.) into a new window I want to create. The purpose would be to have 2 different programs in 1 window.
Do you know if it is something possible?
If it is, what kind of technology could I use? (I can use C++, C# in windows 7/Visual)
Thanks.

If you wish to add an external program then I suggest you have a look at SetParent, ShowWindow and SetWindowLong. The theory is to set your window (or a control within your window) to be the parent of another window/control.

Related

Embed a Powershell Window inside a Winforms form

Is it possible to embed a Powershell screen in my application?
I want to see the screen itself, just like Visual Studio does. I cannot use a console redirect as that option would not allow me to interact with programs or view programs displaying colors and the like.
Capture both standard input and standard output is not a possible solution. I am using programs that use colors and progress bars.
It would be something similar to being able to implement a Windows Terminal, or https://github.com/dwmkerr/consolecontrol
I also tried this code, but it does not allow me to embed to Terminal server although I can use it with Notepad Run extended programs GUI on my own c# form
Looking for information, I found a project that apparently could be what I am looking for but it does not work with Winforms and I cannot find a simple example of use. https://github.com/PowerShell/PowerShellEditorServices

Combine two applications into one icon on taskbar

I have two applications. One is the main application and the other is the updater.
A user launches with the updater - if an update is available it will download and extract, otherwise it will just launch the main application. I used two applications for this so that I am able to overwrite the main applcation.
The issue is that the users have pinned the "Launcher" application on their taskbar, but when the main application launches it is not grouped under that icon and very confusing for them.
Is there any way around this?
You should be able to do that using Windows API Code Pack.
You need to use Microsoft.WindowsAPICodePack.Taskbar namespace from the Microsoft.WindowsAPICodePack.Shell assembly.
Call TaskbarManager.Instance.SetApplicationIdForSpecificWindow( window, string appId ); method. You can specify either an IntPtr windows handle if you're using WinForms, or a Window instance if you're using WPF.
Do this step in both your processes immediately after launch, and specify the same appId for both.
you can refer [ How to group my apps in windows taskbar? ] of George's answer,
by forcefully make two process share the same APP_ID(string)
simply by calling shell32!SetCurrentProcessExplicitAppUserModelID at each process's main()
It was already mentioned to set the Application user Model ID.
But then you still have the problem that when the Application is pinned, it will not pin to the Launcher. But there is also a solution for this, that the Launcher/Updater is pinned instead of the Application: Pinning to the taskbar a "chained process"

How would I open a program inside of a windows form?

I want a program, let's say google chrome, to open inside of a windows form but not be able to be moved outside of the form or seen on the taskbar.
You can't embed arbitrary applications into yours, unless they provide an API for that. If you want to embed a browser, take a look at WebBrowser control or Awesomium project that happens to be a .Net wrapper for Chromium.
Although rather hacky, this can be done by using the SetParent ( http://msdn.microsoft.com/en-gb/library/windows/desktop/ms633541(v=vs.85).aspxwindows ) API function.
I have done this when I've needed to integrate with a buggy video libraries which would crash periodically. It was not acceptable to have the main user interface crash when the video library died so I spawned another application to show the video, and parented it to a window in the main application.
Once parented you may want to use other functions to move it around or resize it e.g. MoveWindow.
Using this method can have some side effects which you may need to manage.

C# PInvoke and QWidget

I have an application that I am trying to automate on Windows. I need to find the location of a window that is running inside the application, and then automate a couple of mouse events on the application.
In a previous incarnation of the software that I am automating, I was able to search for child windows of the process which were named using the GetWindowText WinAPI function from C# (in combination with GetWindowTextLength).
The software manufacturers have now updated the software and updated the way that the child windows are drawn. Now each window lacks a caption, and has a class name of QWidget. I can no longer use my old strategy to find the child window location. I presume the use of QWidget means the windowing system uses the Qt framework.
Is there any way of pulling any data from the QWidget using PInvoke that I might be able to identify my windows with?
There's a couple problems here. One is that you can't get "unshared" data from another process. You can get at window data by pinvoking methods like GetWindowLong; but unless you know specific data about what QWidget does in that data (the other problem), there's not much you can do with the data.
Another problem is if you want to use most QT objects in a managed application (you can do this with C++/CLI and IJW) you need to initialize A QT Application object in your application... I'm not sure how this would impact what you want to do.

open a .exe as a window in an mdi form?

I wanted to create a program that would allow me to open instances of a already exsiting program (i just have the exe) as windows inside (i belive its called mdi)
Is that something i could do? can anyone point me to an example?
Thanks
Maybe this is the answer you are looking for here. It can be done...look in the sample on that link given.
Hope this helps,
Best regards,
Tom.
When Windows starts a program its parent is the Desktop Window.
If you could somehow manipulate that, it may work.
However, I doubt it is possible, as why would I want to allow you to run my application in your window? Especially MDI? Besides that - running in a child window isn't quite the same as running in the "main" window.
Having said that there is an application out there (can't think of it's name OH) that does place individual applications in tabs. Pretty nifty if you're not on Windows 7. The folks over at the Business of Software forum might be able to help you find it.
Well, after starting the app and storing its PID, you could start monitor the windows that get created, either thru a CBTHook or by just using a timer and the GetWindows to find when a top level window gets created by the PID in question.
Then you can use SetParent to make that window a child to your MDIChild (I doubt you can make it your MDIChild directly).
That should get you going. What you'll run into after that I really don't know. I guess you must correlate any movement of either your app or the external app so that thir windows appears to be stuck together...
Maybo you could strip away the caption from the external app (Get/SetWindowsLong). That could make it look better...

Categories