views:

41

answers:

1

Hello,

I want to develop Windows program who can stick into other window.

I searching fastest-way to do this. I can get by WinAPI all information about target window and move my window into good location and after it Sniffing Windows Messages of target window to searching resize or move window and after this doing move my window again. But i don't know what is a simplest good working way (maybe somewhat on .NET? But i don't preffer answers in .NET i like free framework's).

I want to stick on the top, bottom, left, right of the target window, but this maybe never mind.

Can anyone help me something with this problem? Thanks.

A: 

You basically need to do two things:

  1. Get a list of all windows to which your app is supposed to stick, and their locations/dimensions.
  2. Listen to your application's main window's move event and if at any point your window gets close enough to any of the relevant windows from #1 you move it yourself so that they align.

You can do both in Win32 API or with .Net. You just need a good criterion for #1. Like, for example, all top level visible windows that are within the desktop's boundaries.

Might want to include the desktop itself in the list above, so that your app sticks to the edges of the desktop as well.

Assaf Lavie
I have #1 already developed in WinAPI in full version ;-) But i asking about align function. I can do this with WinAPI? I must write this from base form? I can't find about this on MSDN infromation.
Svisstack
You need to catch WM_WINDOWPOSCHANGING message, and modify WINDOWPOS structure (it resides in lParam).
southerton
No, there's no alignment functionality in the API AFAIK. You have to do it yourself (or find existing code).
Assaf Lavie