Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Function] WinGetClientPos()


  • Please log in to reply
No replies to this topic
dustind900
  • Members
  • 43 posts
  • Last active: Nov 03 2017 01:11 PM
  • Joined: 09 Dec 2012

Working example and Function

Gui New, +HwndhGUI +LabelGui_ +Resize
Gui %hGUI%:Show, w500 h500
MsgBox The Gui client area will now be covered with a new black gui
Gui New, +HwndhGUI2 -Caption +ToolWindow +AlwaysOnTop
Gui %hGUI2%:Color, 000000
Client := WinGetClientPos( hGUI )
Gui %hGUI2%:Show, % "x" Client.X " y" Client.Y " w" Client.W " h" Client.H
OnMessage( 0x03, "GuiChanged" )
OnMessage( 0x05, "GuiChanged" )
return

Gui_Close:
	ExitApp

WinGetClientPos( Hwnd ) {
	VarSetCapacity( size, 16, 0 )
	DllCall( "GetClientRect", UInt, Hwnd, Ptr, &size )
	DllCall( "ClientToScreen", UInt, Hwnd, Ptr, &size )
	x := NumGet(size, 0, "Int")
	y := NumGet(size, 4, "Int")
	w := NumGet( size, 8, "Int" )
	h := NumGet( size, 12, "Int" )
	return { X: x, Y: y, W: w, H: h }
}

GuiChanged() {
	global hGUI,hGUI2
	Client := WinGetClientPos( hGUI )
	Gui %hGUI2%:Show, % "x" Client.X " y" Client.Y " w" Client.W " h" Client.H
}

I've seen other functions like this, but none ( that I found ) gave both the position and size.I was aiming for functionality similar to WinGetPos.