Triggering events when moving a window

I am currently developing an iTunes plugin and I need my WPF plugin to keep close to the iTunes window when dragging, resizing, etc. The goal is for iTunes to stick my wpf app side by side.

I'm looking for a way to track the movement (resize, move) of another window (iTunes in my case). ITunes COM for Windows SDK offers events for maximizing and minimizing, unfortunately there are no events for resizing and moving windows.

I have tried the win32 setParent function without any success. I don't think this is a suitable solution for my problem. I searched the internet thoroughly for information but found nothing.

+3


source to share


1 answer


I think the WINDOWPOS framework is what you are looking for. Other window structures may come in handy.

Some google searches another example that doesn't use WINDOWPOS:



1, call the FindWindow () API to retrieve the window handle (Uuse SPY ++ to get the two parameters ClassName and WindowName);

2, Invoke API GetWindowRect () to get the size and position of the specified window.

Snippet of code

    [DllImport("user32.dll")]
    private static extern IntPtr FindWindow(string className, string windowName);

    [DllImport("user32.dll")]
    private static extern int GetWindowRect(IntPtr hwnd, out Rectangle rect);

    private void button2_Click(object sender, EventArgs e)
    {
        string className = "yourClassName";
        string windowName = "yourWindowName";

        Rectangle rect;
        IntPtr hwnd = FindWindow(className, windowName);
        GetWindowRect(hwnd, out rect);
    }

      

+2


source







All Articles