Hi All,
I'm starting to get a headache. This is a port from wine to win32k/ntuser/winpos.c.
It does compile. But it is so butt ugly! I'm in the process of fixing MDI. So far,
testing with winefile.exe has come down to this one function. So this is open for
peer review. I'm tired. 8^(
Thanks,
James
BOOL
FASTCALL
IntIsIconic(HWND hWnd)
{
return (NtUserGetWindowLong( hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE) != 0;
}
BOOL
FASTCALL
IntIsWindowEnabled(
HWND hWnd)
{
return (! (NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_DISABLED));
}
#define MAKEINTATOMW(atom) ((LPCWSTR)((ULONG_PTR)((WORD)(atom))))
#define ICONTITLE_CLASS_ATOM MAKEINTATOMW(32772)
static ATOM atomInternalPos;
extern HWND FASTCALL IntSetOwner(HWND hWnd, HWND hWndNewOwner);
extern HWND STDCALL
IntCreateWindowEx(DWORD dwExStyle,
PUNICODE_STRING ClassName,
PUNICODE_STRING WindowName,
DWORD dwStyle,
LONG x,
LONG y,
LONG nWidth,
LONG nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam,
DWORD dwShowMode,
BOOL bUnicodeWindow);
HWND
FASTCALL
ICONTITLE_Create( HWND owner )
{
HWND hWnd;
UNICODE_STRING ClassName;
HINSTANCE instance = (HINSTANCE)NtUserGetWindowLong( owner, GWL_HINSTANCE, FALSE );
LONG style = WS_CLIPSIBLINGS;
RtlInitUnicodeString(&ClassName, NULL);
ClassName.Buffer = (LPWSTR)ICONTITLE_CLASS_ATOM;
if (!IntIsWindowEnabled(owner)) style |= WS_DISABLED;
if( NtUserGetWindowLong( owner, GWL_STYLE,FALSE ) & WS_CHILD )
hWnd = IntCreateWindowEx( 0, &ClassName, NULL,
style | WS_CHILD, 0, 0, 1, 1,
NtUserGetParent(owner), 0, instance, NULL,SW_SHOW,TRUE
);
else
hWnd = IntCreateWindowEx( 0, &ClassName, NULL, style, 0, 0, 1, 1,
owner, 0, instance, NULL,SW_SHOW,TRUE );
IntSetOwner( hWnd, owner ); /* MDI depends on this */
NtUserSetWindowLong( hWnd, GWL_STYLE,
NtUserGetWindowLong( hWnd, GWL_STYLE,FALSE ) & ~(WS_CAPTION |
WS_BORDER), FALSE );
return hWnd;
}
BOOL
FASTCALL
WinPosShowIconTitle(HWND hWnd, BOOL bShow)
{
PWINDOW_OBJECT WindowObject;
PINTERNALPOS lpPos;
/* This way or??? */
lpPos = (PINTERNALPOS)NtUserGetProp( hWnd, atomInternalPos );
if (!(WindowObject = IntGetWindowObject(hWnd)))
{
return FALSE;
}
/* This way? Dont know! */
lpPos = WindowObject->InternalPos;
if (lpPos )
{
HWND title = 0;//lpPos->hwndIconTitle;
if( !title )
// lpPos->hwndIconTitle =
title = ICONTITLE_Create( hWnd );
if( bShow )
{
if (!IntIsWindowVisible(title))
{
IntSendMessage( title, WM_SHOWWINDOW, TRUE, 0 );
WinPosSetWindowPos( title, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
}
}
else WinPosShowWindow( title, SW_HIDE );
}
IntReleaseWindowObject(WindowObject);
return TRUE;
}
UINT
FASTCALL
WinPosArrangeIconicWindows(PWINDOW_OBJECT parent)
{
RECT rectParent;
HWND hwndChild;
INT i, x, y, xspacing, yspacing;
HWND *List = IntWinListChildren(parent);
IntGetClientRect( parent, &rectParent );
x = rectParent.left;
y = rectParent.bottom;
xspacing = NtUserGetSystemMetrics(SM_CXICONSPACING);
yspacing = NtUserGetSystemMetrics(SM_CYICONSPACING);
for( i = 0; List[i]; i++)
{
hwndChild = List[i];
if( IntIsIconic( hwndChild ) )
{
WinPosShowIconTitle( hwndChild, FALSE );
WinPosSetWindowPos( hwndChild, 0, x + (xspacing -
NtUserGetSystemMetrics(SM_CXICON)) / 2,
y - yspacing - NtUserGetSystemMetrics(SM_CYICON)/2, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
if( IntIsWindow(hwndChild) )
WinPosShowIconTitle(hwndChild , TRUE );
if (x <= rectParent.right - xspacing) x += xspacing;
else
{
x = rectParent.left;
y -= yspacing;
}
}
}
ExFreePool(List);
return yspacing;
}