﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2786	MDI childs don't adjust to parent windows client rect #2	Synix <cross.fire@…>		"#1013 was about child windows of parent GUIs with $WS_CAPTION style. This is fixed and works fine.

If the parent GUI has the style $WS_POPUP and no caption, the offset of the MDI child window differs with the different border styles and can not be properly aligned on top of the parent GUI. This is a major problem if you e.g. want to work with layered child windows.

I have an example code to show this, with a potential workaround, that at least does work for my Win7 and Win8 machine:

{{{
#include <GUIConstants.au3>
Global $aSM_CYBORDER = DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CYBORDER)
Global $aSM_CYEDGE = DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CYEDGE) ;3-D counterpart of SM_CYBORDER
Global $aSM_CYDLGFRAME = DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CYDLGFRAME) ;same as SM_CYFIXEDFRAME
Global $aSM_CYFRAME = DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CYFRAME) ;same as SM_CYSIZEFRAME
;~ Exit MsgBox(0, """", $aSM_CYBORDER[0] & "" - "" & $aSM_CYEDGE[0] & "" - "" & $aSM_CYDLGFRAME[0] & "" - "" & $aSM_CYFRAME[0])

For $i = 1 To 2
	$bOffsetFix = ($i = 1 ? False : True)
	MsgBox(0, ""Offset Fix"", $bOffsetFix)
	;$WS_DLGFRAME + $WS_BORDER = $WS_CAPTION
	;$WS_CAPTION always works fine with offset=0
	_GUIs($bOffsetFix, 0)
	_GUIs($bOffsetFix, $WS_DLGFRAME) ;works fine with offset=0
	_GUIs($bOffsetFix, $WS_BORDER)
	_GUIs($bOffsetFix, $WS_THICKFRAME)
	_GUIs($bOffsetFix, BitOR($WS_THICKFRAME, $WS_DLGFRAME))
	_GUIs($bOffsetFix, BitOR($WS_THICKFRAME, $WS_BORDER))
Next

Func _GUIs($bOffsetFix, $iBorder)
	Local $iW = 220, $iH = 220, $iOffset = ($bOffsetFix ? _OffsetFix($iBorder) : 0)

	$hGUI = GUICreate('MDI Example', $iW, $iH, -1, -1, BitOR($WS_POPUP, $iBorder))
	GUISetBkColor(0x000000)
	$hChild = GUICreate('', $iW, $iH,  $iOffset, $iOffset, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
	GUISetBkColor(0xdddddd)
	GUICtrlCreateLabel('Child GUI offset:  ' & ($iOffset >= 0 ? '+' : '') & $iOffset & ' px' & @CRLF & _
				'Main GUI style:' & @TAB & '   $WS_POPUP             ' & _
				(_StyleInStyle($iBorder, $WS_CAPTION) ?  @CRLF & @TAB & @TAB & ' +$WS_CAPTION' : '') & _
				(_StyleInStyle($iBorder, $WS_BORDER) ? @CRLF & @TAB & @TAB & ' +$WS_BORDER' : '') & _
				(_StyleInStyle($iBorder, $WS_THICKFRAME) ? @CRLF & @TAB & @TAB & ' +$WS_THICKFRAME' : '') & _
				(_StyleInStyle($iBorder, $WS_DLGFRAME) ? @CRLF & @TAB & @TAB & ' +$WS_DLGFRAME' : '') & _
				@CRLF & @CRLF & 'Press [Esc]', 10, 10)
	GUISetState(@SW_SHOW, $hGUI)
	GUISetState(@SW_SHOW, $hChild)
	While GUIGetMsg() <> -3
	WEnd
	GUIDelete($hChild)
	GUIDelete($hGUI)
EndFunc

Func _OffsetFix($iBorder)
	Local $iRet = 0
	If Not _StyleInStyle($iBorder, $WS_CAPTION) Then
		If Not _StyleInStyle($iBorder, $WS_DLGFRAME) Then $iRet += $aSM_CYDLGFRAME[0] ;+3
		If _StyleInStyle($iBorder, $WS_BORDER) Then $iRet -= $aSM_CYBORDER[0] ;-1
		If _StyleInStyle($iBorder, $WS_THICKFRAME) Then
			$iRet -= $aSM_CYFRAME[0] ;-8
			If _StyleInStyle($iBorder, $WS_DLGFRAME) Then
				$iRet += $aSM_CYDLGFRAME[0] ;+3
			Else
				$iRet += $aSM_CYBORDER[0] ;+1
			EndIf
		EndIf
	EndIf
	Return $iRet
EndFunc

Func _StyleInStyle($iSrc, $iSearch)
	Return BitAND($iSrc, $iSearch) = $iSearch
EndFunc
}}}

In #1866 someone reported this issue and it got rejected. Though it wasn't a great example with all the different border styles demonstrated. So I follow the comment of trancexx from that ticket: ""If anyone sees any sense in this then please make another report.""
Please try to fix this internally, so an MDI child always aligns correctly with its parent.

Thanks in advance :)"	Bug	closed		AutoIt	3.3.8.1	None	Wont Fix	$WS_EX_MDICHILD, $WS_POPUP	
