*
*/
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-#include "windef.h"
-#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "wine/unicode.h"
-#include "user32/regcontrol.h"
-#include <winnls.h>
-#include "wine/debug.h"
-#include "dlgs.h"
+#include <user32.h>
+#define NDEBUG
+#include <debug.h>
+
WINE_DEFAULT_DEBUG_CHANNEL(mdi);
static LRESULT WINAPI MDIClientWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
static LRESULT WINAPI MDIClientWndProcW( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
+
+static
+HWND* WIN_ListChildren (HWND hWndparent)
+{
+
+ DWORD dwCount = 0;
+ HWND* pHwnd = NULL;
+ HANDLE hHeap;
+
+ SetLastError(0);
+
+ dwCount = NtUserBuildHwndList ( NULL, hWndparent, FALSE, 0, 0, NULL, 0 );
+
+ if ( !dwCount || GetLastError() )
+ return 0;
+
+ /* allocate buffer to receive HWND handles */
+ hHeap = GetProcessHeap();
+
+ pHwnd = HeapAlloc ( hHeap, 0, sizeof(HWND)*(dwCount+1) );
+ if ( !pHwnd )
+ {
+ SetLastError ( ERROR_NOT_ENOUGH_MEMORY );
+ return 0;
+ }
+
+ /* now call kernel again to fill the buffer this time */
+ dwCount = NtUserBuildHwndList (NULL, hWndparent, FALSE, 0, 0, pHwnd, dwCount );
+
+ if ( !dwCount || GetLastError() )
+ {
+ if ( pHwnd )
+ HeapFree ( hHeap, 0, pHwnd );
+ return 0;
+ }
+
+ return pHwnd;
+}
+
+
+
#ifdef __REACTOS__
void WINAPI ScrollChildren(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void WINAPI CalcChildScroll(HWND hwnd, INT scroll);
{
#ifdef __REACTOS__
DWORD Control = id;
- if (hwnd && !EnumChildWindows(hwnd, (ENUMWINDOWSPROC)&MDI_GetChildByID_EnumProc, (LPARAM)&Control))
+ if (hwnd && !EnumChildWindows(hwnd, (WNDENUMPROC)&MDI_GetChildByID_EnumProc, (LPARAM)&Control))
{
return (HWND)Control;
}
#endif
}
+static BOOL is_close_enabled(HWND hwnd, HMENU hSysMenu)
+{
+ if (GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE) return FALSE;
+
+ if (!hSysMenu) hSysMenu = GetSystemMenu(hwnd, FALSE);
+ if (hSysMenu)
+ {
+ UINT state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
+ if (state == 0xFFFFFFFF || (state & (MF_DISABLED | MF_GRAYED)))
+ return FALSE;
+ }
+ return TRUE;
+}
+
/**********************************************************************
* MDI_MenuModifyItem
*/
if (clientInfo->nActiveChildren - 1 > MDI_MOREWINDOWSLIMIT)
{
WCHAR szTmp[50];
- LoadStringW(GetModuleHandleA("USER32"), IDS_MDI_MOREWINDOWS, szTmp, sizeof(szTmp)/sizeof(szTmp[0]));
+ LoadStringW(User32Instance, IDS_MDI_MOREWINDOWS, szTmp, sizeof(szTmp)/sizeof(szTmp[0]));
AppendMenuW(clientInfo->hWindowMenu, MF_STRING, clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT, szTmp);
}
return TRUE;
static HWND MDI_GetWindow(MDICLIENTINFO *clientInfo, HWND hWnd, BOOL bNext,
DWORD dwStyleMask )
{
-#ifdef __REACTOS__
- /* FIXME */
- return 0;
-#else
int i;
HWND *list;
HWND last = 0;
found:
HeapFree( GetProcessHeap(), 0, list );
return last;
-#endif
}
/**********************************************************************
if (ci->nActiveChildren == MDI_MOREWINDOWSLIMIT + 1)
{
WCHAR szTmp[50];
- LoadStringW(GetModuleHandleA("USER32"), IDS_MDI_MOREWINDOWS, szTmp, sizeof(szTmp)/sizeof(szTmp[0]));
+ LoadStringW(User32Instance, IDS_MDI_MOREWINDOWS, szTmp, sizeof(szTmp)/sizeof(szTmp[0]));
ModifyMenuW(ci->hWindowMenu,
ci->idFirstChild + MDI_MOREWINDOWSLIMIT,
return hbCopy;
}
+
+
+
/**********************************************************************
* MDICascade
*/
static LONG MDICascade( HWND client, MDICLIENTINFO *ci )
{
-#ifdef __REACTOS__
- /* FIXME */
- return 0;
-#else
HWND *win_array;
BOOL has_icons = FALSE;
int i, total;
+DbgPrint("MDICascade\n");
+
if (ci->hwndChildMaximized)
SendMessageA( client, WM_MDIRESTORE,
(WPARAM)ci->hwndChildMaximized, 0);
if (has_icons) ArrangeIconicWindows( client );
return 0;
-#endif
}
/**********************************************************************
*/
static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam )
{
-#ifdef __REACTOS__
- /* FIXME */
- return;
-#else
HWND *win_array;
int i, total;
BOOL has_icons = FALSE;
+DbgPrint("MDITile\n");
+
if (ci->hwndChildMaximized)
SendMessageA( client, WM_MDIRESTORE, (WPARAM)ci->hwndChildMaximized, 0);
}
HeapFree( GetProcessHeap(), 0, win_array );
if (has_icons) ArrangeIconicWindows( client );
-#endif
}
/* ----------------------- Frame window ---------------------------- */
if (!(hSysPopup = GetSystemMenu(hChild, FALSE)))
return 0;
- AppendMenuA(menu,MF_HELP | MF_BITMAP,
- SC_MINIMIZE, (LPSTR)(DWORD)HBMMENU_MBAR_MINIMIZE ) ;
- AppendMenuA(menu,MF_HELP | MF_BITMAP,
- SC_RESTORE, (LPSTR)(DWORD)HBMMENU_MBAR_RESTORE );
-
- AppendMenuA(menu,MF_HELP | MF_BITMAP,
- SC_CLOSE, (LPSTR)(DWORD)HBMMENU_MBAR_CLOSE );
+ AppendMenuW(menu, MF_HELP | MF_BITMAP,
+ SC_MINIMIZE, (LPCWSTR)HBMMENU_MBAR_MINIMIZE ) ;
+ AppendMenuW(menu, MF_HELP | MF_BITMAP,
+ SC_RESTORE, (LPCWSTR)HBMMENU_MBAR_RESTORE );
+ AppendMenuW(menu, MF_HELP | MF_BITMAP,
+ SC_CLOSE, is_close_enabled(hChild, hSysPopup) ?
+ (LPCWSTR)HBMMENU_MBAR_CLOSE : (LPCWSTR)HBMMENU_MBAR_CLOSE_D );
/* The system menu is replaced by the child icon */
hIcon = (HICON)GetClassLongW(hChild, GCL_HICONSM);
if( !ci->hwndChildMaximized ) break;
switch( id )
{
+ case SC_CLOSE:
+ if (!is_close_enabled(ci->hwndActiveChild, 0)) break;
case SC_SIZE:
case SC_MOVE:
case SC_MINIMIZE:
case SC_MAXIMIZE:
case SC_NEXTWINDOW:
case SC_PREVWINDOW:
- case SC_CLOSE:
case SC_RESTORE:
return SendMessageW( ci->hwndChildMaximized, WM_SYSCOMMAND,
wParam, lParam);
case WM_SETFOCUS:
case WM_CHILDACTIVATE:
case WM_SYSCOMMAND:
-/* FIXME */
#ifndef __REACTOS__
case WM_SETVISIBLE:
#endif
+ case WM_SHOWWINDOW:
case WM_SIZE:
case WM_NEXTMENU:
case WM_SYSCHAR:
}
break;
-/* FIXME */
#ifndef __REACTOS__
case WM_SETVISIBLE:
+#endif
+ case WM_SHOWWINDOW:
if( ci->hwndChildMaximized) ci->mdiFlags &= ~MDIF_NEEDUPDATE;
else MDI_PostUpdate(client, ci, SB_BOTH+1);
break;
-#endif
case WM_SIZE:
if( ci->hwndActiveChild == hwnd && wParam != SIZE_MAXIMIZED )
break;
case VK_F4:
case VK_RBUTTON:
- wParam = SC_CLOSE;
- break;
+ if (is_close_enabled(ci->hwndActiveChild, 0))
+ {
+ wParam = SC_CLOSE;
+ break;
+ }
+ /* fall through */
default:
return 0;
}
{
case WM_INITDIALOG:
{
-#ifdef __REACTOS__
- /* FIXME */
- return FALSE;
-#else
UINT widest = 0;
UINT length;
UINT i;
/* Set the current selection */
SendMessageW(hListBox, LB_SETCURSEL, MDI_MOREWINDOWSLIMIT, 0);
return TRUE;
-#endif
}
case WM_COMMAND:
HRSRC hRes;
HANDLE hDlgTmpl;
- hRes = FindResourceA(GetModuleHandleA("USER32"), "MDI_MOREWINDOWS", (LPSTR)RT_DIALOG);
+ hRes = FindResourceA(User32Instance, "MDI_MOREWINDOWS", (LPSTR)RT_DIALOG);
if (hRes == 0)
return 0;
- hDlgTmpl = LoadResource(GetModuleHandleA("USER32"), hRes );
+ hDlgTmpl = LoadResource(User32Instance, hRes);
if (hDlgTmpl == 0)
return 0;
if (template == 0)
return 0;
- return (HWND) DialogBoxIndirectParamA(GetModuleHandleA("USER32"),
+ return (HWND) DialogBoxIndirectParamA(User32Instance,
(LPDLGTEMPLATE) template,
hwnd, MDI_MoreWindowsDlgProc, (LPARAM) hwnd);
}
static void MDI_SwapMenuItems(HWND parent, UINT pos1, UINT pos2)
{
-/* FIXME */
-#ifndef __REACTOS__
HWND *list;
int i;
else if (id == pos2) SetWindowLongW( list[i], GWL_ID, pos1 );
}
HeapFree( GetProcessHeap(), 0, list );
-#endif
}