Kenny Lim
Kenny Lim

Reputation: 1214

Windows - knowing an external Window movement

I need to create a Window that will follow an external program (ie. Notepad.exe). When user move Notepad.exe to a new position in the Desktop, I want my Window to move also.

I did some research :-

  1. Using SetParent (where parent is Notepad)- I got this render initially, moving Notepad will not render my Window.

  2. Using SetWindowPos and SetWindowHook on Notepad.

  3. Using SetWindowSubClass. This doesn't work, getting error code. Possibly Notepad is a different process.

I am thinking no.2 is the path I want to go deeper. Do you think this is the right path? Is this overkilling?

Upvotes: 0

Views: 191

Answers (2)

Benilda Key
Benilda Key

Reputation: 3102

See the SetWinEventHook function.

Also see the SetWindowsHookEx function, specifically the WH_GETMESSAGE hook may be of use.

Upvotes: 2

GlGuru
GlGuru

Reputation: 774

You can possibly use Windows Hooks to monitor Window movements and Mouse Input. Perhaps that can be an alternative?

http://msdn.microsoft.com/en-gb/library/windows/desktop/ms644960(v=vs.85).aspx

Upvotes: 1

Related Questions