Re: Add support for CS_NOCLOSE

2003-08-14 Thread Dmitry Timoshkov
Dmitry Timoshkov [EMAIL PROTECTED] wrote:

 My test under win2k shows that Windows sends
 WM_SYSCOMMAND/SC_CLOSE and then WM_CLOSE regardless whether CS_NOCLOSE
 is set or not.

Wrong. Please ignore that chunk of the patch. If other parts are OK I'll
resend the whole thing.

-- 
Dmitry.





Re: Add support for CS_NOCLOSE

2003-08-14 Thread Dmitry Timoshkov
Alexandre Julliard [EMAIL PROTECTED] wrote:

 I think it's much better, drawing directly will cause a lot of
 problems, especially when called from another thread context. Unless
 you really have an app that depends on not getting a WM_NCPAINT here I
 see no reason not to use the normal mechanisms.

OK, here is another patch. But it now exposes a bug in Wine's RedrawWindow()
implementation. Under win2k RedrawWindow(RDW_FRAME | RDW_INVALIDATE) causes
a window to receive only WM_NCPAINT, while under Wine it redraws the whole
window.

-- 
Dmitry.
diff -u cvs/hq/wine/controls/menu.c wine/controls/menu.c
--- cvs/hq/wine/controls/menu.c Tue May 13 09:33:13 2003
+++ wine/controls/menu.cSun Aug 10 23:57:50 2003
@@ -3267,9 +3267,8 @@ UINT WINAPI EnableMenuItem( HMENU hMenu,
if (!(parentMenu = MENU_GetMenu(menu-hSysMenuOwner)))
return (UINT)-1;
 
-   /* Refresh the frame to reflect the change*/
-   SetWindowPos(parentMenu-hWnd, 0, 0, 0, 0, 0,
-SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
+/* Refresh the frame to reflect the change */
+RedrawWindow(parentMenu-hWnd, NULL, 0, RDW_FRAME | RDW_INVALIDATE | 
RDW_NOCHILDREN);
}
}
 
diff -u cvs/hq/wine/windows/nonclient.c wine/windows/nonclient.c
--- cvs/hq/wine/windows/nonclient.c Wed Feb 19 21:30:36 2003
+++ wine/windows/nonclient.cSun Aug 10 23:59:55 2003
@@ -1349,10 +1349,11 @@ static void  NC_DrawCaption95(
/* Go get the sysmenu */
hSysMenu = GetSystemMenu(hwnd, FALSE);
state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
+if (state == 0x) state = 0;
+if (GetClassLongW(hwnd, GCL_STYLE)  CS_NOCLOSE) state |= MF_GRAYED;
 
/* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not 
there */
-   NC_DrawCloseButton95 (hwnd, hdc, FALSE,
- state  MF_DISABLED) || (state  MF_GRAYED)))  
(state != 0x)));
+   NC_DrawCloseButton95 (hwnd, hdc, FALSE, state  (MF_DISABLED | MF_GRAYED));
r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
 
if ((style  WS_MAXIMIZEBOX) || (style  WS_MINIMIZEBOX))
@@ -1939,9 +1940,10 @@ NC_TrackCloseButton95 (HWND hwnd, WORD w
return;
 
 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
+if (GetClassLongW(hwnd, GCL_STYLE)  CS_NOCLOSE) state |= MF_GRAYED;
 
 /* If the item close of the sysmenu is disabled or not there do nothing */
-if((state  MF_DISABLED) || (state  MF_GRAYED) || (state == 0x))
+if((state  (MF_DISABLED | MF_GRAYED)) || (state == 0x))
return;
 
 hdc = GetWindowDC( hwnd );


Re: Add support for CS_NOCLOSE

2003-08-14 Thread Alexandre Julliard
Dmitry Timoshkov [EMAIL PROTECTED] writes:

 Hello,

 Changelog:
 Dmitry Timoshkov [EMAIL PROTECTED]
 Add support for CS_NOCLOSE.

This is implemented already in MENU_InitSysMenuPopup; if it doesn't
work right it should be fixed there.

-- 
Alexandre Julliard
[EMAIL PROTECTED]



Re: Add support for CS_NOCLOSE

2003-08-14 Thread Dmitry Timoshkov
Alexandre Julliard [EMAIL PROTECTED] wrote:

  Windows doesn't use SetWindowPos to update the disabled Close button,
  but draws the button directly.
 
 Actually that doesn't look right either, we shouldn't bypass the
 normal painting code IMO; but RedrawWindow(RDW_FRAME) would probably
 work better than SetWindowPos.

Probably RedrawWindow(RDW_FRAME) would be better, but under Windows
a window doesn't receive WM_NCPAINT in that case either.

-- 
Dmitry.





Re: Add support for CS_NOCLOSE

2003-08-09 Thread Dmitry Timoshkov
Alexandre Julliard [EMAIL PROTECTED] wrote:

 This is implemented already in MENU_InitSysMenuPopup; if it doesn't
 work right it should be fixed there.

Windows doesn't use SetWindowPos to update the disabled Close button,
but draws the button directly. So you can apply the patch and ignore
only the last chunk of it:

--- cvs/hq/wine/windows/win.c Wed Jun 25 15:59:24 2003
+++ wine/windows/win.c Sat Aug  2 22:43:41 2003
@@ -1169,6 +1169,10 @@ static HWND WIN_CreateWindowEx( CREATEST
 return 0;
 }
 
+/* Disable the 'Close' system menu item in the case of CS_NOCLOSE */
+if ((GetWindowLongW(hwnd, GWL_STYLE)  WS_SYSMENU)  (GetClassLongW(hwnd, 
GCL_STYLE)  CS_NOCLOSE))
+EnableMenuItem(GetSystemMenu(hwnd, FALSE), SC_CLOSE, MF_GRAYED);
+
 /* Notify the parent window only */
 
 send_parent_notify( hwnd, WM_CREATE );

I'll try to investigate why existing code in MENU_InitSysMenuPopup doesn't work.

-- 
Dmitry.





Re: Add support for CS_NOCLOSE

2003-08-09 Thread Dmitry Timoshkov
Alexandre Julliard [EMAIL PROTECTED] wrote:

 Actually that doesn't look right either, we shouldn't bypass the
 normal painting code IMO; but RedrawWindow(RDW_FRAME) would probably
 work better than SetWindowPos.

Here is an updated patch which works for me and also removes
WM_SYSCOMMAND/SC_CLOSE filtering based on the CS_NOCLOSE test
in DefWindowProc. My test under win2k shows that Windows sends
WM_SYSCOMMAND/SC_CLOSE and then WM_CLOSE regardless whether CS_NOCLOSE
is set or not.

Alexandre, I understand that you want to separate the drawing code from
such cases and prevent a possible breakage of win31/etc. drawing code.
But that's how it's done in Windows. It's up to you, if you wish, to
replace the NC_DrawCloseButton95 call by RedrawWindow(RDW_FRAME) if you
still think that it's cleaner to do.

-- 
Dmitry.
diff -u cvs/hq/wine/controls/menu.c wine/controls/menu.c
--- cvs/hq/wine/controls/menu.c Tue May 13 09:33:13 2003
+++ wine/controls/menu.cFri Aug  8 20:58:16 2003
@@ -3262,14 +3262,16 @@ UINT WINAPI EnableMenuItem( HMENU hMenu,
if (menu-hSysMenuOwner != 0)
{
POPUPMENU* parentMenu;
+HDC hdc;
 
/* Get the parent menu to access*/
if (!(parentMenu = MENU_GetMenu(menu-hSysMenuOwner)))
return (UINT)-1;
 
/* Refresh the frame to reflect the change*/
-   SetWindowPos(parentMenu-hWnd, 0, 0, 0, 0, 0,
-SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
+hdc = GetWindowDC(parentMenu-hWnd);
+NC_DrawCloseButton95(parentMenu-hWnd, hdc, FALSE, item-fState  
MF_GRAYED);
+ReleaseDC(parentMenu-hWnd, hdc);
}
}
 
diff -u cvs/hq/wine/include/nonclient.h wine/include/nonclient.h
--- cvs/hq/wine/include/nonclient.h Tue Mar 12 13:38:48 2002
+++ wine/include/nonclient.hFri Aug  8 20:51:51 2003
@@ -31,6 +31,7 @@ extern LONG NC_HandleNCLButtonDown( HWND
 extern LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam);
 extern LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam );
 extern LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam );
+extern void NC_DrawCloseButton95( HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed );
 extern void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down );
 extern BOOL NC_DrawSysButton95( HWND hwnd, HDC hdc, BOOL down );
 extern void NC_GetSysPopupPos( HWND hwnd, RECT* rect );
diff -u cvs/hq/wine/windows/defwnd.c wine/windows/defwnd.c
--- cvs/hq/wine/windows/defwnd.cThu Jan  9 20:46:26 2003
+++ wine/windows/defwnd.c   Fri Aug  8 21:07:19 2003
@@ -551,8 +551,7 @@ static LRESULT DEFWND_DefWinProc( HWND h
if( wParam == VK_F4 )   /* try to close the window */
{
 HWND top = GetAncestor( hwnd, GA_ROOT );
-if (!(GetClassLongW( top, GCL_STYLE )  CS_NOCLOSE))
-PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
+PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
}
}
else if( wParam == VK_F10 )
diff -u cvs/hq/wine/windows/nonclient.c wine/windows/nonclient.c
--- cvs/hq/wine/windows/nonclient.c Wed Feb 19 21:30:36 2003
+++ wine/windows/nonclient.cFri Aug  8 20:52:31 2003
@@ -974,7 +974,7 @@ NC_DrawSysButton95 (HWND hwnd, HDC hdc, 
  *
  */
 
-static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
+void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
 {
 RECT rect;
 
@@ -1352,7 +1352,7 @@ static void  NC_DrawCaption95(
 
/* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not 
there */
NC_DrawCloseButton95 (hwnd, hdc, FALSE,
- state  MF_DISABLED) || (state  MF_GRAYED)))  
(state != 0x)));
+  (state  (MF_DISABLED | MF_GRAYED))  (state != 
0x));
r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
 
if ((style  WS_MAXIMIZEBOX) || (style  WS_MINIMIZEBOX))