0

I'm interested in begin able to manipulate windows programmatically. Perhaps by clicking on a window so it has focus, then by using some key combination, I can move the windows. Also, I'd like to move the windows in the z-direction, which would mean that it would appear to get smaller as it went deeper into the screen and bigger as it was moved toward me.

I would like this to apply to any existing window, being a text editor window, a browser window, or even the calculator program window.

The problem is that I have no idea what technology would be needed to accomplish that.

Any ideas?

fuzzlog
  • 131
  • 3
  • 18

1 Answers1

2

You'd need to use the Win32 API (using P/Invoke).

"Manipulating" a window would need several different API functions depending on what you want to do... these are a few:

  • FindWindow (pinvoke.net link) will allow you to find the window handle so you feed it into the other functions (there are more ways to find a window handle depending on your needs, but this one is by far the easiest)
  • MoveWindow(pinvoke.net link) allows you to set position and size
  • SetWindowPos (pinvoke.net link) to set the z-order of top-level windows

etc.

Use http://pinvoke.net to find out how to call Win32 API functions from c#, and use the MSDN (this link: http://msdn.microsoft.com/en-us/library/windows/desktop/ff468919(v=vs.85).aspx in particular) for a reference of all functions to handle Windows.

Update

Rereading your question it looks like you want to "simulate" a 3D-like effect in your windows. This is not in the API and there's no standarized way to do it as far as I know (the modern accelerated DWM does it, but I don't think you can access any functions to do that via its API).

You could research into capturing the window contents to a bitmap, and render that bitmap scaled into your own window. It's not impossible, but it's not precisely easy and would be WAY too long to explain how to do this here.

Update 2

There's actually a DWM API (link to MSDN), but even with it, I doubt you can do what you want in a practical manner with it

Jcl
  • 27,696
  • 5
  • 61
  • 92
  • So, setting he z-order is one thing, but what about moving the window "deeper" into the screen and making it look smaller as a result (or "shallower" up to the screen and making the window look bigger? – fuzzlog Jan 16 '15 at 07:48
  • @fuzzlog I don't think you can do that with the standard API (you could change the window size, but it wouldn't scale the contents). The best option would be capturing the window contents and draw your own window with the scaled image of the content inside. I'll edit my question – Jcl Jan 16 '15 at 07:49
  • Holding the "Window key" + TAB gives us that window scrolling effect. Do you know what that is called? also, if a window has a video, you can see the video playing as is being scrolled. Do you know if that has an available API? – fuzzlog Jan 16 '15 at 07:56
  • @fuzzlog yes, that's the DWM (look my "Update 2"), but I don't think you can achieve that effect using the DWM API. What the DWM does is generate a thumbnail for each window (capturing its content) and draw the effect for you (using a Direct3D window). You can use the DWM API to generate or read the window thumbnails, but it won't have functions to draw the 3D windows. That's Direct3D – Jcl Jan 16 '15 at 07:59
  • Check this link: http://msdn.microsoft.com/en-us/library/windows/desktop/aa969540(v=vs.85).aspx and read about what the DWM does – Jcl Jan 16 '15 at 08:01
  • That's close enough for me. I've accepted this as the answer since it has tons related info I can begin digging into. Thanks. – fuzzlog Jan 16 '15 at 08:02