Embed Thumbnail Image of Another .exe into Form as preview
Im looking to embe开发者_开发技巧d an .exe into my form. An example of what I want to do is the preview area when selecting a screensaver in Windows. It shows a small running preview of the app in the current window. How do I do that in my VB form?
Well, that's not so easy. Screen savers are explicitly designed to support a preview. They are not EXEs, they are DLLs. They run in-process and export 3 functions that Windows calls to get them to do what screen savers normally do.
Getting a preview of an EXE window is a completely different problem, much harder to solve. It is somewhat possible by pinvoking the SetParent() API function, making your window the parent of the EXE window. For that, you must have the handle of the EXE window, that can be hard to obtain. Your best bet without a lot of nasty pinvoke is Process.MainWindowHandle. Getting a thumbnail view of it is also unlikely to work out well, the EXE controls the painting of the window. You can make the window smaller by pinvoking MoveWindow, what you get is unpredictable but unlikely to resemble a thumbnail. Try resizing the Visual Studio window to a thumbnail size for example.
If you want to try this anyway, visit pinvoke.net to get the required declarations. If this is a 'getting started' kind of project then do consider trying to tackle something less likely to be disappointing.
精彩评论