-/* $Id: defwnd.c,v 1.73 2003/08/20 21:42:27 gvg Exp $
+/* $Id: defwnd.c,v 1.74 2003/08/29 09:29:11 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
BOOL
IsMaxBoxActive(HWND hWnd)
{
- ULONG uStyle = GetWindowLongW( hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW(hWnd, GWL_STYLE);
return (uStyle & WS_MAXIMIZEBOX);
}
BOOL
-IsCloseBoxActive( HWND hWnd )
+IsCloseBoxActive(HWND hWnd)
{
- ULONG uStyle = GetWindowLongW(hWnd, GWL_STYLE );
- return ( uStyle & WS_SYSMENU );
+ ULONG uStyle = GetWindowLongW(hWnd, GWL_STYLE);
+ return (uStyle & WS_SYSMENU);
}
BOOL
-IsMinBoxActive( HWND hWnd )
+IsMinBoxActive(HWND hWnd)
{
- ULONG uStyle = GetWindowLongW( hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW(hWnd, GWL_STYLE);
return (uStyle & WS_MINIMIZEBOX);
}
INT
-UIGetFrameSizeX( HWND hWnd )
+UIGetFrameSizeX(HWND hWnd)
{
- ULONG uStyle = GetWindowLongW( hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW(hWnd, GWL_STYLE);
if ( uStyle & WS_THICKFRAME )
- return GetSystemMetrics( SM_CXSIZEFRAME );
+ return GetSystemMetrics(SM_CXSIZEFRAME);
else
- return GetSystemMetrics( SM_CXFRAME );
+ return GetSystemMetrics(SM_CXFRAME);
}
INT
-UIGetFrameSizeY( HWND hWnd )
+UIGetFrameSizeY(HWND hWnd)
{
- ULONG uStyle = GetWindowLongW( hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW(hWnd, GWL_STYLE);
- if ( uStyle & WS_THICKFRAME )
- return GetSystemMetrics( SM_CYSIZEFRAME );
+ if (uStyle & WS_THICKFRAME)
+ return GetSystemMetrics(SM_CYSIZEFRAME);
else
- return GetSystemMetrics( SM_CYFRAME );
+ return GetSystemMetrics(SM_CYFRAME);
}
VOID
-UserSetupInternalPos( VOID )
+UserSetupInternalPos(VOID)
{
- LPSTR Str = "SysIP";
- AtomInternalPos = GlobalAddAtomA(Str);
+ LPSTR Str = "SysIP";
+ AtomInternalPos = GlobalAddAtomA(Str);
}
-
/*
* @implemented
*/
DWORD STDCALL
GetSysColor(int nIndex)
{
- return SysColours[nIndex];
+ return SysColours[nIndex];
}
-
+/*
+ * @implemented
+ */
HPEN STDCALL
-GetSysColorPen( int nIndex )
+GetSysColorPen(int nIndex)
{
- return(CreatePen(PS_SOLID, 1, SysColours[nIndex]));
+ return CreatePen(PS_SOLID, 1, SysColours[nIndex]);
}
-
/*
* @implemented
*/
HBRUSH STDCALL
-GetSysColorBrush( int nIndex )
+GetSysColorBrush(int nIndex)
{
- return(CreateSolidBrush(SysColours[nIndex]));
+ return CreateSolidBrush(SysColours[nIndex]);
}
-
/*
* @unimplemented
*/
WPARAM wParam,
LPARAM lParam )
{
- UNIMPLEMENTED;
- return((LRESULT)0);
+ UNIMPLEMENTED;
+ return ((LRESULT)0);
}
/*
WPARAM wParam,
LPARAM lParam)
{
- UNIMPLEMENTED;
- return((LRESULT)0);
+ UNIMPLEMENTED;
+ return ((LRESULT)0);
}
PINTERNALPOS
UserGetInternalPos(HWND hWnd)
{
- PINTERNALPOS lpPos;
- lpPos = (PINTERNALPOS)GetPropA(hWnd, (LPSTR)(DWORD)AtomInternalPos);
- return(lpPos);
+ PINTERNALPOS lpPos;
+ lpPos = (PINTERNALPOS)GetPropA(hWnd, (LPSTR)(DWORD)AtomInternalPos);
+ return(lpPos);
}
BOOL
DefWndRedrawIconTitle(HWND hWnd)
{
- PINTERNALPOS lpPos = (PINTERNALPOS)GetPropA(hWnd,
- (LPSTR)(DWORD)AtomInternalPos);
- if (lpPos != NULL)
+ PINTERNALPOS lpPos = (PINTERNALPOS)GetPropA(hWnd, (LPSTR)(DWORD)AtomInternalPos);
+
+ if (lpPos != NULL)
{
- if (lpPos->IconTitle != NULL)
- {
- SendMessageA(lpPos->IconTitle, WM_SHOWWINDOW, TRUE, 0);
- InvalidateRect(lpPos->IconTitle, NULL, TRUE);
- return(TRUE);
- }
+ if (lpPos->IconTitle != NULL)
+ {
+ SendMessageA(lpPos->IconTitle, WM_SHOWWINDOW, TRUE, 0);
+ InvalidateRect(lpPos->IconTitle, NULL, TRUE);
+ return(TRUE);
+ }
}
- return(FALSE);
+ return(FALSE);
}
-
BOOL
UserHasMenu(HWND hWnd, ULONG Style)
{
- return(!(Style & WS_CHILD) && GetMenu(hWnd) != 0);
+ return (!(Style & WS_CHILD) && GetMenu(hWnd) != 0);
}
-
ULONG
UserHasAnyFrameStyle(ULONG Style, ULONG ExStyle)
{
- return((Style & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) ||
- (ExStyle & WS_EX_DLGMODALFRAME) ||
- (!(Style & (WS_CHILD | WS_POPUP))));
+ return ((Style & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) ||
+ (ExStyle & WS_EX_DLGMODALFRAME) ||
+ (!(Style & (WS_CHILD | WS_POPUP))));
}
-
ULONG
UserHasDlgFrameStyle(ULONG Style, ULONG ExStyle)
{
- return((ExStyle & WS_EX_DLGMODALFRAME) ||
- ((Style & WS_DLGFRAME) && (!(Style & WS_THICKFRAME))));
+ return ((ExStyle & WS_EX_DLGMODALFRAME) ||
+ ((Style & WS_DLGFRAME) && (!(Style & WS_THICKFRAME))));
}
-
ULONG
UserHasThickFrameStyle(ULONG Style, ULONG ExStyle)
{
- return((Style & WS_THICKFRAME) &&
- (!((Style & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)));
+ return ((Style & WS_THICKFRAME) &&
+ (!((Style & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)));
}
-
ULONG
UserHasThinFrameStyle(ULONG Style, ULONG ExStyle)
{
- return((Style & WS_BORDER) ||
- (!(Style & (WS_CHILD | WS_POPUP))));
+ return ((Style & WS_BORDER) || (!(Style & (WS_CHILD | WS_POPUP))));
}
-
ULONG
UserHasBigFrameStyle(ULONG Style, ULONG ExStyle)
{
- return((Style & (WS_THICKFRAME | WS_DLGFRAME)) ||
- (ExStyle & WS_EX_DLGMODALFRAME));
+ return ((Style & (WS_THICKFRAME | WS_DLGFRAME)) ||
+ (ExStyle & WS_EX_DLGMODALFRAME));
}
void
-UserGetInsideRectNC( HWND hWnd, RECT *rect )
+UserGetInsideRectNC(HWND hWnd, RECT *rect)
{
- RECT WindowRect;
- ULONG Style;
- ULONG ExStyle;
-
- Style = GetWindowLongW(hWnd, GWL_STYLE);
- ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
- GetWindowRect(hWnd, &WindowRect);
- rect->top = rect->left = 0;
- rect->right = WindowRect.right - WindowRect.left;
- rect->bottom = WindowRect.bottom - WindowRect.top;
-
- if (Style & WS_ICONIC)
+ RECT WindowRect;
+ ULONG Style;
+ ULONG ExStyle;
+
+ Style = GetWindowLongW(hWnd, GWL_STYLE);
+ ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
+ GetWindowRect(hWnd, &WindowRect);
+ rect->top = rect->left = 0;
+ rect->right = WindowRect.right - WindowRect.left;
+ rect->bottom = WindowRect.bottom - WindowRect.top;
+
+ if (Style & WS_ICONIC)
{
- return;
+ return;
}
- /* Remove frame from rectangle */
- if (UserHasThickFrameStyle(Style, ExStyle ))
- {
- InflateRect( rect, -GetSystemMetrics(SM_CXFRAME),
- -GetSystemMetrics(SM_CYFRAME) );
- }
+ /* Remove frame from rectangle */
+ if (UserHasThickFrameStyle(Style, ExStyle ))
+ {
+ InflateRect(rect, -GetSystemMetrics(SM_CXFRAME),
+ -GetSystemMetrics(SM_CYFRAME));
+ }
else
- {
- if (UserHasDlgFrameStyle(Style, ExStyle ))
- {
- InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME),
- -GetSystemMetrics(SM_CYDLGFRAME));
- /* FIXME: this isn't in NC_AdjustRect? why not? */
- if (ExStyle & WS_EX_DLGMODALFRAME)
- InflateRect( rect, -1, 0 );
- }
- else
- {
- if (UserHasThinFrameStyle(Style, ExStyle))
- {
- InflateRect(rect, -GetSystemMetrics(SM_CXBORDER),
- -GetSystemMetrics(SM_CYBORDER));
- }
- }
- }
+ {
+ if (UserHasDlgFrameStyle(Style, ExStyle ))
+ {
+ InflateRect(rect, -GetSystemMetrics(SM_CXDLGFRAME),
+ -GetSystemMetrics(SM_CYDLGFRAME));
+ /* FIXME: this isn't in NC_AdjustRect? why not? */
+ if (ExStyle & WS_EX_DLGMODALFRAME)
+ InflateRect( rect, -1, 0 );
+ }
+ else
+ {
+ if (UserHasThinFrameStyle(Style, ExStyle))
+ {
+ InflateRect(rect, -GetSystemMetrics(SM_CXBORDER),
+ -GetSystemMetrics(SM_CYBORDER));
+ }
+ }
+ }
}
WINBOOL
-UserDrawSysMenuButton( HWND hWnd, HDC hDC, LPRECT Rect, BOOL down )
+UserDrawSysMenuButton(HWND hWnd, HDC hDC, LPRECT Rect, BOOL down)
{
HDC hDcMem;
HBITMAP hSavedBitmap;
- WINBOOL result = FALSE;
- hbSysMenu = (HBITMAP)LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE));
+ if (!hbSysMenu)
+ {
+ hbSysMenu = (HBITMAP)LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE));
+ }
hDcMem = CreateCompatibleDC(hDC);
- if (! hDcMem) goto cleanup;
+ if (!hDcMem)
+ {
+ return FALSE;
+ }
hSavedBitmap = SelectObject(hDcMem, hbSysMenu);
- if (! hSavedBitmap) goto cleanup;
-
- BitBlt(hDC, Rect->left + 2, Rect->top +
- 2, 16, 16, hDcMem,
- (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ?
- GetSystemMetrics(SM_CXSIZE): 0, 0, SRCCOPY);
-
- result = TRUE;
+ if (!hSavedBitmap)
+ {
+ DeleteDC(hDcMem);
+ return FALSE;
+ }
- cleanup:
- if (hDcMem)
- {
- if(hSavedBitmap) SelectObject(hDcMem, hSavedBitmap);
- DeleteDC(hDcMem);
- }
- return result;
- }
+ BitBlt(hDC, Rect->left + 2, Rect->top + 2, 16, 16, hDcMem,
+ (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ?
+ GetSystemMetrics(SM_CXSIZE): 0, 0, SRCCOPY);
-/* FIXME: Cache bitmaps, then just bitblt instead of calling DFC() (and
- wasting precious CPU cycles) every time */
+ SelectObject(hDcMem, hSavedBitmap);
+ DeleteDC(hDcMem);
+ return TRUE;
+}
+/*
+ * FIXME:
+ * Cache bitmaps, then just bitblt instead of calling DFC() (and
+ * wasting precious CPU cycles) every time
+ */
static void
-UserDrawCaptionButton( HWND hWnd, HDC hDC, BOOL bDown, ULONG Type )
+UserDrawCaptionButton(HWND hWnd, HDC hDC, BOOL bDown, ULONG Type)
{
- RECT rect;
- INT iBmpWidth = GetSystemMetrics(SM_CXSIZE) - 2;
- INT iBmpHeight = GetSystemMetrics(SM_CYSIZE) - 4;
-
- INT OffsetX = UIGetFrameSizeX( hWnd );
- INT OffsetY = UIGetFrameSizeY( hWnd );
+ RECT rect;
+ INT iBmpWidth = GetSystemMetrics(SM_CXSIZE) - 2;
+ INT iBmpHeight = GetSystemMetrics(SM_CYSIZE) - 4;
+ INT OffsetX = UIGetFrameSizeX(hWnd);
+ INT OffsetY = UIGetFrameSizeY(hWnd);
- if(!(GetWindowLongW( hWnd, GWL_STYLE ) & WS_SYSMENU))
- {
- return;
- }
+ if (!(GetWindowLongW(hWnd, GWL_STYLE) & WS_SYSMENU))
+ {
+ return;
+ }
- GetWindowRect( hWnd, &rect );
+ GetWindowRect(hWnd, &rect);
- rect.right = rect.right - rect.left;
- rect.bottom = rect.bottom - rect.top;
- rect.left = rect.top = 0;
+ rect.right = rect.right - rect.left;
+ rect.bottom = rect.bottom - rect.top;
+ rect.left = rect.top = 0;
- switch(Type)
- {
- case DFCS_CAPTIONMIN:
- {
- if ((GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW) == TRUE)
- return; /* ToolWindows don't have min/max buttons */
-
- SetRect(&rect,
- rect.right - OffsetX - (iBmpWidth*3) - 5,
- OffsetY + 2,
- rect.right - (iBmpWidth * 2) - OffsetX - 5,
- rect.top + iBmpHeight + OffsetY + 2 );
- DrawFrameControl( hDC, &rect, DFC_CAPTION,
- DFCS_CAPTIONMIN | (bDown ? DFCS_PUSHED : 0) |
- (IsMinBoxActive(hWnd) ? 0 : DFCS_INACTIVE) );
- break;
- }
- case DFCS_CAPTIONMAX:
- {
- if ((GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW) == TRUE)
- return; /* ToolWindows don't have min/max buttons */
- SetRect(&rect,
- rect.right - OffsetX - (iBmpWidth*2) - 5,
- OffsetY + 2,
- rect.right - iBmpWidth - OffsetX - 5,
- rect.top + iBmpHeight + OffsetY + 2 );
-
- DrawFrameControl( hDC, &rect, DFC_CAPTION,
- (IsZoomed(hWnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX) |
- (bDown ? DFCS_PUSHED : 0) |
- (IsMaxBoxActive(hWnd) ? 0 : DFCS_INACTIVE) );
- break;
- }
- case DFCS_CAPTIONCLOSE:
- {
- SetRect(&rect,
- rect.right - OffsetX - iBmpWidth - 3,
- OffsetY + 2,
- rect.right - OffsetX - 3,
- rect.top + iBmpHeight + OffsetY + 2 );
-
- DrawFrameControl( hDC, &rect, DFC_CAPTION,
- (DFCS_CAPTIONCLOSE |
- (bDown ? DFCS_PUSHED : 0) |
- (IsCloseBoxActive(hWnd) ? 0 : DFCS_INACTIVE)) );
+ switch(Type)
+ {
+ case DFCS_CAPTIONMIN:
+ {
+ if ((GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW) == TRUE)
+ return; /* ToolWindows don't have min/max buttons */
+
+ SetRect(&rect, rect.right - OffsetX - (iBmpWidth * 3) - 5,
+ OffsetY + 2, rect.right - (iBmpWidth * 2) - OffsetX - 5,
+ rect.top + iBmpHeight + OffsetY + 2);
+ DrawFrameControl(hDC, &rect, DFC_CAPTION,
+ DFCS_CAPTIONMIN | (bDown ? DFCS_PUSHED : 0) |
+ (IsMinBoxActive(hWnd) ? 0 : DFCS_INACTIVE));
+ break;
+ }
+ case DFCS_CAPTIONMAX:
+ {
+ if ((GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW) == TRUE)
+ return; /* ToolWindows don't have min/max buttons */
+
+ SetRect(&rect, rect.right - OffsetX - (iBmpWidth * 2) - 5,
+ OffsetY + 2, rect.right - iBmpWidth - OffsetX - 5,
+ rect.top + iBmpHeight + OffsetY + 2);
+ DrawFrameControl(hDC, &rect, DFC_CAPTION,
+ (IsZoomed(hWnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX) |
+ (bDown ? DFCS_PUSHED : 0) |
+ (IsMaxBoxActive(hWnd) ? 0 : DFCS_INACTIVE));
+ break;
+ }
+ case DFCS_CAPTIONCLOSE:
+ {
+ SetRect(&rect, rect.right - OffsetX - iBmpWidth - 3,
+ OffsetY + 2, rect.right - OffsetX - 3,
+ rect.top + iBmpHeight + OffsetY + 2 );
+ DrawFrameControl(hDC, &rect, DFC_CAPTION,
+ (DFCS_CAPTIONCLOSE | (bDown ? DFCS_PUSHED : 0) |
+ (IsCloseBoxActive(hWnd) ? 0 : DFCS_INACTIVE)));
+ break;
+ }
}
- }
}
-
// Enabling this will cause captions to draw smoother, but slower:
// #define DOUBLE_BUFFER_CAPTION
// NOTE: Double buffering appears to be broken for this at the moment
/*
* @implemented
*/
-WINBOOL
-STDCALL
+WINBOOL STDCALL
DrawCaption(
HWND hWnd,
HDC hDC,
RECT r = *lprc;
UINT VCenter = 0, Padding = 0;
WCHAR buffer[256];
- HFONT hFont = NULL,
- hOldFont = NULL;
- HBRUSH OldBrush = NULL;
- HDC MemDC = NULL;
+ HFONT hFont = NULL;
+ HFONT hOldFont = NULL;
+ HBRUSH OldBrush = NULL;
+ HDC MemDC = NULL;
#ifdef DOUBLE_BUFFER_CAPTION
- HBITMAP MemBMP = NULL,
- OldBMP = NULL;
+ HBITMAP MemBMP = NULL, OldBMP = NULL;
MemDC = CreateCompatibleDC(hDC);
if (! MemDC) goto cleanup;
r.right = (lprc->right - lprc->left);
nclm.cbSize = sizeof(nclm);
- if (! SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &nclm, 0)) goto cleanup;
+ if (! SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &nclm, 0)) goto cleanup;
if (uFlags & DC_INBUTTON)
SetTextColor(MemDC, SysColours[ uFlags & DC_ACTIVE ? COLOR_BTNTEXT : COLOR_GRAYTEXT]);
}
}
-
LRESULT STDCALL
DefWndNCCalcSize(HWND hWnd, RECT* Rect)
{
- LRESULT Result = 0;
- LONG Style = GetClassLongW(hWnd, GCL_STYLE);
- RECT TmpRect = {0, 0, 0, 0};
+ LRESULT Result = 0;
+ LONG Style = GetClassLongW(hWnd, GCL_STYLE);
+ RECT TmpRect = {0, 0, 0, 0};
- if (Style & CS_VREDRAW)
+ if (Style & CS_VREDRAW)
{
- Result |= WVR_VREDRAW;
+ Result |= WVR_VREDRAW;
}
- if (Style & CS_HREDRAW)
+ if (Style & CS_HREDRAW)
{
- Result |= WVR_HREDRAW;
+ Result |= WVR_HREDRAW;
}
- if (!(GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE))
+ if (!(GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE))
{
- DefWndAdjustRect(&TmpRect, GetWindowLongW(hWnd, GWL_STYLE),
- FALSE, GetWindowLongW(hWnd, GWL_EXSTYLE));
- Rect->left -= TmpRect.left;
- Rect->top -= TmpRect.top;
- Rect->right -= TmpRect.right;
- Rect->bottom -= TmpRect.bottom;
- if (UserHasMenu(hWnd, GetWindowLongW(hWnd, GWL_EXSTYLE)))
- {
- Rect->top += MenuGetMenuBarHeight(hWnd,
- Rect->right - Rect->left,
- -TmpRect.left,
- -TmpRect.top) + 1;
- }
- Rect->bottom = max(Rect->top, Rect->bottom);
- Rect->right = max(Rect->left, Rect->right);
+ DefWndAdjustRect(&TmpRect, GetWindowLongW(hWnd, GWL_STYLE),
+ FALSE, GetWindowLongW(hWnd, GWL_EXSTYLE));
+ Rect->left -= TmpRect.left;
+ Rect->top -= TmpRect.top;
+ Rect->right -= TmpRect.right;
+ Rect->bottom -= TmpRect.bottom;
+ if (UserHasMenu(hWnd, GetWindowLongW(hWnd, GWL_STYLE)))
+ {
+ Rect->top += MenuGetMenuBarHeight(hWnd, Rect->right - Rect->left,
+ -TmpRect.left, -TmpRect.top) + 1;
+ }
+ if (Rect->top > Rect->bottom)
+ Rect->bottom = Rect->top;
+ if (Rect->left > Rect->right)
+ Rect->right = Rect->left;
}
- return(Result);
-}
+ return (Result);
+}
LRESULT
DefWndHandleWindowPosChanging(HWND hWnd, WINDOWPOS* Pos)
{
- UNIMPLEMENTED;
- return 0;
+ POINT maxSize, minTrack;
+ LONG style = GetWindowLongA(hWnd, GWL_STYLE);
+
+ if (Pos->flags & SWP_NOSIZE) return 0;
+ if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0))
+ {
+ WinPosGetMinMaxInfo(hWnd, &maxSize, NULL, &minTrack, NULL);
+ Pos->cx = min(Pos->cx, maxSize.x);
+ Pos->cy = min(Pos->cy, maxSize.y);
+ if (!(style & WS_MINIMIZE))
+ {
+ if (Pos->cx < minTrack.x) Pos->cx = minTrack.x;
+ if (Pos->cy < minTrack.y) Pos->cy = minTrack.y;
+ }
+ }
+ return 0;
+}
+
+/* Undocumented flags. */
+#define SWP_NOCLIENTMOVE 0x0800
+#define SWP_NOCLIENTSIZE 0x1000
+
+LRESULT
+DefWndHandleWindowPosChanged(HWND hWnd, WINDOWPOS* Pos)
+{
+ RECT rect;
+
+ GetClientRect(hWnd, &rect);
+
+ if (!(Pos->flags & SWP_NOCLIENTMOVE))
+ SendMessageW(hWnd, WM_MOVE, 0, MAKELONG(rect.left, rect.top));
+
+ if (!(Pos->flags & SWP_NOCLIENTSIZE))
+ {
+ WPARAM wp = SIZE_RESTORED;
+ if (IsZoomed(hWnd)) wp = SIZE_MAXIMIZED;
+ else if (IsIconic(hWnd)) wp = SIZE_MINIMIZED;
+ SendMessageW(hWnd, WM_SIZE, wp,
+ MAKELONG(rect.right - rect.left, rect.bottom - rect.top));
+ }
+
+ return 0;
}
LPARAM lParam,
BOOL bUnicode)
{
- switch (Msg)
+ switch (Msg)
{
- case WM_NCPAINT:
- {
- return(DefWndPaintNC(hWnd, (HRGN)wParam));
- }
- case WM_WINDOWPOSCHANGING:
- {
- break;
- }
- case WM_NCHITTEST:
- {
- POINT Point;
- Point.x = SLOWORD(lParam);
- Point.y = SHIWORD(lParam);
- return(DefWndHitTestNC(hWnd, Point));
- }
+ case WM_NCPAINT:
+ {
+ return (DefWndPaintNC(hWnd, (HRGN)wParam));
+ }
- case WM_NCLBUTTONDOWN:
- {
- return(DefWndHandleLButtonDownNC(hWnd, wParam, lParam));
- }
+ case WM_NCCALCSIZE:
+ {
+ return (DefWndNCCalcSize(hWnd, (RECT*)lParam));
+ }
- case WM_NCLBUTTONUP:
- {
- return(DefWndHandleLButtonUpNC(hWnd, wParam, lParam));
- }
+ case WM_WINDOWPOSCHANGING:
+ {
+ return (DefWndHandleWindowPosChanging(hWnd, (WINDOWPOS*)lParam));
+ }
- case WM_LBUTTONDBLCLK:
- case WM_NCLBUTTONDBLCLK:
- {
- return(DefWndHandleLButtonDblClkNC(hWnd, wParam, lParam));
- }
+ case WM_WINDOWPOSCHANGED:
+ {
+ return (DefWndHandleWindowPosChanged(hWnd, (WINDOWPOS*)lParam));
+ }
- case WM_NCRBUTTONDOWN:
- {
- if (wParam == HTCAPTION)
- {
- SetCapture(hWnd);
- }
- break;
- }
- case WM_LBUTTONUP:
- {
- break;
- }
- case WM_RBUTTONUP:
- {
- POINT Pt;
- if (hWnd == GetCapture())
- {
- ReleaseCapture();
- }
- Pt.x = SLOWORD(lParam);
- Pt.y = SHIWORD(lParam);
- ClientToScreen(hWnd, &Pt);
- lParam = MAKELPARAM(Pt.x, Pt.y);
- if (bUnicode)
- {
- SendMessageW(hWnd, WM_CONTEXTMENU, (WPARAM)hWnd, lParam);
- }
- else
- {
- SendMessageA (hWnd, WM_CONTEXTMENU, (WPARAM)hWnd, lParam);
- }
- break;
- }
+ case WM_NCHITTEST:
+ {
+ POINT Point;
+ Point.x = SLOWORD(lParam);
+ Point.y = SHIWORD(lParam);
+ return (DefWndHitTestNC(hWnd, Point));
+ }
- case WM_NCRBUTTONUP:
- {
- /* Wine does nothing here. */
- break;
- }
+ case WM_NCLBUTTONDOWN:
+ {
+ return (DefWndHandleLButtonDownNC(hWnd, wParam, lParam));
+ }
- case WM_CONTEXTMENU:
- {
- if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
- {
- if (bUnicode)
- {
- SendMessageW(GetParent(hWnd), Msg, wParam, lParam);
- }
- else
- {
- SendMessageA(hWnd, WM_CONTEXTMENU, wParam, lParam);
- }
- }
- else
- {
- LONG HitCode;
- POINT Pt;
+ case WM_NCLBUTTONUP:
+ {
+ return (DefWndHandleLButtonUpNC(hWnd, wParam, lParam));
+ }
- Pt.x = SLOWORD(lParam);
- Pt.y = SHIWORD(lParam);
+ case WM_LBUTTONDBLCLK:
+ case WM_NCLBUTTONDBLCLK:
+ {
+ return (DefWndHandleLButtonDblClkNC(hWnd, wParam, lParam));
+ }
- if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
- {
- ScreenToClient(GetParent(hWnd), &Pt);
- }
+ case WM_NCRBUTTONDOWN:
+ {
+ if (wParam == HTCAPTION)
+ {
+ SetCapture(hWnd);
+ }
+ break;
+ }
- HitCode = DefWndHitTestNC(hWnd, Pt);
+ case WM_RBUTTONUP:
+ {
+ POINT Pt;
+ if (hWnd == GetCapture())
+ {
+ ReleaseCapture();
+ }
+ Pt.x = SLOWORD(lParam);
+ Pt.y = SHIWORD(lParam);
+ ClientToScreen(hWnd, &Pt);
+ lParam = MAKELPARAM(Pt.x, Pt.y);
+ if (bUnicode)
+ {
+ SendMessageW(hWnd, WM_CONTEXTMENU, (WPARAM)hWnd, lParam);
+ }
+ else
+ {
+ SendMessageA(hWnd, WM_CONTEXTMENU, (WPARAM)hWnd, lParam);
+ }
+ break;
+ }
- if (HitCode == HTCAPTION || HitCode == HTSYSMENU)
- {
- TrackPopupMenu(GetSystemMenu(hWnd, FALSE),
- TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
- Pt.x, Pt.y, 0, hWnd, NULL);
- }
- }
- break;
- }
+ case WM_CONTEXTMENU:
+ {
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
+ {
+ if (bUnicode)
+ {
+ SendMessageW(GetParent(hWnd), Msg, wParam, lParam);
+ }
+ else
+ {
+ SendMessageA(GetParent(hWnd), WM_CONTEXTMENU, wParam, lParam);
+ }
+ }
+ else
+ {
+ LONG HitCode;
+ POINT Pt;
- case WM_NCACTIVATE:
- {
- return(DefWndHandleActiveNC(hWnd, wParam));
- }
+ Pt.x = SLOWORD(lParam);
+ Pt.y = SHIWORD(lParam);
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
+ {
+ ScreenToClient(GetParent(hWnd), &Pt);
+ }
- case WM_NCDESTROY:
- {
- return(0);
- }
+ HitCode = DefWndHitTestNC(hWnd, Pt);
- case WM_PRINT:
- {
- return(0);
- }
+ if (HitCode == HTCAPTION || HitCode == HTSYSMENU)
+ {
+ TrackPopupMenu(GetSystemMenu(hWnd, FALSE),
+ TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
+ Pt.x, Pt.y, 0, hWnd, NULL);
+ }
+ }
+ break;
+ }
- case WM_PAINTICON:
- case WM_PAINT:
- {
- PAINTSTRUCT Ps;
- HDC hDC = BeginPaint(hWnd, &Ps);
- if (hDC)
- {
- HICON hIcon;
- if (GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE &&
- (hIcon = (HICON)GetClassLongW(hWnd, GCL_HICON)) != NULL)
- {
- RECT WindowRect;
- INT x, y;
- GetWindowRect(hWnd, &WindowRect);
- x = (WindowRect.right - WindowRect.left -
- GetSystemMetrics(SM_CXICON)) / 2;
- y = (WindowRect.bottom - WindowRect.top -
- GetSystemMetrics(SM_CYICON)) / 2;
- DrawIcon(hDC, x, y, hIcon);
- }
- if (GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_CLIENTEDGE)
- {
- RECT WindowRect;
- GetClientRect(hWnd, &WindowRect);
- DrawEdge(hDC, &WindowRect, EDGE_SUNKEN, BF_RECT);
- }
- EndPaint(hWnd, &Ps);
- }
- return(0);
- }
+ case WM_NCACTIVATE:
+ {
+ return (DefWndHandleActiveNC(hWnd, wParam));
+ }
- case WM_SYNCPAINT:
- {
- HRGN hRgn;
- hRgn = CreateRectRgn(0, 0, 0, 0);
- if (GetUpdateRgn(hWnd, hRgn, FALSE) != NULLREGION)
- {
- RedrawWindow(hWnd, NULL, hRgn,
- RDW_ERASENOW | RDW_ERASE | RDW_FRAME |
- RDW_ALLCHILDREN);
- }
- DeleteObject(hRgn);
- return(0);
- }
+ case WM_PRINT:
+ {
+ /* FIXME: Implement. */
+ return (0);
+ }
- case WM_SETREDRAW:
- {
- DefWndSetRedraw(hWnd, wParam);
- return(0);
- }
+ case WM_PAINTICON:
+ case WM_PAINT:
+ {
+ PAINTSTRUCT Ps;
+ HDC hDC = BeginPaint(hWnd, &Ps);
+ if (hDC)
+ {
+ HICON hIcon;
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE &&
+ (hIcon = (HICON)GetClassLongW(hWnd, GCL_HICON)) != NULL)
+ {
+ RECT WindowRect;
+ INT x, y;
+ GetWindowRect(hWnd, &WindowRect);
+ x = (WindowRect.right - WindowRect.left -
+ GetSystemMetrics(SM_CXICON)) / 2;
+ y = (WindowRect.bottom - WindowRect.top -
+ GetSystemMetrics(SM_CYICON)) / 2;
+ DrawIcon(hDC, x, y, hIcon);
+ }
+ if (GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_CLIENTEDGE)
+ {
+ RECT WindowRect;
+ GetClientRect(hWnd, &WindowRect);
+ DrawEdge(hDC, &WindowRect, EDGE_SUNKEN, BF_RECT);
+ }
+ EndPaint(hWnd, &Ps);
+ }
+ return (0);
+ }
- case WM_CLOSE:
- {
- DestroyWindow(hWnd);
- return(0);
- }
+ case WM_SYNCPAINT:
+ {
+ HRGN hRgn;
+ hRgn = CreateRectRgn(0, 0, 0, 0);
+ if (GetUpdateRgn(hWnd, hRgn, FALSE) != NULLREGION)
+ {
+ RedrawWindow(hWnd, NULL, hRgn,
+ RDW_ERASENOW | RDW_ERASE | RDW_FRAME |
+ RDW_ALLCHILDREN);
+ }
+ DeleteObject(hRgn);
+ return (0);
+ }
- case WM_MOUSEACTIVATE:
- {
- if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
- {
- LONG Ret;
- if (bUnicode)
- {
- Ret = SendMessageW(GetParent(hWnd), WM_MOUSEACTIVATE,
- wParam, lParam);
- }
- else
- {
- Ret = SendMessageA(GetParent(hWnd), WM_MOUSEACTIVATE,
- wParam, lParam);
- }
- if (Ret)
- {
- return(Ret);
- }
- }
- return((LOWORD(lParam) >= HTCLIENT) ? MA_ACTIVATE : MA_NOACTIVATE);
- }
+ case WM_SETREDRAW:
+ {
+ DefWndSetRedraw(hWnd, wParam);
+ return (0);
+ }
- case WM_ACTIVATE:
- {
- /* Check if the window is minimized. */
- if (LOWORD(lParam) != WA_INACTIVE &&
- !(GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE))
- {
- SetFocus(hWnd);
- }
- break;
- }
+ case WM_CLOSE:
+ {
+ DestroyWindow(hWnd);
+ return (0);
+ }
- case WM_MOUSEWHEEL:
- {
- if (GetWindowLongW(hWnd, GWL_STYLE & WS_CHILD))
- {
- if (bUnicode)
- {
- return(SendMessageW(GetParent(hWnd), WM_MOUSEWHEEL,
- wParam, lParam));
- }
- else
- {
- return(SendMessageA(GetParent(hWnd), WM_MOUSEWHEEL,
- wParam, lParam));
- }
- }
- break;
- }
+ case WM_MOUSEACTIVATE:
+ {
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
+ {
+ LONG Ret;
+ if (bUnicode)
+ {
+ Ret = SendMessageW(GetParent(hWnd), WM_MOUSEACTIVATE,
+ wParam, lParam);
+ }
+ else
+ {
+ Ret = SendMessageA(GetParent(hWnd), WM_MOUSEACTIVATE,
+ wParam, lParam);
+ }
+ if (Ret)
+ {
+ return (Ret);
+ }
+ }
+ return ((LOWORD(lParam) >= HTCLIENT) ? MA_ACTIVATE : MA_NOACTIVATE);
+ }
- case WM_ERASEBKGND:
- case WM_ICONERASEBKGND:
- {
-
- RECT Rect;
- HBRUSH hBrush = (HBRUSH)GetClassLongW(hWnd, GCL_HBRBACKGROUND);
- if (NULL == hBrush)
- {
- return 0;
- }
- if (0 == (((DWORD) hBrush) & 0xffff0000))
- {
- hBrush = GetSysColorBrush((DWORD) hBrush - 1);
- }
- GetClipBox((HDC)wParam, &Rect);
- FillRect((HDC)wParam, &Rect, hBrush);
- return(1);
- }
+ case WM_ACTIVATE:
+ {
+ /* Check if the window is minimized. */
+ if (LOWORD(lParam) != WA_INACTIVE &&
+ !(GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE))
+ {
+ SetFocus(hWnd);
+ }
+ break;
+ }
- case WM_GETDLGCODE:
- {
- return(0);
- }
+ case WM_MOUSEWHEEL:
+ {
+ if (GetWindowLongW(hWnd, GWL_STYLE & WS_CHILD))
+ {
+ if (bUnicode)
+ {
+ return (SendMessageW(GetParent(hWnd), WM_MOUSEWHEEL,
+ wParam, lParam));
+ }
+ else
+ {
+ return (SendMessageA(GetParent(hWnd), WM_MOUSEWHEEL,
+ wParam, lParam));
+ }
+ }
+ break;
+ }
- /* FIXME: Implement colour controls. */
+ case WM_ERASEBKGND:
+ case WM_ICONERASEBKGND:
+ {
+ RECT Rect;
+ HBRUSH hBrush = (HBRUSH)GetClassLongW(hWnd, GCL_HBRBACKGROUND);
- case WM_SETCURSOR:
- {
- if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
- {
- if (LOWORD(lParam) < HTLEFT || LOWORD(lParam) > HTBOTTOMRIGHT)
- {
- BOOL bResult;
- if (bUnicode)
- {
- bResult = SendMessageW(GetParent(hWnd), WM_SETCURSOR,
- wParam, lParam);
- }
- else
- {
- bResult = SendMessageA(GetParent(hWnd), WM_SETCURSOR,
- wParam, lParam);
- }
- if (bResult)
- {
- return(TRUE);
- }
- }
- }
- return(DefWndHandleSetCursor(hWnd, wParam, lParam));
- }
+ if (NULL == hBrush)
+ {
+ return 0;
+ }
+ if (0 == (((DWORD) hBrush) & 0xffff0000))
+ {
+ hBrush = GetSysColorBrush((DWORD) hBrush - 1);
+ }
+ GetClipBox((HDC)wParam, &Rect);
+ FillRect((HDC)wParam, &Rect, hBrush);
+ return (1);
+ }
- case WM_SYSCOMMAND:
- {
- POINT Pt;
- Pt.x = SLOWORD(lParam);
- Pt.y = SHIWORD(lParam);
- return(DefWndHandleSysCommand(hWnd, wParam, Pt));
- }
+ /* FIXME: Implement colour controls. */
+/*
+ case WM_CTLCOLORMSGBOX:
+ case WM_CTLCOLOREDIT:
+ case WM_CTLCOLORLISTBOX:
+ case WM_CTLCOLORBTN:
+ case WM_CTLCOLORDLG:
+ case WM_CTLCOLORSTATIC:
+ case WM_CTLCOLORSCROLLBAR:
+ case WM_CTLCOLOR:
+*/
- /* FIXME: Handle key messages. */
+ case WM_SETCURSOR:
+ {
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
+ {
+ if (LOWORD(lParam) < HTLEFT || LOWORD(lParam) > HTBOTTOMRIGHT)
+ {
+ BOOL bResult;
+ if (bUnicode)
+ {
+ bResult = SendMessageW(GetParent(hWnd), WM_SETCURSOR,
+ wParam, lParam);
+ }
+ else
+ {
+ bResult = SendMessageA(GetParent(hWnd), WM_SETCURSOR,
+ wParam, lParam);
+ }
+ if (bResult)
+ {
+ return(TRUE);
+ }
+ }
+ }
+ return (DefWndHandleSetCursor(hWnd, wParam, lParam));
+ }
- case WM_SHOWWINDOW:
- {
- if (lParam)
- {
- return(0);
- }
- /* FIXME: Not done correctly */
- if ((GetWindowLongW(hWnd, GWL_STYLE) & WS_VISIBLE && !wParam) ||
- (!(GetWindowLongW(hWnd, GWL_STYLE) & WS_VISIBLE) && wParam))
- {
- return(0);
- }
- ShowWindow(hWnd, wParam ? SW_SHOWNA : SW_HIDE);
- break;
- }
+ case WM_SYSCOMMAND:
+ {
+ POINT Pt;
+ Pt.x = SLOWORD(lParam);
+ Pt.y = SHIWORD(lParam);
+ return (DefWndHandleSysCommand(hWnd, wParam, Pt));
+ }
- case WM_CANCELMODE:
- {
- /* FIXME: Check for a desktop. */
- if (GetCapture() == hWnd)
- {
- ReleaseCapture();
- }
- break;
- }
+ /* FIXME: Handle key messages. */
+/*
+ case WM_KEYDOWN:
+ case WM_KEYUP:
+ case WM_SYSKEYUP:
+ case WM_SYSCHAR:
+*/
- case WM_VKEYTOITEM:
- case WM_CHARTOITEM:
- return(-1);
+ /* FIXME: This is also incomplete. */
+ case WM_SYSKEYDOWN:
+ {
+ if (HIWORD(lParam) & KEYDATA_ALT)
+ {
+ if (wParam == VK_F4) /* Try to close the window */
+ {
+ HWND top = GetAncestor(hWnd, GA_ROOT);
+ if (!(GetClassLongW(top, GCL_STYLE) & CS_NOCLOSE))
+ {
+ if (bUnicode)
+ PostMessageW(top, WM_SYSCOMMAND, SC_CLOSE, 0);
+ else
+ PostMessageA(top, WM_SYSCOMMAND, SC_CLOSE, 0);
+ }
+ }
+ }
+ break;
+ }
+
+ case WM_SHOWWINDOW:
+ {
+ LONG Style;
+
+ if (!lParam)
+ return 0;
+ Style = GetWindowLongW(hWnd, GWL_STYLE);
+ if (!(Style & WS_POPUP))
+ return 0;
+ if ((Style & WS_VISIBLE) && wParam)
+ return 0;
+ if (!(Style & WS_VISIBLE) && !wParam)
+ return 0;
+ if (!GetWindow(hWnd, GW_OWNER))
+ return 0;
+ ShowWindow(hWnd, wParam ? SW_SHOWNA : SW_HIDE);
+ break;
+ }
- case WM_DROPOBJECT:
- /* FIXME: Implement this. */
- break;
+ case WM_CANCELMODE:
+ {
+ /* FIXME: Check for a desktop. */
+ if (GetCapture() == hWnd)
+ {
+ ReleaseCapture();
+ }
+ break;
+ }
- case WM_QUERYDROPOBJECT:
- {
- if (GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_ACCEPTFILES)
- {
- return(1);
- }
- break;
- }
+ case WM_VKEYTOITEM:
+ case WM_CHARTOITEM:
+ return (-1);
- case WM_QUERYDRAGICON:
- {
- UINT Len;
- HICON hIcon;
+ case WM_DROPOBJECT:
+ /* FIXME: Implement this. */
+ break;
- hIcon = (HICON)GetClassLongW(hWnd, GCL_HICON);
- if (hIcon)
- {
- return((LRESULT)hIcon);
- }
- for (Len = 1; Len < 64; Len++)
- {
- if ((hIcon = LoadIconW(NULL, MAKEINTRESOURCEW(Len))) != NULL)
- {
- return((LRESULT)hIcon);
- }
- }
- return((LRESULT)LoadIconW(0, IDI_APPLICATION));
- }
+ case WM_QUERYDROPOBJECT:
+ {
+ if (GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_ACCEPTFILES)
+ {
+ return(1);
+ }
+ break;
+ }
- /* FIXME: WM_ISACTIVEICON */
+ case WM_QUERYDRAGICON:
+ {
+ UINT Len;
+ HICON hIcon;
- case WM_NOTIFYFORMAT:
- {
- if (IsWindowUnicode(hWnd))
- {
- return(NFR_UNICODE);
- }
- else
- {
- return(NFR_ANSI);
- }
- }
+ hIcon = (HICON)GetClassLongW(hWnd, GCL_HICON);
+ if (hIcon)
+ {
+ return ((LRESULT)hIcon);
+ }
+ for (Len = 1; Len < 64; Len++)
+ {
+ if ((hIcon = LoadIconW(NULL, MAKEINTRESOURCEW(Len))) != NULL)
+ {
+ return((LRESULT)hIcon);
+ }
+ }
+ return ((LRESULT)LoadIconW(0, IDI_APPLICATION));
+ }
- case WM_SETICON:
- {
- INT Index = (wParam != 0) ? GCL_HICON : GCL_HICONSM;
- HICON hOldIcon = (HICON)GetClassLongW(hWnd, Index);
- SetClassLongW(hWnd, Index, lParam);
- SetWindowPos(hWnd, 0, 0, 0, 0, 0,
- SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
- SWP_NOACTIVATE | SWP_NOZORDER);
- return((LRESULT)hOldIcon);
- }
+ /* FIXME: WM_ISACTIVEICON */
- case WM_GETICON:
- {
- INT Index = (wParam != 0) ? GCL_HICON : GCL_HICONSM;
- return(GetClassLongW(hWnd, Index));
- }
+ case WM_NOTIFYFORMAT:
+ {
+ if (IsWindowUnicode(hWnd))
+ {
+ return(NFR_UNICODE);
+ }
+ else
+ {
+ return(NFR_ANSI);
+ }
+ }
- case WM_HELP:
- {
- if (bUnicode)
- {
- SendMessageW(GetParent(hWnd), Msg, wParam, lParam);
- }
- else
- {
- SendMessageA(GetParent(hWnd), Msg, wParam, lParam);
- }
- break;
- }
+ case WM_SETICON:
+ {
+ INT Index = (wParam != 0) ? GCL_HICON : GCL_HICONSM;
+ HICON hOldIcon = (HICON)GetClassLongW(hWnd, Index);
+ SetClassLongW(hWnd, Index, lParam);
+ SetWindowPos(hWnd, 0, 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
+ SWP_NOACTIVATE | SWP_NOZORDER);
+ return ((LRESULT)hOldIcon);
+ }
- case WM_SYSKEYDOWN:
- if (HIWORD(lParam) & KEYDATA_ALT)
- {
- if (wParam == VK_F4) /* Try to close the window */
- {
- //HWND hTopWnd = GetAncestor(hWnd, GA_ROOT);
- HWND hTopWnd = hWnd;
- if (!(GetClassLongW(hTopWnd, GCL_STYLE) & CS_NOCLOSE))
- {
- if (bUnicode)
- {
- PostMessageW(hTopWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
- }
- else
- {
- PostMessageA(hTopWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
- }
- }
+ case WM_GETICON:
+ {
+ INT Index = (wParam != 0) ? GCL_HICON : GCL_HICONSM;
+ return (GetClassLongW(hWnd, Index));
+ }
+
+ case WM_HELP:
+ {
+ if (bUnicode)
+ {
+ SendMessageW(GetParent(hWnd), Msg, wParam, lParam);
}
- }
- break;
+ else
+ {
+ SendMessageA(GetParent(hWnd), Msg, wParam, lParam);
+ }
+ break;
+ }
+
+ case WM_QUERYOPEN:
+ case WM_QUERYENDSESSION:
+ {
+ return (1);
+ }
}
- return 0;
+ return 0;
}
WPARAM wParam,
LPARAM lParam)
{
- LRESULT Result;
- static LPSTR WindowTextAtom = 0;
- PSTR WindowText;
+ static LPSTR WindowTextAtom = 0;
+ PSTR WindowText;
- switch (Msg)
+ switch (Msg)
{
- case WM_NCCREATE:
- {
- CREATESTRUCTA* Cs = (CREATESTRUCTA*)lParam;
- if (HIWORD(Cs->lpszName))
- {
- if (0 == WindowTextAtom)
- {
- WindowTextAtom =
- (LPSTR)(ULONG)GlobalAddAtomA("USER32!WindowTextAtomA");
- }
- WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0,
- strlen(Cs->lpszName) * sizeof(CHAR));
- strcpy(WindowText, Cs->lpszName);
- SetPropA(hWnd, WindowTextAtom, WindowText);
- }
- return(1);
- }
-
- case WM_NCCALCSIZE:
- {
- return(DefWndNCCalcSize(hWnd, (RECT*)lParam));
- }
-
- case WM_WINDOWPOSCHANGING:
- {
- return(DefWndHandleWindowPosChanging(hWnd, (WINDOWPOS*)lParam));
- }
+ case WM_NCCREATE:
+ {
+ CREATESTRUCTA *Cs = (CREATESTRUCTA*)lParam;
+ if (HIWORD(Cs->lpszName))
+ {
+ if (0 == WindowTextAtom)
+ {
+ WindowTextAtom =
+ (LPSTR)(ULONG)GlobalAddAtomA("USER32!WindowTextAtomA");
+ }
+ WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0,
+ strlen(Cs->lpszName) * sizeof(CHAR));
+ strcpy(WindowText, Cs->lpszName);
+ SetPropA(hWnd, WindowTextAtom, WindowText);
+ }
+ return (1);
+ }
- case WM_GETTEXTLENGTH:
- {
- if (WindowTextAtom == 0 ||
- (WindowText = GetPropA(hWnd, WindowTextAtom)) == NULL)
- {
- return(0);
- }
- return(strlen(WindowText));
- }
+ case WM_GETTEXTLENGTH:
+ {
+ if (WindowTextAtom == 0 ||
+ (WindowText = GetPropA(hWnd, WindowTextAtom)) == NULL)
+ {
+ return(0);
+ }
+ return (strlen(WindowText));
+ }
- case WM_GETTEXT:
- {
- if (WindowTextAtom == 0 ||
- (WindowText = GetPropA(hWnd, WindowTextAtom)) == NULL)
- {
- if (wParam > 1)
- {
- *((PSTR)lParam) = '\0';
- }
- return(0);
- }
- strncpy((LPSTR)lParam, WindowText, wParam);
- return(min(wParam, strlen(WindowText)));
- }
+ case WM_GETTEXT:
+ {
+ if (WindowTextAtom == 0 ||
+ (WindowText = GetPropA(hWnd, WindowTextAtom)) == NULL)
+ {
+ if (wParam > 1)
+ {
+ *((PSTR)lParam) = '\0';
+ }
+ return (0);
+ }
+ strncpy((LPSTR)lParam, WindowText, wParam);
+ return (min(wParam, strlen(WindowText)));
+ }
- case WM_SETTEXT:
- {
- if (0 == WindowTextAtom)
- {
- WindowTextAtom =
- (LPSTR)(DWORD)GlobalAddAtomA("USER32!WindowTextAtomA");
- }
- if (WindowTextAtom != 0 &&
- (WindowText = GetPropA(hWnd, WindowTextAtom)) == NULL)
- {
- RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText);
- }
- WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0,
- strlen((PSTR)lParam) * sizeof(CHAR));
- strcpy(WindowText, (PSTR)lParam);
- SetPropA(hWnd, WindowTextAtom, WindowText);
- if (0 != (GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION))
- {
- DefWndPaintNC(hWnd, (HRGN) 1);
- }
- Result = (LPARAM) TRUE;
- break;
- }
+ case WM_SETTEXT:
+ {
+ if (0 == WindowTextAtom)
+ {
+ WindowTextAtom =
+ (LPSTR)(DWORD)GlobalAddAtomA("USER32!WindowTextAtomA");
+ }
+ if (WindowTextAtom != 0 &&
+ (WindowText = GetPropA(hWnd, WindowTextAtom)) == NULL)
+ {
+ RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText);
+ }
+ WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0,
+ strlen((PSTR)lParam) * sizeof(CHAR));
+ strcpy(WindowText, (PSTR)lParam);
+ SetPropA(hWnd, WindowTextAtom, WindowText);
+ if (0 != (GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION))
+ {
+ DefWndPaintNC(hWnd, (HRGN) 1);
+ }
+ return (1);
+ }
- case WM_NCDESTROY:
- {
- if (WindowTextAtom != 0 &&
- (WindowText = RemovePropA(hWnd, WindowTextAtom)) == NULL)
- {
- RtlFreeHeap(GetProcessHeap(), 0, WindowText);
- }
- return(0);
- }
+/*
+ FIXME: Implement these.
+ case WM_IME_CHAR:
+ case WM_IME_KEYDOWN:
+ case WM_IME_KEYUP:
+ case WM_IME_STARTCOMPOSITION:
+ case WM_IME_COMPOSITION:
+ case WM_IME_ENDCOMPOSITION:
+ case WM_IME_SELECT:
+ case WM_IME_SETCONTEXT:
+*/
- default:
- Result = User32DefWindowProc(hWnd, Msg, wParam, lParam, FALSE);
- break;
+ case WM_NCDESTROY:
+ {
+ if (WindowTextAtom != 0 &&
+ (WindowText = RemovePropA(hWnd, WindowTextAtom)) == NULL)
+ {
+ RtlFreeHeap(GetProcessHeap(), 0, WindowText);
+ }
+ return(0);
+ }
}
- return(Result);
+ return User32DefWindowProc(hWnd, Msg, wParam, lParam, FALSE);
}
WPARAM wParam,
LPARAM lParam)
{
- LRESULT Result;
- static LPWSTR WindowTextAtom = 0;
- PWSTR WindowText;
+ static LPWSTR WindowTextAtom = 0;
+ PWSTR WindowText;
- switch (Msg)
+ switch (Msg)
{
- case WM_NCCREATE:
- {
- CREATESTRUCTW* Cs = (CREATESTRUCTW*)lParam;
- if (HIWORD(Cs->lpszName))
- {
- if (0 == WindowTextAtom)
- {
- WindowTextAtom =
- (LPWSTR)(DWORD)GlobalAddAtomW(L"USER32!WindowTextAtomW");
- }
- WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0,
- wcslen(Cs->lpszName) * sizeof(WCHAR));
- wcscpy(WindowText, Cs->lpszName);
- SetPropW(hWnd, WindowTextAtom, WindowText);
- }
- return(1);
- }
-
- case WM_NCCALCSIZE:
- {
- return(DefWndNCCalcSize(hWnd, (RECT*)lParam));
- }
+ case WM_NCCREATE:
+ {
+ CREATESTRUCTW* CreateStruct = (CREATESTRUCTW*)lParam;
+ if (HIWORD(CreateStruct->lpszName))
+ {
+ if (0 == WindowTextAtom)
+ {
+ WindowTextAtom =
+ (LPWSTR)(DWORD)GlobalAddAtomW(L"USER32!WindowTextAtomW");
+ }
+ WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0,
+ wcslen(CreateStruct->lpszName) * sizeof(WCHAR));
+ wcscpy(WindowText, CreateStruct->lpszName);
+ SetPropW(hWnd, WindowTextAtom, WindowText);
+ }
+ return (1);
+ }
- case WM_WINDOWPOSCHANGING:
- {
- return(DefWndHandleWindowPosChanging(hWnd, (WINDOWPOS*)lParam));
- }
+ case WM_GETTEXTLENGTH:
+ {
+ if (WindowTextAtom == 0 ||
+ (WindowText = GetPropW(hWnd, WindowTextAtom)) == NULL)
+ {
+ return(0);
+ }
+ return (wcslen(WindowText));
+ }
- case WM_GETTEXTLENGTH:
- {
- if (WindowTextAtom == 0 ||
- (WindowText = GetPropW(hWnd, WindowTextAtom)) == NULL)
- {
- return(0);
- }
- return(wcslen(WindowText));
- }
+ case WM_GETTEXT:
+ {
+ if (WindowTextAtom == 0 ||
+ (WindowText = GetPropW(hWnd, WindowTextAtom)) == NULL)
+ {
+ if (wParam > 1)
+ {
+ ((PWSTR)lParam) = '\0';
+ }
+ return (0);
+ }
+ wcsncpy((PWSTR)lParam, WindowText, wParam);
+ return (min(wParam, wcslen(WindowText)));
+ }
- case WM_GETTEXT:
- {
- if (WindowTextAtom == 0 ||
- (WindowText = GetPropW(hWnd, WindowTextAtom)) == NULL)
- {
- if (wParam > 1)
- {
- ((PWSTR)lParam) = '\0';
- }
- return(0);
- }
- wcsncpy((PWSTR)lParam, WindowText, wParam);
- return(min(wParam, wcslen(WindowText)));
- }
+ case WM_SETTEXT:
+ {
+ if (WindowTextAtom == 0)
+ {
+ WindowTextAtom =
+ (LPWSTR)(DWORD)GlobalAddAtomW(L"USER32!WindowTextAtomW");
+ }
+ if (WindowTextAtom != 0 &&
+ (WindowText = GetPropW(hWnd, WindowTextAtom)) == NULL)
+ {
+ RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText);
+ }
+ WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0,
+ wcslen((PWSTR)lParam) * sizeof(WCHAR));
+ wcscpy(WindowText, (PWSTR)lParam);
+ SetPropW(hWnd, WindowTextAtom, WindowText);
+ if ((GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
+ {
+ DefWndPaintNC(hWnd, (HRGN)1);
+ }
+ return (1);
+ }
- case WM_SETTEXT:
- {
- if (WindowTextAtom == 0)
- {
- WindowTextAtom =
- (LPWSTR)(DWORD)GlobalAddAtomW(L"USER32!WindowTextAtomW");
- }
- if (WindowTextAtom != 0 &&
- (WindowText = GetPropW(hWnd, WindowTextAtom)) == NULL)
- {
- RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText);
- }
- WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0,
- wcslen((PWSTR)lParam) * sizeof(WCHAR));
- wcscpy(WindowText, (PWSTR)lParam);
- SetPropW(hWnd, WindowTextAtom, WindowText);
- if (0 != (GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION))
- {
- DefWndPaintNC(hWnd, (HRGN) 1);
- }
- Result = (LPARAM) TRUE;
- break;
- }
+ case WM_IME_CHAR:
+ {
+ SendMessageW(hWnd, WM_CHAR, wParam, lParam);
+ return (0);
+ }
- case WM_NCDESTROY:
- {
- if (WindowTextAtom != 0 &&
- (WindowText = RemovePropW(hWnd, WindowTextAtom)) == NULL)
- {
- RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText);
- }
- return(0);
- }
+ case WM_IME_SETCONTEXT:
+ {
+ /* FIXME */
+ return (0);
+ }
- default:
- Result = User32DefWindowProc(hWnd, Msg, wParam, lParam, TRUE);
- break;
+ case WM_NCDESTROY:
+ {
+ if (WindowTextAtom != 0 &&
+ (WindowText = RemovePropW(hWnd, WindowTextAtom)) == NULL)
+ {
+ RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText);
+ }
+ return (0);
+ }
}
- return(Result);
+ return User32DefWindowProc(hWnd, Msg, wParam, lParam, TRUE);
}