How can I discover a maximised window's restored position co-ordinates?
As the title suggests, I'm trying to discover where a maximised parent window will be re-drawn when the user Restores it from a maximised state. Now, I can currently do this by using the winRestore command, capture the position and then winMaximise again, but this causes the window to a) flash as it is drawn twice and b) takes too long for a process that I want to be instant to the user (I use the Restored position later when moving the window to another screen).
I'm fairly sure I'm on the right path with the GetWindowsPlac开发者_开发百科ement Windows API method, but I'm willing to admit that figuring out how to get the info I need is a step beyond my current dllCalling coding abilities and Google searches aren't turning up anything.
In a nutshell: what I want to be able to do is get and set (into the Windows window management system) the top-left co-ordinate of any window's Restored position without actually redrawing and moving the maximised window.
Does anyone have a direction or pointer I can follow? Thanks!
User Lexikos shows how to do it with a DLL call to GetWindowPlacement:
http://www.autohotkey.com/forum/post-172836.html#172836
hwnd := WinExist("Untitled - Notepad")
WinGetPos, mX, mY
WinGetNormalPos(hwnd, x, y, w, h)
MsgBox Pos:`nx: %mX%`ny: %mY%`n`nNormalPos:`nx: %x%`ny: %y%`nw: %w%`nh: %h%
WinGetNormalPos(hwnd, ByRef x, ByRef y, ByRef w="", ByRef h="")
{
VarSetCapacity(wp, 44), NumPut(44, wp)
DllCall("GetWindowPlacement", "uint", hwnd, "uint", &wp)
x := NumGet(wp, 28, "int")
y := NumGet(wp, 32, "int")
w := NumGet(wp, 36, "int") - x
h := NumGet(wp, 40, "int") - y
}
精彩评论