Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Non-client area window functions |
| 3 | * |
| 4 | * Copyright 1994 Alexandre Julliard |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 5 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 19 | */ |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 20 | |
Alexandre Julliard | daa2886 | 2002-04-11 21:54:01 +0000 | [diff] [blame] | 21 | #include "config.h" |
| 22 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 23 | #include "windef.h" |
| 24 | #include "wingdi.h" |
Michael Veksler | 9d14a00 | 1999-05-08 12:40:24 +0000 | [diff] [blame] | 25 | #include "wine/winuser16.h" |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 26 | #include "wownt32.h" |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 27 | #include "win.h" |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 28 | #include "user.h" |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 29 | #include "dce.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 30 | #include "controls.h" |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 31 | #include "cursoricon.h" |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 32 | #include "winpos.h" |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 33 | #include "nonclient.h" |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 34 | #include "shellapi.h" |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 35 | #include "bitmap.h" |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 36 | #include "wine/debug.h" |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 37 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 38 | WINE_DEFAULT_DEBUG_CHANNEL(nonclient); |
| 39 | WINE_DECLARE_DEBUG_CHANNEL(shell); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 40 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 41 | BOOL NC_DrawGrayButton(HDC hdc, int x, int y); |
| 42 | |
Alexandre Julliard | c1d35cc | 2001-01-24 19:47:57 +0000 | [diff] [blame] | 43 | static HBITMAP hbitmapClose; |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 44 | |
Alexandre Julliard | c1d35cc | 2001-01-24 19:47:57 +0000 | [diff] [blame] | 45 | static const BYTE lpGrayMask[] = { 0xAA, 0xA0, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 46 | 0x55, 0x50, |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 47 | 0xAA, 0xA0, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 48 | 0x55, 0x50, |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 49 | 0xAA, 0xA0, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 50 | 0x55, 0x50, |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 51 | 0xAA, 0xA0, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 52 | 0x55, 0x50, |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 53 | 0xAA, 0xA0, |
| 54 | 0x55, 0x50}; |
| 55 | |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 56 | #define SC_ABOUTWINE (SC_SCREENSAVE+1) |
Uwe Bonnes | 3700777 | 1998-11-01 15:07:24 +0000 | [diff] [blame] | 57 | #define SC_PUTMARK (SC_SCREENSAVE+2) |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 58 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 59 | /* Some useful macros */ |
| 60 | #define HAS_DLGFRAME(style,exStyle) \ |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 61 | (((exStyle) & WS_EX_DLGMODALFRAME) || \ |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 62 | (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME))) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 63 | |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 64 | #define HAS_THICKFRAME(style,exStyle) \ |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 65 | (((style) & WS_THICKFRAME) && \ |
Abey George | 48c6eb5 | 1999-09-03 12:33:40 +0000 | [diff] [blame] | 66 | !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME)) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 67 | |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 68 | #define HAS_THINFRAME(style) \ |
| 69 | (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP))) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 70 | |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 71 | #define HAS_BIGFRAME(style,exStyle) \ |
| 72 | (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \ |
| 73 | ((exStyle) & WS_EX_DLGMODALFRAME)) |
Gerard Patel | 5773dad | 1999-06-12 14:45:56 +0000 | [diff] [blame] | 74 | |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 75 | #define HAS_STATICOUTERFRAME(style,exStyle) \ |
| 76 | (((exStyle) & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == \ |
| 77 | WS_EX_STATICEDGE) |
| 78 | |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 79 | #define HAS_ANYFRAME(style,exStyle) \ |
| 80 | (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \ |
| 81 | ((exStyle) & WS_EX_DLGMODALFRAME) || \ |
| 82 | !((style) & (WS_CHILD | WS_POPUP))) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 83 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 84 | #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0)) |
| 85 | |
Sylvain St-Germain | 00bf381 | 1999-07-24 12:11:22 +0000 | [diff] [blame] | 86 | |
| 87 | /*********************************************************************** |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 88 | * NC_AdjustRect |
| 89 | * |
| 90 | * Compute the size of the window rectangle from the size of the |
| 91 | * client rectangle. |
| 92 | */ |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 93 | static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 94 | { |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 95 | if (TWEAK_WineLook > WIN31_LOOK) |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 96 | ERR("Called in Win95 mode. Aiee! Please report this.\n" ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 97 | |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 98 | if(style & WS_ICONIC) return; |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 99 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 100 | if (HAS_THICKFRAME( style, exStyle )) |
| 101 | InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) ); |
| 102 | else if (HAS_DLGFRAME( style, exStyle )) |
| 103 | InflateRect( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) ); |
| 104 | else if (HAS_THINFRAME( style )) |
| 105 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)); |
| 106 | |
| 107 | if ((style & WS_CAPTION) == WS_CAPTION) |
| 108 | rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER); |
| 109 | |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 110 | if (menu) rect->top -= GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYBORDER); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 111 | |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 112 | if (style & WS_VSCROLL) { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 113 | rect->right += GetSystemMetrics(SM_CXVSCROLL) - 1; |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 114 | if(!HAS_ANYFRAME( style, exStyle )) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 115 | rect->right++; |
| 116 | } |
| 117 | |
| 118 | if (style & WS_HSCROLL) { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 119 | rect->bottom += GetSystemMetrics(SM_CYHSCROLL) - 1; |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 120 | if(!HAS_ANYFRAME( style, exStyle )) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 121 | rect->bottom++; |
| 122 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 126 | /****************************************************************************** |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 127 | * NC_AdjustRectOuter95 |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 128 | * |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 129 | * Computes the size of the "outside" parts of the window based on the |
| 130 | * parameters of the client area. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 131 | * |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 132 | + PARAMS |
| 133 | * LPRECT16 rect |
| 134 | * DWORD style |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 135 | * BOOL menu |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 136 | * DWORD exStyle |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 137 | * |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 138 | * NOTES |
| 139 | * "Outer" parts of a window means the whole window frame, caption and |
| 140 | * menu bar. It does not include "inner" parts of the frame like client |
| 141 | * edge, static edge or scroll bars. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 142 | * |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 143 | * Revision history |
| 144 | * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) |
| 145 | * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect |
| 146 | * |
| 147 | * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de) |
| 148 | * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and |
| 149 | * NC_AdjustRectInner95 and added handling of Win95 styles. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 150 | * |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 151 | * 28-Jul-1999 Ove Kåven (ovek@arcticnet.no) |
| 152 | * Streamlined window style checks. |
| 153 | * |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 154 | *****************************************************************************/ |
| 155 | |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 156 | static void |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 157 | NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 158 | { |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 159 | int adjust; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 160 | if(style & WS_ICONIC) return; |
| 161 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 162 | if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 163 | WS_EX_STATICEDGE) |
| 164 | { |
| 165 | adjust = 1; /* for the outer frame always present */ |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | adjust = 0; |
| 170 | if ((exStyle & WS_EX_DLGMODALFRAME) || |
| 171 | (style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */ |
| 172 | } |
| 173 | if (style & WS_THICKFRAME) |
| 174 | adjust += ( GetSystemMetrics (SM_CXFRAME) |
| 175 | - GetSystemMetrics (SM_CXDLGFRAME)); /* The resize border */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 176 | if ((style & (WS_BORDER|WS_DLGFRAME)) || |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 177 | (exStyle & WS_EX_DLGMODALFRAME)) |
| 178 | adjust++; /* The other border */ |
| 179 | |
| 180 | InflateRect (rect, adjust, adjust); |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 181 | |
| 182 | if ((style & WS_CAPTION) == WS_CAPTION) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 183 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 184 | if (exStyle & WS_EX_TOOLWINDOW) |
| 185 | rect->top -= GetSystemMetrics(SM_CYSMCAPTION); |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 186 | else |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 187 | rect->top -= GetSystemMetrics(SM_CYCAPTION); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 188 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 189 | if (menu) rect->top -= GetSystemMetrics(SM_CYMENU); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | |
| 193 | /****************************************************************************** |
| 194 | * NC_AdjustRectInner95 |
| 195 | * |
| 196 | * Computes the size of the "inside" part of the window based on the |
| 197 | * parameters of the client area. |
| 198 | * |
| 199 | + PARAMS |
| 200 | * LPRECT16 rect |
| 201 | * DWORD style |
| 202 | * DWORD exStyle |
| 203 | * |
| 204 | * NOTES |
| 205 | * "Inner" part of a window means the window frame inside of the flat |
| 206 | * window frame. It includes the client edge, the static edge and the |
| 207 | * scroll bars. |
| 208 | * |
| 209 | * Revision history |
| 210 | * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) |
| 211 | * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect |
| 212 | * |
| 213 | * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de) |
| 214 | * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and |
| 215 | * NC_AdjustRectInner95 and added handling of Win95 styles. |
| 216 | * |
| 217 | *****************************************************************************/ |
| 218 | |
| 219 | static void |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 220 | NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 221 | { |
| 222 | if(style & WS_ICONIC) return; |
| 223 | |
| 224 | if (exStyle & WS_EX_CLIENTEDGE) |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 225 | InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 226 | |
Alberto Massari | bf9390e | 2003-01-14 23:41:01 +0000 | [diff] [blame] | 227 | if (style & WS_VSCROLL) |
| 228 | { |
| 229 | if((exStyle & WS_EX_LEFTSCROLLBAR) != 0) |
| 230 | rect->left -= GetSystemMetrics(SM_CXVSCROLL); |
| 231 | else |
| 232 | rect->right += GetSystemMetrics(SM_CXVSCROLL); |
| 233 | } |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 234 | if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 238 | |
| 239 | static HICON NC_IconForWindow( HWND hwnd ) |
| 240 | { |
| 241 | HICON hIcon = (HICON) GetClassLongA( hwnd, GCL_HICONSM ); |
| 242 | if (!hIcon) hIcon = (HICON) GetClassLongA( hwnd, GCL_HICON ); |
| 243 | |
| 244 | /* If there is no hIcon specified and this is a modal dialog, |
| 245 | * get the default one. |
| 246 | */ |
| 247 | if (!hIcon && (GetWindowLongA( hwnd, GWL_STYLE ) & DS_MODALFRAME)) |
| 248 | hIcon = LoadImageA(0, IDI_WINLOGOA, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); |
| 249 | return hIcon; |
| 250 | } |
| 251 | |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 252 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 253 | * DrawCaption (USER32.@) Draws a caption bar |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 254 | * |
| 255 | * PARAMS |
| 256 | * hwnd [I] |
| 257 | * hdc [I] |
| 258 | * lpRect [I] |
| 259 | * uFlags [I] |
| 260 | * |
Eric Kohl | d0b79c0 | 1998-10-24 10:45:42 +0000 | [diff] [blame] | 261 | * RETURNS |
| 262 | * Success: |
| 263 | * Failure: |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 264 | */ |
| 265 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 266 | BOOL WINAPI |
| 267 | DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags) |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 268 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 269 | return DrawCaptionTempA (hwnd, hdc, lpRect, 0, 0, NULL, uFlags & 0x1F); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | |
| 273 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 274 | * DrawCaptionTempA (USER32.@) |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 275 | */ |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 276 | BOOL WINAPI DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont, |
| 277 | HICON hIcon, LPCSTR str, UINT uFlags) |
| 278 | { |
| 279 | LPWSTR strW; |
| 280 | INT len; |
| 281 | BOOL ret = FALSE; |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 282 | |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 283 | if (!(uFlags & DC_TEXT) || !str) |
| 284 | return DrawCaptionTempW( hwnd, hdc, rect, hFont, hIcon, NULL, uFlags ); |
| 285 | |
| 286 | len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); |
| 287 | if ((strW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) |
| 288 | { |
| 289 | MultiByteToWideChar( CP_ACP, 0, str, -1, strW, len ); |
| 290 | ret = DrawCaptionTempW (hwnd, hdc, rect, hFont, hIcon, strW, uFlags); |
| 291 | HeapFree( GetProcessHeap (), 0, strW ); |
| 292 | } |
| 293 | return ret; |
| 294 | } |
| 295 | |
| 296 | |
| 297 | /*********************************************************************** |
| 298 | * DrawCaptionTempW (USER32.@) |
| 299 | */ |
| 300 | BOOL WINAPI DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont, |
| 301 | HICON hIcon, LPCWSTR str, UINT uFlags) |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 302 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 303 | RECT rc = *rect; |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 304 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 305 | TRACE("(%p,%p,%p,%p,%p,%s,%08x)\n", |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 306 | hwnd, hdc, rect, hFont, hIcon, debugstr_w(str), uFlags); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 307 | |
| 308 | /* drawing background */ |
| 309 | if (uFlags & DC_INBUTTON) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 310 | FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE)); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 311 | |
| 312 | if (uFlags & DC_ACTIVE) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 313 | HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ()); |
| 314 | PatBlt (hdc, rc.left, rc.top, |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 315 | rc.right-rc.left, rc.bottom-rc.top, 0xFA0089); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 316 | SelectObject (hdc, hbr); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 317 | } |
| 318 | } |
| 319 | else { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 320 | FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ? |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 321 | COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION)); |
| 322 | } |
| 323 | |
| 324 | |
| 325 | /* drawing icon */ |
| 326 | if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 327 | POINT pt; |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 328 | |
| 329 | pt.x = rc.left + 2; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 330 | pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2; |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 331 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 332 | if (!hIcon) hIcon = NC_IconForWindow(hwnd); |
| 333 | DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON), |
| 334 | GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 335 | rc.left += (rc.bottom - rc.top); |
| 336 | } |
| 337 | |
| 338 | /* drawing text */ |
| 339 | if (uFlags & DC_TEXT) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 340 | HFONT hOldFont; |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 341 | |
| 342 | if (uFlags & DC_INBUTTON) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 343 | SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 344 | else if (uFlags & DC_ACTIVE) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 345 | SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT)); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 346 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 347 | SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT)); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 348 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 349 | SetBkMode (hdc, TRANSPARENT); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 350 | |
| 351 | if (hFont) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 352 | hOldFont = SelectObject (hdc, hFont); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 353 | else { |
Matthew Davison | 3f17416 | 2002-11-24 22:13:26 +0000 | [diff] [blame] | 354 | NONCLIENTMETRICSW nclm; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 355 | HFONT hNewFont; |
Rein Klazes | 6f9b686 | 2002-12-16 22:12:11 +0000 | [diff] [blame] | 356 | nclm.cbSize = sizeof(NONCLIENTMETRICSW); |
Matthew Davison | 3f17416 | 2002-11-24 22:13:26 +0000 | [diff] [blame] | 357 | SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); |
| 358 | hNewFont = CreateFontIndirectW ((uFlags & DC_SMALLCAP) ? |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 359 | &nclm.lfSmCaptionFont : &nclm.lfCaptionFont); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 360 | hOldFont = SelectObject (hdc, hNewFont); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | if (str) |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 364 | DrawTextW (hdc, str, -1, &rc, |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 365 | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT); |
| 366 | else { |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 367 | WCHAR szText[128]; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 368 | INT nLen; |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 369 | nLen = GetWindowTextW (hwnd, szText, 128); |
| 370 | DrawTextW (hdc, szText, nLen, &rc, |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 371 | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT); |
| 372 | } |
| 373 | |
| 374 | if (hFont) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 375 | SelectObject (hdc, hOldFont); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 376 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 377 | DeleteObject (SelectObject (hdc, hOldFont)); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | /* drawing focus ??? */ |
| 381 | if (uFlags & 0x2000) |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 382 | FIXME("undocumented flag (0x2000)!\n"); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 383 | |
| 384 | return 0; |
| 385 | } |
| 386 | |
| 387 | |
| 388 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 389 | * AdjustWindowRect (USER.102) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 390 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 391 | BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 392 | { |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 393 | return AdjustWindowRectEx16( rect, style, menu, 0 ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | |
| 397 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 398 | * AdjustWindowRect (USER32.@) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 399 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 400 | BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 401 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 402 | return AdjustWindowRectEx( rect, style, menu, 0 ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | |
| 406 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 407 | * AdjustWindowRectEx (USER.454) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 408 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 409 | BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style, |
| 410 | BOOL16 menu, DWORD exStyle ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 411 | { |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 412 | RECT rect32; |
| 413 | BOOL ret; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 414 | |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 415 | CONV_RECT16TO32( rect, &rect32 ); |
| 416 | ret = AdjustWindowRectEx( &rect32, style, menu, exStyle ); |
| 417 | CONV_RECT32TO16( &rect32, rect ); |
| 418 | return ret; |
| 419 | } |
| 420 | |
| 421 | |
| 422 | /*********************************************************************** |
| 423 | * AdjustWindowRectEx (USER32.@) |
| 424 | */ |
| 425 | BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle ) |
| 426 | { |
| 427 | /* Correct the window style */ |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 428 | style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 429 | exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 430 | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 431 | if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME; |
| 432 | |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 433 | TRACE("(%ld,%ld)-(%ld,%ld) %08lx %d %08lx\n", |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 434 | rect->left, rect->top, rect->right, rect->bottom, |
| 435 | style, menu, exStyle ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 436 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 437 | if (TWEAK_WineLook == WIN31_LOOK) |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 438 | NC_AdjustRect( rect, style, menu, exStyle ); |
| 439 | else |
| 440 | { |
| 441 | NC_AdjustRectOuter95( rect, style, menu, exStyle ); |
| 442 | NC_AdjustRectInner95( rect, style, exStyle ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 443 | } |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 444 | return TRUE; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 448 | /*********************************************************************** |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 449 | * NC_HandleNCCalcSize |
| 450 | * |
| 451 | * Handle a WM_NCCALCSIZE message. Called from DefWindowProc(). |
| 452 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 453 | LONG NC_HandleNCCalcSize( HWND hwnd, RECT *winRect ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 454 | { |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 455 | RECT tmpRect = { 0, 0, 0, 0 }; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 456 | LONG result = 0; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 457 | LONG cls_style = GetClassLongA(hwnd, GCL_STYLE); |
| 458 | LONG style = GetWindowLongA( hwnd, GWL_STYLE ); |
| 459 | LONG exStyle = GetWindowLongA( hwnd, GWL_EXSTYLE ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 460 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 461 | if (cls_style & CS_VREDRAW) result |= WVR_VREDRAW; |
| 462 | if (cls_style & CS_HREDRAW) result |= WVR_HREDRAW; |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 463 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 464 | if (!IsIconic(hwnd)) |
| 465 | { |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 466 | if (TWEAK_WineLook == WIN31_LOOK) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 467 | NC_AdjustRect( &tmpRect, style, FALSE, exStyle ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 468 | else |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 469 | NC_AdjustRectOuter95( &tmpRect, style, FALSE, exStyle ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 470 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 471 | winRect->left -= tmpRect.left; |
| 472 | winRect->top -= tmpRect.top; |
| 473 | winRect->right -= tmpRect.right; |
| 474 | winRect->bottom -= tmpRect.bottom; |
| 475 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 476 | if (!(style & WS_CHILD) && GetMenu(hwnd)) |
| 477 | { |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 478 | TRACE("Calling GetMenuBarHeight with hwnd %p, width %ld, at (%ld, %ld).\n", |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 479 | hwnd, winRect->right - winRect->left, -tmpRect.left, -tmpRect.top ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 480 | |
| 481 | winRect->top += |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 482 | MENU_GetMenuBarHeight( hwnd, |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 483 | winRect->right - winRect->left, |
| 484 | -tmpRect.left, -tmpRect.top ) + 1; |
| 485 | } |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 486 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 487 | if (TWEAK_WineLook > WIN31_LOOK) { |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 488 | SetRect(&tmpRect, 0, 0, 0, 0); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 489 | NC_AdjustRectInner95 (&tmpRect, style, exStyle); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 490 | winRect->left -= tmpRect.left; |
| 491 | winRect->top -= tmpRect.top; |
| 492 | winRect->right -= tmpRect.right; |
| 493 | winRect->bottom -= tmpRect.bottom; |
| 494 | } |
Mike McCormack | a2bdade | 2000-09-12 23:37:57 +0000 | [diff] [blame] | 495 | |
| 496 | if (winRect->top > winRect->bottom) |
| 497 | winRect->bottom = winRect->top; |
| 498 | |
| 499 | if (winRect->left > winRect->right) |
| 500 | winRect->right = winRect->left; |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 501 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 502 | return result; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | |
| 506 | /*********************************************************************** |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 507 | * NC_GetInsideRect |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 508 | * |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 509 | * Get the 'inside' rectangle of a window, i.e. the whole window rectangle |
| 510 | * but without the borders (if any). |
| 511 | * The rectangle is in window coordinates (for drawing with GetWindowDC()). |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 512 | */ |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 513 | void NC_GetInsideRect( HWND hwnd, RECT *rect ) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 514 | { |
| 515 | WND * wndPtr = WIN_FindWndPtr( hwnd ); |
| 516 | |
| 517 | rect->top = rect->left = 0; |
| 518 | rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left; |
| 519 | rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top; |
| 520 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 521 | if (wndPtr->dwStyle & WS_ICONIC) goto END; |
Alexandre Julliard | 3ed37e0 | 1994-11-07 18:20:42 +0000 | [diff] [blame] | 522 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 523 | /* Remove frame from rectangle */ |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 524 | if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 525 | { |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 526 | InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) ); |
| 527 | } |
| 528 | else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) |
| 529 | { |
| 530 | InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME)); |
| 531 | /* FIXME: this isn't in NC_AdjustRect? why not? */ |
| 532 | if ((TWEAK_WineLook == WIN31_LOOK) && (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 533 | InflateRect( rect, -1, 0 ); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 534 | } |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 535 | else if (HAS_THINFRAME( wndPtr->dwStyle )) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 536 | { |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 537 | InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 538 | } |
| 539 | |
Francis Beaudet | 1cc0a9a | 1999-09-03 15:00:45 +0000 | [diff] [blame] | 540 | /* We have additional border information if the window |
| 541 | * is a child (but not an MDI child) */ |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 542 | if (TWEAK_WineLook != WIN31_LOOK) |
| 543 | { |
| 544 | if ( (wndPtr->dwStyle & WS_CHILD) && |
| 545 | ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) ) |
| 546 | { |
| 547 | if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE) |
| 548 | InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE)); |
| 549 | if (wndPtr->dwExStyle & WS_EX_STATICEDGE) |
| 550 | InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER)); |
| 551 | } |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 552 | } |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 553 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 554 | END: |
| 555 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 556 | return; |
| 557 | } |
| 558 | |
| 559 | |
| 560 | /*********************************************************************** |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 561 | * NC_DoNCHitTest |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 562 | * |
Andreas Mohr | 260f1a1 | 2000-09-22 20:59:29 +0000 | [diff] [blame] | 563 | * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest(). |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 564 | */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 565 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 566 | static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 567 | { |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 568 | RECT rect; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 569 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 570 | TRACE("hwnd=%p pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y ); |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 571 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 572 | GetWindowRect(wndPtr->hwndSelf, &rect ); |
| 573 | if (!PtInRect( &rect, pt )) return HTNOWHERE; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 574 | |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 575 | if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 576 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 577 | /* Check borders */ |
| 578 | if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 579 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 580 | InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) ); |
| 581 | if (!PtInRect( &rect, pt )) |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 582 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 583 | /* Check top sizing border */ |
| 584 | if (pt.y < rect.top) |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 585 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 586 | if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT; |
| 587 | if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT; |
| 588 | return HTTOP; |
| 589 | } |
| 590 | /* Check bottom sizing border */ |
| 591 | if (pt.y >= rect.bottom) |
| 592 | { |
| 593 | if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT; |
| 594 | if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT; |
| 595 | return HTBOTTOM; |
| 596 | } |
| 597 | /* Check left sizing border */ |
| 598 | if (pt.x < rect.left) |
| 599 | { |
| 600 | if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT; |
| 601 | if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT; |
| 602 | return HTLEFT; |
| 603 | } |
| 604 | /* Check right sizing border */ |
| 605 | if (pt.x >= rect.right) |
| 606 | { |
| 607 | if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT; |
| 608 | if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT; |
| 609 | return HTRIGHT; |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 610 | } |
| 611 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 612 | } |
| 613 | else /* No thick frame */ |
| 614 | { |
| 615 | if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) |
| 616 | InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME)); |
| 617 | else if (HAS_THINFRAME( wndPtr->dwStyle )) |
| 618 | InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER)); |
| 619 | if (!PtInRect( &rect, pt )) return HTBORDER; |
| 620 | } |
| 621 | |
| 622 | /* Check caption */ |
| 623 | |
| 624 | if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION) |
| 625 | { |
| 626 | rect.top += GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER); |
| 627 | if (!PtInRect( &rect, pt )) |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 628 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 629 | /* Check system menu */ |
| 630 | if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW)) |
| 631 | rect.left += GetSystemMetrics(SM_CXSIZE); |
| 632 | if (pt.x <= rect.left) return HTSYSMENU; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 633 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 634 | /* Check maximize box */ |
| 635 | if (wndPtr->dwStyle & WS_MAXIMIZEBOX) |
| 636 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 637 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 638 | if (pt.x >= rect.right) return HTMAXBUTTON; |
| 639 | /* Check minimize box */ |
| 640 | if (wndPtr->dwStyle & WS_MINIMIZEBOX) |
| 641 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
| 642 | if (pt.x >= rect.right) return HTMINBUTTON; |
| 643 | return HTCAPTION; |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 644 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 645 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 646 | |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 647 | /* Check client area */ |
| 648 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 649 | ScreenToClient( wndPtr->hwndSelf, &pt ); |
| 650 | GetClientRect( wndPtr->hwndSelf, &rect ); |
| 651 | if (PtInRect( &rect, pt )) return HTCLIENT; |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 652 | |
| 653 | /* Check vertical scroll bar */ |
| 654 | |
| 655 | if (wndPtr->dwStyle & WS_VSCROLL) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 656 | { |
Alberto Massari | bf9390e | 2003-01-14 23:41:01 +0000 | [diff] [blame] | 657 | if((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) |
| 658 | rect.left -= GetSystemMetrics(SM_CXVSCROLL); |
| 659 | else |
| 660 | rect.right += GetSystemMetrics(SM_CXVSCROLL); |
| 661 | if (PtInRect( &rect, pt )) return HTVSCROLL; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 662 | } |
| 663 | |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 664 | /* Check horizontal scroll bar */ |
| 665 | |
| 666 | if (wndPtr->dwStyle & WS_HSCROLL) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 667 | { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 668 | rect.bottom += GetSystemMetrics(SM_CYHSCROLL); |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 669 | if (PtInRect( &rect, pt )) |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 670 | { |
| 671 | /* Check size box */ |
| 672 | if ((wndPtr->dwStyle & WS_VSCROLL) && |
Alberto Massari | bf9390e | 2003-01-14 23:41:01 +0000 | [diff] [blame] | 673 | ((((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) && (pt.x <= rect.left + GetSystemMetrics(SM_CXVSCROLL))) || |
| 674 | (((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) == 0) && (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL))))) |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 675 | return HTSIZE; |
| 676 | return HTHSCROLL; |
| 677 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 678 | } |
| 679 | |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 680 | /* Check menu bar */ |
| 681 | |
| 682 | if (HAS_MENU(wndPtr)) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 683 | { |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 684 | if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right)) |
| 685 | return HTMENU; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 686 | } |
| 687 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 688 | /* Has to return HTNOWHERE if nothing was found |
Francois Boisvert | 5538ec4 | 2000-07-29 00:00:29 +0000 | [diff] [blame] | 689 | Could happen when a window has a customized non client area */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 690 | return HTNOWHERE; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | |
| 694 | /*********************************************************************** |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 695 | * NC_DoNCHitTest95 |
| 696 | * |
| 697 | * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest(). |
| 698 | * |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 699 | * FIXME: Just a modified copy of the Win 3.1 version. |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 700 | */ |
| 701 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 702 | static LONG NC_DoNCHitTest95 (WND *wndPtr, POINT pt ) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 703 | { |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 704 | RECT rect; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 705 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 706 | TRACE("hwnd=%p pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 707 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 708 | GetWindowRect(wndPtr->hwndSelf, &rect ); |
| 709 | if (!PtInRect( &rect, pt )) return HTNOWHERE; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 710 | |
| 711 | if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION; |
| 712 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 713 | /* Check borders */ |
| 714 | if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 715 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 716 | InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) ); |
| 717 | if (!PtInRect( &rect, pt )) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 718 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 719 | /* Check top sizing border */ |
| 720 | if (pt.y < rect.top) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 721 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 722 | if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT; |
| 723 | if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT; |
| 724 | return HTTOP; |
| 725 | } |
| 726 | /* Check bottom sizing border */ |
| 727 | if (pt.y >= rect.bottom) |
| 728 | { |
| 729 | if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT; |
| 730 | if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT; |
| 731 | return HTBOTTOM; |
| 732 | } |
| 733 | /* Check left sizing border */ |
| 734 | if (pt.x < rect.left) |
| 735 | { |
| 736 | if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT; |
| 737 | if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT; |
| 738 | return HTLEFT; |
| 739 | } |
| 740 | /* Check right sizing border */ |
| 741 | if (pt.x >= rect.right) |
| 742 | { |
| 743 | if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT; |
| 744 | if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT; |
| 745 | return HTRIGHT; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 746 | } |
| 747 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 748 | } |
| 749 | else /* No thick frame */ |
| 750 | { |
| 751 | if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) |
| 752 | InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME)); |
| 753 | else if (HAS_THINFRAME( wndPtr->dwStyle )) |
| 754 | InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER)); |
| 755 | if (!PtInRect( &rect, pt )) return HTBORDER; |
| 756 | } |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 757 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 758 | /* Check caption */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 759 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 760 | if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION) |
| 761 | { |
| 762 | if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW) |
| 763 | rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1; |
| 764 | else |
| 765 | rect.top += GetSystemMetrics(SM_CYCAPTION) - 1; |
| 766 | if (!PtInRect( &rect, pt )) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 767 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 768 | /* Check system menu */ |
| 769 | if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW)) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 770 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 771 | if (NC_IconForWindow(wndPtr->hwndSelf)) |
| 772 | rect.left += GetSystemMetrics(SM_CYCAPTION) - 1; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 773 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 774 | if (pt.x < rect.left) return HTSYSMENU; |
| 775 | |
| 776 | /* Check close button */ |
| 777 | if (wndPtr->dwStyle & WS_SYSMENU) |
| 778 | rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1; |
| 779 | if (pt.x > rect.right) return HTCLOSE; |
| 780 | |
| 781 | /* Check maximize box */ |
| 782 | /* In win95 there is automatically a Maximize button when there is a minimize one*/ |
| 783 | if ((wndPtr->dwStyle & WS_MAXIMIZEBOX)|| (wndPtr->dwStyle & WS_MINIMIZEBOX)) |
| 784 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
| 785 | if (pt.x > rect.right) return HTMAXBUTTON; |
| 786 | |
| 787 | /* Check minimize box */ |
| 788 | /* In win95 there is automatically a Maximize button when there is a Maximize one*/ |
| 789 | if ((wndPtr->dwStyle & WS_MINIMIZEBOX)||(wndPtr->dwStyle & WS_MAXIMIZEBOX)) |
| 790 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
| 791 | |
| 792 | if (pt.x > rect.right) return HTMINBUTTON; |
| 793 | return HTCAPTION; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 794 | } |
| 795 | } |
| 796 | |
| 797 | /* Check client area */ |
| 798 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 799 | ScreenToClient( wndPtr->hwndSelf, &pt ); |
| 800 | GetClientRect( wndPtr->hwndSelf, &rect ); |
| 801 | if (PtInRect( &rect, pt )) return HTCLIENT; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 802 | |
| 803 | /* Check vertical scroll bar */ |
| 804 | |
| 805 | if (wndPtr->dwStyle & WS_VSCROLL) |
| 806 | { |
Alberto Massari | bf9390e | 2003-01-14 23:41:01 +0000 | [diff] [blame] | 807 | if((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) |
| 808 | rect.left -= GetSystemMetrics(SM_CXVSCROLL); |
| 809 | else |
| 810 | rect.right += GetSystemMetrics(SM_CXVSCROLL); |
| 811 | if (PtInRect( &rect, pt )) return HTVSCROLL; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | /* Check horizontal scroll bar */ |
| 815 | |
| 816 | if (wndPtr->dwStyle & WS_HSCROLL) |
| 817 | { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 818 | rect.bottom += GetSystemMetrics(SM_CYHSCROLL); |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 819 | if (PtInRect( &rect, pt )) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 820 | { |
| 821 | /* Check size box */ |
| 822 | if ((wndPtr->dwStyle & WS_VSCROLL) && |
Alberto Massari | bf9390e | 2003-01-14 23:41:01 +0000 | [diff] [blame] | 823 | ((((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) && (pt.x <= rect.left + GetSystemMetrics(SM_CXVSCROLL))) || |
| 824 | (((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) == 0) && (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL))))) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 825 | return HTSIZE; |
| 826 | return HTHSCROLL; |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | /* Check menu bar */ |
| 831 | |
| 832 | if (HAS_MENU(wndPtr)) |
| 833 | { |
| 834 | if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right)) |
| 835 | return HTMENU; |
| 836 | } |
| 837 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 838 | /* Has to return HTNOWHERE if nothing was found |
Francois Boisvert | 5538ec4 | 2000-07-29 00:00:29 +0000 | [diff] [blame] | 839 | Could happen when a window has a customized non client area */ |
| 840 | return HTNOWHERE; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | |
| 844 | /*********************************************************************** |
| 845 | * NC_HandleNCHitTest |
| 846 | * |
| 847 | * Handle a WM_NCHITTEST message. Called from DefWindowProc(). |
| 848 | */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 849 | LONG NC_HandleNCHitTest (HWND hwnd , POINT pt) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 850 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 851 | LONG retvalue; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 852 | WND *wndPtr = WIN_FindWndPtr (hwnd); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 853 | |
| 854 | if (!wndPtr) |
| 855 | return HTERROR; |
| 856 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 857 | if (TWEAK_WineLook == WIN31_LOOK) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 858 | retvalue = NC_DoNCHitTest (wndPtr, pt); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 859 | else |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 860 | retvalue = NC_DoNCHitTest95 (wndPtr, pt); |
| 861 | WIN_ReleaseWndPtr(wndPtr); |
| 862 | return retvalue; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | |
| 866 | /*********************************************************************** |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 867 | * NC_DrawSysButton |
| 868 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 869 | void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down ) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 870 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 871 | RECT rect; |
| 872 | HDC hdcMem; |
| 873 | HBITMAP hbitmap; |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 874 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 875 | NC_GetInsideRect( hwnd, &rect ); |
| 876 | hdcMem = CreateCompatibleDC( hdc ); |
| 877 | hbitmap = SelectObject( hdcMem, hbitmapClose ); |
| 878 | BitBlt(hdc, rect.left, rect.top, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE), |
| 879 | hdcMem, (GetWindowLongA(hwnd,GWL_STYLE) & WS_CHILD) ? GetSystemMetrics(SM_CXSIZE) : 0, 0, |
| 880 | down ? NOTSRCCOPY : SRCCOPY ); |
| 881 | SelectObject( hdcMem, hbitmap ); |
| 882 | DeleteDC( hdcMem ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | |
| 886 | /*********************************************************************** |
| 887 | * NC_DrawMaxButton |
| 888 | */ |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 889 | static void NC_DrawMaxButton( HWND hwnd, HDC hdc, BOOL down ) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 890 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 891 | RECT rect; |
Alexandre Julliard | cc2d382 | 2002-01-03 02:35:23 +0000 | [diff] [blame] | 892 | UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 893 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 894 | NC_GetInsideRect( hwnd, &rect ); |
Alexandre Julliard | cc2d382 | 2002-01-03 02:35:23 +0000 | [diff] [blame] | 895 | rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) + 1; |
| 896 | rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1; |
| 897 | rect.top += 1; |
| 898 | rect.right -= 1; |
| 899 | if (down) flags |= DFCS_PUSHED; |
| 900 | DrawFrameControl( hdc, &rect, DFC_CAPTION, flags ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | |
| 904 | /*********************************************************************** |
| 905 | * NC_DrawMinButton |
| 906 | */ |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 907 | static void NC_DrawMinButton( HWND hwnd, HDC hdc, BOOL down ) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 908 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 909 | RECT rect; |
Alexandre Julliard | cc2d382 | 2002-01-03 02:35:23 +0000 | [diff] [blame] | 910 | UINT flags = DFCS_CAPTIONMIN; |
| 911 | DWORD style = GetWindowLongA( hwnd, GWL_STYLE ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 912 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 913 | NC_GetInsideRect( hwnd, &rect ); |
Alexandre Julliard | cc2d382 | 2002-01-03 02:35:23 +0000 | [diff] [blame] | 914 | if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX)) |
| 915 | rect.right -= GetSystemMetrics(SM_CXSIZE) - 2; |
| 916 | rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) + 1; |
| 917 | rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1; |
| 918 | rect.top += 1; |
| 919 | rect.right -= 1; |
| 920 | if (down) flags |= DFCS_PUSHED; |
| 921 | DrawFrameControl( hdc, &rect, DFC_CAPTION, flags ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 922 | } |
| 923 | |
| 924 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 925 | /****************************************************************************** |
| 926 | * |
| 927 | * void NC_DrawSysButton95( |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 928 | * HWND hwnd, |
| 929 | * HDC hdc, |
| 930 | * BOOL down ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 931 | * |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 932 | * Draws the Win95 system icon. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 933 | * |
| 934 | * Revision history |
| 935 | * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) |
| 936 | * Original implementation from NC_DrawSysButton source. |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 937 | * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de) |
| 938 | * Fixed most bugs. |
| 939 | * |
| 940 | *****************************************************************************/ |
| 941 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 942 | BOOL |
| 943 | NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 944 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 945 | HICON hIcon = NC_IconForWindow( hwnd ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 946 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 947 | if (hIcon) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 948 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 949 | RECT rect; |
| 950 | NC_GetInsideRect( hwnd, &rect ); |
Alexandre Julliard | d4304f8 | 2002-08-28 22:25:12 +0000 | [diff] [blame] | 951 | DrawIconEx (hdc, rect.left + 1, rect.top + 1, hIcon, |
| 952 | GetSystemMetrics(SM_CXSIZE) - 1, |
| 953 | GetSystemMetrics(SM_CYSIZE) - 1, 0, 0, DI_NORMAL); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 954 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 955 | return (hIcon != 0); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | |
| 959 | /****************************************************************************** |
| 960 | * |
| 961 | * void NC_DrawCloseButton95( |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 962 | * HWND hwnd, |
| 963 | * HDC hdc, |
| 964 | * BOOL down, |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 965 | * BOOL bGrayed ) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 966 | * |
| 967 | * Draws the Win95 close button. |
| 968 | * |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 969 | * If bGrayed is true, then draw a disabled Close button |
| 970 | * |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 971 | * Revision history |
| 972 | * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de) |
| 973 | * Original implementation from NC_DrawSysButton95 source. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 974 | * |
| 975 | *****************************************************************************/ |
| 976 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 977 | static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 978 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 979 | RECT rect; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 980 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 981 | NC_GetInsideRect( hwnd, &rect ); |
| 982 | |
| 983 | /* A tool window has a smaller Close button */ |
| 984 | if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 985 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 986 | INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */ |
| 987 | INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */ |
| 988 | INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION); |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 989 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 990 | rect.top = rect.top + (iCaptionHeight - 1 - iBmpHeight) / 2; |
| 991 | rect.left = rect.right - (iCaptionHeight + 1 + iBmpWidth) / 2; |
| 992 | rect.bottom = rect.top + iBmpHeight; |
| 993 | rect.right = rect.left + iBmpWidth; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 994 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 995 | else |
| 996 | { |
| 997 | rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) - 1; |
| 998 | rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1; |
| 999 | rect.top += 2; |
| 1000 | rect.right -= 2; |
| 1001 | } |
| 1002 | DrawFrameControl( hdc, &rect, DFC_CAPTION, |
| 1003 | (DFCS_CAPTIONCLOSE | |
| 1004 | (down ? DFCS_PUSHED : 0) | |
| 1005 | (bGrayed ? DFCS_INACTIVE : 0)) ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1006 | } |
| 1007 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1008 | /****************************************************************************** |
Alexandre Julliard | c1d35cc | 2001-01-24 19:47:57 +0000 | [diff] [blame] | 1009 | * NC_DrawMaxButton95 |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1010 | * |
| 1011 | * Draws the maximize button for Win95 style windows. |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1012 | * If bGrayed is true, then draw a disabled Maximize button |
Alexandre Julliard | c1d35cc | 2001-01-24 19:47:57 +0000 | [diff] [blame] | 1013 | */ |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1014 | static void NC_DrawMaxButton95(HWND hwnd,HDC hdc,BOOL down, BOOL bGrayed) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1015 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1016 | RECT rect; |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1017 | UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1018 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1019 | NC_GetInsideRect( hwnd, &rect ); |
| 1020 | if (GetWindowLongA( hwnd, GWL_STYLE) & WS_SYSMENU) |
| 1021 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
| 1022 | rect.left = rect.right - GetSystemMetrics(SM_CXSIZE); |
| 1023 | rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1; |
| 1024 | rect.top += 2; |
| 1025 | rect.right -= 2; |
| 1026 | if (down) flags |= DFCS_PUSHED; |
| 1027 | if (bGrayed) flags |= DFCS_INACTIVE; |
| 1028 | DrawFrameControl( hdc, &rect, DFC_CAPTION, flags ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1031 | /****************************************************************************** |
Alexandre Julliard | c1d35cc | 2001-01-24 19:47:57 +0000 | [diff] [blame] | 1032 | * NC_DrawMinButton95 |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1033 | * |
| 1034 | * Draws the minimize button for Win95 style windows. |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1035 | * If bGrayed is true, then draw a disabled Minimize button |
Alexandre Julliard | c1d35cc | 2001-01-24 19:47:57 +0000 | [diff] [blame] | 1036 | */ |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1037 | static void NC_DrawMinButton95(HWND hwnd,HDC hdc,BOOL down, BOOL bGrayed) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1038 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1039 | RECT rect; |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1040 | UINT flags = DFCS_CAPTIONMIN; |
| 1041 | DWORD style = GetWindowLongA( hwnd, GWL_STYLE ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1042 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1043 | NC_GetInsideRect( hwnd, &rect ); |
| 1044 | if (style & WS_SYSMENU) |
| 1045 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
| 1046 | if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX)) |
| 1047 | rect.right -= GetSystemMetrics(SM_CXSIZE) - 2; |
| 1048 | rect.left = rect.right - GetSystemMetrics(SM_CXSIZE); |
| 1049 | rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1; |
| 1050 | rect.top += 2; |
| 1051 | rect.right -= 2; |
| 1052 | if (down) flags |= DFCS_PUSHED; |
| 1053 | if (bGrayed) flags |= DFCS_INACTIVE; |
| 1054 | DrawFrameControl( hdc, &rect, DFC_CAPTION, flags ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1055 | } |
| 1056 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 1057 | /*********************************************************************** |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1058 | * NC_DrawFrame |
| 1059 | * |
| 1060 | * Draw a window frame inside the given rectangle, and update the rectangle. |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1061 | * The correct pen for the frame must be selected in the DC. |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1062 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1063 | static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame, |
| 1064 | BOOL active ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1065 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1066 | INT width, height; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1067 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1068 | if (TWEAK_WineLook != WIN31_LOOK) |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1069 | ERR("Called in Win95 mode. Aiee! Please report this.\n" ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1070 | |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1071 | if (dlgFrame) |
| 1072 | { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1073 | width = GetSystemMetrics(SM_CXDLGFRAME) - 1; |
| 1074 | height = GetSystemMetrics(SM_CYDLGFRAME) - 1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1075 | SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 1076 | COLOR_INACTIVECAPTION) ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1077 | } |
| 1078 | else |
| 1079 | { |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 1080 | width = GetSystemMetrics(SM_CXFRAME) - 2; |
| 1081 | height = GetSystemMetrics(SM_CYFRAME) - 2; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1082 | SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER : |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 1083 | COLOR_INACTIVEBORDER) ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | /* Draw frame */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1087 | PatBlt( hdc, rect->left, rect->top, |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1088 | rect->right - rect->left, height, PATCOPY ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1089 | PatBlt( hdc, rect->left, rect->top, |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1090 | width, rect->bottom - rect->top, PATCOPY ); |
Randy Weems | 0bc73c7 | 1999-03-25 15:49:11 +0000 | [diff] [blame] | 1091 | PatBlt( hdc, rect->left, rect->bottom - 1, |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1092 | rect->right - rect->left, -height, PATCOPY ); |
Randy Weems | 0bc73c7 | 1999-03-25 15:49:11 +0000 | [diff] [blame] | 1093 | PatBlt( hdc, rect->right - 1, rect->top, |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1094 | -width, rect->bottom - rect->top, PATCOPY ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1095 | |
| 1096 | if (dlgFrame) |
| 1097 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1098 | InflateRect( rect, -width, -height ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1099 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1100 | else |
| 1101 | { |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 1102 | INT decYOff = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXSIZE) - 1; |
| 1103 | INT decXOff = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYSIZE) - 1; |
Huw D M Davies | 2d617be | 1998-12-08 09:14:09 +0000 | [diff] [blame] | 1104 | |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1105 | /* Draw inner rectangle */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1106 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1107 | SelectObject( hdc, GetStockObject(NULL_BRUSH) ); |
| 1108 | Rectangle( hdc, rect->left + width, rect->top + height, |
Huw D M Davies | 2d617be | 1998-12-08 09:14:09 +0000 | [diff] [blame] | 1109 | rect->right - width , rect->bottom - height ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1110 | |
| 1111 | /* Draw the decorations */ |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1112 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1113 | MoveToEx( hdc, rect->left, rect->top + decYOff, NULL ); |
| 1114 | LineTo( hdc, rect->left + width, rect->top + decYOff ); |
| 1115 | MoveToEx( hdc, rect->right - 1, rect->top + decYOff, NULL ); |
| 1116 | LineTo( hdc, rect->right - width - 1, rect->top + decYOff ); |
| 1117 | MoveToEx( hdc, rect->left, rect->bottom - decYOff, NULL ); |
| 1118 | LineTo( hdc, rect->left + width, rect->bottom - decYOff ); |
| 1119 | MoveToEx( hdc, rect->right - 1, rect->bottom - decYOff, NULL ); |
| 1120 | LineTo( hdc, rect->right - width - 1, rect->bottom - decYOff ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1121 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1122 | MoveToEx( hdc, rect->left + decXOff, rect->top, NULL ); |
| 1123 | LineTo( hdc, rect->left + decXOff, rect->top + height); |
| 1124 | MoveToEx( hdc, rect->left + decXOff, rect->bottom - 1, NULL ); |
| 1125 | LineTo( hdc, rect->left + decXOff, rect->bottom - height - 1 ); |
| 1126 | MoveToEx( hdc, rect->right - decXOff, rect->top, NULL ); |
| 1127 | LineTo( hdc, rect->right - decXOff, rect->top + height ); |
| 1128 | MoveToEx( hdc, rect->right - decXOff, rect->bottom - 1, NULL ); |
| 1129 | LineTo( hdc, rect->right - decXOff, rect->bottom - height - 1 ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1130 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1131 | InflateRect( rect, -width - 1, -height - 1 ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1132 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1136 | /****************************************************************************** |
| 1137 | * |
| 1138 | * void NC_DrawFrame95( |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 1139 | * HDC hdc, |
| 1140 | * RECT *rect, |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1141 | * BOOL active, |
| 1142 | * DWORD style, |
| 1143 | * DWORD exStyle ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1144 | * |
| 1145 | * Draw a window frame inside the given rectangle, and update the rectangle. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1146 | * |
| 1147 | * Bugs |
| 1148 | * Many. First, just what IS a frame in Win95? Note that the 3D look |
| 1149 | * on the outer edge is handled by NC_DoNCPaint95. As is the inner |
| 1150 | * edge. The inner rectangle just inside the frame is handled by the |
| 1151 | * Caption code. |
| 1152 | * |
| 1153 | * In short, for most people, this function should be a nop (unless |
| 1154 | * you LIKE thick borders in Win95/NT4.0 -- I've been working with |
| 1155 | * them lately, but just to get this code right). Even so, it doesn't |
| 1156 | * appear to be so. It's being worked on... |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1157 | * |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1158 | * Revision history |
| 1159 | * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) |
| 1160 | * Original implementation (based on NC_DrawFrame) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 1161 | * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de) |
| 1162 | * Some minor fixes. |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 1163 | * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no) |
| 1164 | * Fixed a fix or something. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1165 | * |
| 1166 | *****************************************************************************/ |
| 1167 | |
| 1168 | static void NC_DrawFrame95( |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1169 | HDC hdc, |
| 1170 | RECT *rect, |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1171 | BOOL active, |
| 1172 | DWORD style, |
| 1173 | DWORD exStyle) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1174 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1175 | INT width, height; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1176 | |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1177 | /* Firstly the "thick" frame */ |
| 1178 | if (style & WS_THICKFRAME) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1179 | { |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1180 | width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXDLGFRAME); |
| 1181 | height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYDLGFRAME); |
| 1182 | |
| 1183 | SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER : |
| 1184 | COLOR_INACTIVEBORDER) ); |
| 1185 | /* Draw frame */ |
| 1186 | PatBlt( hdc, rect->left, rect->top, |
| 1187 | rect->right - rect->left, height, PATCOPY ); |
| 1188 | PatBlt( hdc, rect->left, rect->top, |
| 1189 | width, rect->bottom - rect->top, PATCOPY ); |
| 1190 | PatBlt( hdc, rect->left, rect->bottom - 1, |
| 1191 | rect->right - rect->left, -height, PATCOPY ); |
| 1192 | PatBlt( hdc, rect->right - 1, rect->top, |
| 1193 | -width, rect->bottom - rect->top, PATCOPY ); |
| 1194 | |
| 1195 | InflateRect( rect, -width, -height ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1196 | } |
| 1197 | |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1198 | /* Now the other bit of the frame */ |
| 1199 | if ((style & (WS_BORDER|WS_DLGFRAME)) || |
| 1200 | (exStyle & WS_EX_DLGMODALFRAME)) |
| 1201 | { |
| 1202 | width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE); |
| 1203 | height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE); |
| 1204 | /* This should give a value of 1 that should also work for a border */ |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 1205 | |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1206 | SelectObject( hdc, GetSysColorBrush( |
| 1207 | (exStyle & (WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE)) ? |
| 1208 | COLOR_3DFACE : |
| 1209 | (exStyle & WS_EX_STATICEDGE) ? |
| 1210 | COLOR_WINDOWFRAME : |
| 1211 | (style & (WS_DLGFRAME|WS_THICKFRAME)) ? |
| 1212 | COLOR_3DFACE : |
| 1213 | /* else */ |
| 1214 | COLOR_WINDOWFRAME)); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1215 | |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1216 | /* Draw frame */ |
| 1217 | PatBlt( hdc, rect->left, rect->top, |
| 1218 | rect->right - rect->left, height, PATCOPY ); |
| 1219 | PatBlt( hdc, rect->left, rect->top, |
| 1220 | width, rect->bottom - rect->top, PATCOPY ); |
| 1221 | PatBlt( hdc, rect->left, rect->bottom - 1, |
| 1222 | rect->right - rect->left, -height, PATCOPY ); |
| 1223 | PatBlt( hdc, rect->right - 1, rect->top, |
| 1224 | -width, rect->bottom - rect->top, PATCOPY ); |
| 1225 | |
| 1226 | InflateRect( rect, -width, -height ); |
| 1227 | } |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1228 | } |
| 1229 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 1230 | |
| 1231 | /*********************************************************************** |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1232 | * NC_DrawCaption |
| 1233 | * |
| 1234 | * Draw the window caption. |
| 1235 | * The correct pen for the window frame must be selected in the DC. |
| 1236 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1237 | static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, |
| 1238 | DWORD style, BOOL active ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1239 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1240 | RECT r = *rect; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1241 | char buffer[256]; |
| 1242 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 1243 | if (!hbitmapClose) |
| 1244 | { |
Alexandre Julliard | cc2d382 | 2002-01-03 02:35:23 +0000 | [diff] [blame] | 1245 | if (!(hbitmapClose = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_OLD_CLOSE) ))) return; |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 1246 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1247 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1248 | if (GetWindowLongA( hwnd, GWL_EXSTYLE) & WS_EX_DLGMODALFRAME) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1249 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1250 | HBRUSH hbrushOld = SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW) ); |
| 1251 | PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY ); |
| 1252 | PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY ); |
| 1253 | PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY ); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1254 | r.left++; |
| 1255 | r.right--; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1256 | SelectObject( hdc, hbrushOld ); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1257 | } |
Alexandre Julliard | b0efe28 | 2000-08-04 04:18:04 +0000 | [diff] [blame] | 1258 | MoveToEx( hdc, r.left, r.bottom, NULL ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1259 | LineTo( hdc, r.right, r.bottom ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1260 | |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1261 | if (style & WS_SYSMENU) |
| 1262 | { |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1263 | NC_DrawSysButton( hwnd, hdc, FALSE ); |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1264 | r.left += GetSystemMetrics(SM_CXSIZE) + 1; |
Alexandre Julliard | b0efe28 | 2000-08-04 04:18:04 +0000 | [diff] [blame] | 1265 | MoveToEx( hdc, r.left - 1, r.top, NULL ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1266 | LineTo( hdc, r.left - 1, r.bottom ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1267 | } |
Alexandre Julliard | cc2d382 | 2002-01-03 02:35:23 +0000 | [diff] [blame] | 1268 | FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION) ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1269 | if (style & WS_MAXIMIZEBOX) |
| 1270 | { |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1271 | NC_DrawMaxButton( hwnd, hdc, FALSE ); |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1272 | r.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1273 | } |
| 1274 | if (style & WS_MINIMIZEBOX) |
| 1275 | { |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1276 | NC_DrawMinButton( hwnd, hdc, FALSE ); |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1277 | r.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1278 | } |
| 1279 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1280 | if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1281 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1282 | if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) ); |
| 1283 | else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) ); |
| 1284 | SetBkMode( hdc, TRANSPARENT ); |
| 1285 | DrawTextA( hdc, buffer, -1, &r, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1286 | DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1287 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1288 | } |
| 1289 | |
| 1290 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1291 | /****************************************************************************** |
| 1292 | * |
| 1293 | * NC_DrawCaption95( |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 1294 | * HDC hdc, |
| 1295 | * RECT *rect, |
| 1296 | * HWND hwnd, |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1297 | * DWORD style, |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 1298 | * BOOL active ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1299 | * |
| 1300 | * Draw the window caption for Win95 style windows. |
| 1301 | * The correct pen for the window frame must be selected in the DC. |
| 1302 | * |
| 1303 | * Bugs |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 1304 | * Hey, a function that finally works! Well, almost. |
| 1305 | * It's being worked on. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1306 | * |
| 1307 | * Revision history |
| 1308 | * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) |
| 1309 | * Original implementation. |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 1310 | * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de) |
| 1311 | * Some minor fixes. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1312 | * |
| 1313 | *****************************************************************************/ |
| 1314 | |
| 1315 | static void NC_DrawCaption95( |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1316 | HDC hdc, |
| 1317 | RECT *rect, |
| 1318 | HWND hwnd, |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1319 | DWORD style, |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 1320 | DWORD exStyle, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1321 | BOOL active ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1322 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1323 | RECT r = *rect; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1324 | char buffer[256]; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1325 | HPEN hPrevPen; |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1326 | HMENU hSysMenu; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1327 | |
Alexandre Julliard | 4344c36 | 2002-05-20 18:15:28 +0000 | [diff] [blame] | 1328 | hPrevPen = SelectObject( hdc, SYSCOLOR_GetPen( |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1329 | ((exStyle & (WS_EX_STATICEDGE|WS_EX_CLIENTEDGE| |
| 1330 | WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) ? |
| 1331 | COLOR_WINDOWFRAME : COLOR_3DFACE) ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1332 | MoveToEx( hdc, r.left, r.bottom - 1, NULL ); |
| 1333 | LineTo( hdc, r.right, r.bottom - 1 ); |
| 1334 | SelectObject( hdc, hPrevPen ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1335 | r.bottom--; |
| 1336 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1337 | FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 1338 | COLOR_INACTIVECAPTION) ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1339 | |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 1340 | if ((style & WS_SYSMENU) && !(exStyle & WS_EX_TOOLWINDOW)) { |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1341 | if (NC_DrawSysButton95 (hwnd, hdc, FALSE)) |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1342 | r.left += GetSystemMetrics(SM_CYCAPTION) - 1; |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 1343 | } |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1344 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1345 | if (style & WS_SYSMENU) |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1346 | { |
| 1347 | UINT state; |
| 1348 | |
| 1349 | /* Go get the sysmenu */ |
| 1350 | hSysMenu = GetSystemMenu(hwnd, FALSE); |
| 1351 | state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND); |
| 1352 | |
| 1353 | /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1354 | NC_DrawCloseButton95 (hwnd, hdc, FALSE, |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1355 | ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF))); |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1356 | r.right -= GetSystemMetrics(SM_CYCAPTION) - 1; |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1357 | |
| 1358 | if ((style & WS_MAXIMIZEBOX) || (style & WS_MINIMIZEBOX)) |
| 1359 | { |
| 1360 | /* In win95 the two buttons are always there */ |
| 1361 | /* But if the menu item is not in the menu they're disabled*/ |
| 1362 | |
| 1363 | NC_DrawMaxButton95( hwnd, hdc, FALSE, (!(style & WS_MAXIMIZEBOX))); |
| 1364 | r.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1365 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1366 | NC_DrawMinButton95( hwnd, hdc, FALSE, (!(style & WS_MINIMIZEBOX))); |
| 1367 | r.right -= GetSystemMetrics(SM_CXSIZE) + 1; |
| 1368 | } |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1369 | } |
| 1370 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1371 | if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) { |
| 1372 | NONCLIENTMETRICSA nclm; |
| 1373 | HFONT hFont, hOldFont; |
| 1374 | nclm.cbSize = sizeof(NONCLIENTMETRICSA); |
| 1375 | SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 1376 | if (exStyle & WS_EX_TOOLWINDOW) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1377 | hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont); |
Eric Kohl | 8e517b5 | 1998-10-11 13:06:35 +0000 | [diff] [blame] | 1378 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1379 | hFont = CreateFontIndirectA (&nclm.lfCaptionFont); |
| 1380 | hOldFont = SelectObject (hdc, hFont); |
| 1381 | if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) ); |
| 1382 | else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) ); |
| 1383 | SetBkMode( hdc, TRANSPARENT ); |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 1384 | r.left += 2; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1385 | DrawTextA( hdc, buffer, -1, &r, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1386 | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1387 | DeleteObject (SelectObject (hdc, hOldFont)); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | |
| 1392 | |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1393 | /*********************************************************************** |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1394 | * NC_DoNCPaint |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1395 | * |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 1396 | * Paint the non-client area. clip is currently unused. |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1397 | */ |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1398 | static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1399 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1400 | HDC hdc; |
| 1401 | RECT rect; |
| 1402 | BOOL active; |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1403 | WND *wndPtr; |
| 1404 | DWORD dwStyle, dwExStyle; |
| 1405 | WORD flags; |
| 1406 | RECT rectClient, rectWindow; |
| 1407 | int has_menu; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1408 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1409 | if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return; |
| 1410 | has_menu = HAS_MENU(wndPtr); |
| 1411 | dwStyle = wndPtr->dwStyle; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1412 | dwExStyle = wndPtr->dwExStyle; |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1413 | flags = wndPtr->flags; |
| 1414 | rectClient = wndPtr->rectClient; |
| 1415 | rectWindow = wndPtr->rectWindow; |
| 1416 | WIN_ReleasePtr( wndPtr ); |
| 1417 | |
| 1418 | if ( dwStyle & WS_MINIMIZE || |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1419 | !WIN_IsWindowDrawable( hwnd, 0 )) return; /* Nothing to do */ |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1420 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1421 | active = flags & WIN_NCACTIVATED; |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 1422 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1423 | TRACE("%p %d\n", hwnd, active ); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 1424 | |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1425 | if (!(hdc = GetDCEx( hwnd, (clip > (HRGN)1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW | |
| 1426 | ((clip > (HRGN)1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN): 0) ))) return; |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 1427 | |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1428 | if (ExcludeVisRect16( HDC_16(hdc), rectClient.left-rectWindow.left, |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1429 | rectClient.top-rectWindow.top, |
| 1430 | rectClient.right-rectWindow.left, |
| 1431 | rectClient.bottom-rectWindow.top ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1432 | == NULLREGION) |
| 1433 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1434 | ReleaseDC( hwnd, hdc ); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1435 | return; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1436 | } |
| 1437 | |
| 1438 | rect.top = rect.left = 0; |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1439 | rect.right = rectWindow.right - rectWindow.left; |
| 1440 | rect.bottom = rectWindow.bottom - rectWindow.top; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1441 | |
Alexandre Julliard | 4344c36 | 2002-05-20 18:15:28 +0000 | [diff] [blame] | 1442 | SelectObject( hdc, SYSCOLOR_GetPen(COLOR_WINDOWFRAME) ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1443 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1444 | if (HAS_ANYFRAME( dwStyle, dwExStyle )) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1445 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1446 | SelectObject( hdc, GetStockObject(NULL_BRUSH) ); |
| 1447 | Rectangle( hdc, 0, 0, rect.right, rect.bottom ); |
| 1448 | InflateRect( &rect, -1, -1 ); |
| 1449 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1450 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1451 | if (HAS_THICKFRAME( dwStyle, dwExStyle )) |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1452 | NC_DrawFrame(hdc, &rect, FALSE, active ); |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1453 | else if (HAS_DLGFRAME( dwStyle, dwExStyle )) |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1454 | NC_DrawFrame( hdc, &rect, TRUE, active ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1455 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1456 | if ((dwStyle & WS_CAPTION) == WS_CAPTION) |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1457 | { |
| 1458 | RECT r = rect; |
| 1459 | r.bottom = rect.top + GetSystemMetrics(SM_CYSIZE); |
| 1460 | rect.top += GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYBORDER); |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1461 | NC_DrawCaption( hdc, &r, hwnd, dwStyle, active ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1462 | } |
| 1463 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1464 | if (has_menu) |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 1465 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1466 | RECT r = rect; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1467 | r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); /* default height */ |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 1468 | rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ); |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 1469 | } |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1470 | |
Alexandre Julliard | ecc3712 | 1994-11-22 16:31:29 +0000 | [diff] [blame] | 1471 | /* Draw the scroll-bars */ |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1472 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1473 | if (dwStyle & WS_VSCROLL) |
Alex Korobka | d208584 | 1998-10-18 10:37:46 +0000 | [diff] [blame] | 1474 | SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE ); |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1475 | if (dwStyle & WS_HSCROLL) |
Alex Korobka | d208584 | 1998-10-18 10:37:46 +0000 | [diff] [blame] | 1476 | SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE ); |
Alexandre Julliard | ecc3712 | 1994-11-22 16:31:29 +0000 | [diff] [blame] | 1477 | |
| 1478 | /* Draw the "size-box" */ |
| 1479 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1480 | if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL)) |
Alexandre Julliard | ecc3712 | 1994-11-22 16:31:29 +0000 | [diff] [blame] | 1481 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1482 | RECT r = rect; |
Alberto Massari | bf9390e | 2003-01-14 23:41:01 +0000 | [diff] [blame] | 1483 | if((dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) |
| 1484 | r.right = r.left + GetSystemMetrics(SM_CXVSCROLL) + 1; |
| 1485 | else |
| 1486 | r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1487 | r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1; |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 1488 | if(wndPtr->dwStyle & WS_BORDER) { |
| 1489 | r.left++; |
| 1490 | r.top++; |
| 1491 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1492 | FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1493 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1494 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1495 | ReleaseDC( hwnd, hdc ); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1496 | } |
| 1497 | |
| 1498 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1499 | /****************************************************************************** |
| 1500 | * |
| 1501 | * void NC_DoNCPaint95( |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1502 | * HWND hwnd, |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 1503 | * HRGN clip, |
| 1504 | * BOOL suppress_menupaint ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1505 | * |
| 1506 | * Paint the non-client area for Win95 windows. The clip region is |
| 1507 | * currently ignored. |
| 1508 | * |
| 1509 | * Bugs |
| 1510 | * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \ |
| 1511 | * misc/tweak.c controls/menu.c # :-) |
| 1512 | * |
| 1513 | * Revision history |
| 1514 | * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) |
| 1515 | * Original implementation |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 1516 | * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de) |
| 1517 | * Fixed some bugs. |
Ove Kaaven | 60c78f1 | 1999-07-03 15:40:29 +0000 | [diff] [blame] | 1518 | * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no) |
| 1519 | * Streamlined window style checks. |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1520 | * |
| 1521 | *****************************************************************************/ |
| 1522 | |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 1523 | static void NC_DoNCPaint95( |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1524 | HWND hwnd, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1525 | HRGN clip, |
| 1526 | BOOL suppress_menupaint ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1527 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1528 | HDC hdc; |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1529 | RECT rfuzz, rect, rectClip; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1530 | BOOL active; |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1531 | WND *wndPtr; |
| 1532 | DWORD dwStyle, dwExStyle; |
| 1533 | WORD flags; |
| 1534 | RECT rectClient, rectWindow; |
| 1535 | int has_menu; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1536 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1537 | if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return; |
| 1538 | has_menu = HAS_MENU(wndPtr); |
| 1539 | dwStyle = wndPtr->dwStyle; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1540 | dwExStyle = wndPtr->dwExStyle; |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1541 | flags = wndPtr->flags; |
| 1542 | rectClient = wndPtr->rectClient; |
| 1543 | rectWindow = wndPtr->rectWindow; |
| 1544 | WIN_ReleasePtr( wndPtr ); |
| 1545 | |
| 1546 | if ( dwStyle & WS_MINIMIZE || |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1547 | !WIN_IsWindowDrawable( hwnd, 0 )) return; /* Nothing to do */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1548 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1549 | active = flags & WIN_NCACTIVATED; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1550 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1551 | TRACE("%p %d\n", hwnd, active ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1552 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1553 | /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in |
| 1554 | the call to GetDCEx implying that it is allowed not to use it either. |
| 1555 | However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN) |
| 1556 | will cause clipRgn to be deleted after ReleaseDC(). |
| 1557 | Now, how is the "system" supposed to tell what happened? |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1558 | */ |
| 1559 | |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1560 | if (!(hdc = GetDCEx( hwnd, (clip > (HRGN)1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW | |
| 1561 | ((clip > (HRGN)1) ?(DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0) ))) return; |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1562 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1563 | |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1564 | if (ExcludeVisRect16( HDC_16(hdc), rectClient.left-rectWindow.left, |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1565 | rectClient.top-rectWindow.top, |
| 1566 | rectClient.right-rectWindow.left, |
| 1567 | rectClient.bottom-rectWindow.top ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1568 | == NULLREGION) |
| 1569 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1570 | ReleaseDC( hwnd, hdc ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1571 | return; |
| 1572 | } |
| 1573 | |
| 1574 | rect.top = rect.left = 0; |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1575 | rect.right = rectWindow.right - rectWindow.left; |
| 1576 | rect.bottom = rectWindow.bottom - rectWindow.top; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1577 | |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1578 | if( clip > (HRGN)1 ) |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1579 | GetRgnBox( clip, &rectClip ); |
| 1580 | else |
| 1581 | { |
| 1582 | clip = 0; |
| 1583 | rectClip = rect; |
| 1584 | } |
| 1585 | |
Alexandre Julliard | 4344c36 | 2002-05-20 18:15:28 +0000 | [diff] [blame] | 1586 | SelectObject( hdc, SYSCOLOR_GetPen(COLOR_WINDOWFRAME) ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1587 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1588 | if (HAS_STATICOUTERFRAME(dwStyle, dwExStyle)) { |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1589 | DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST); |
| 1590 | } |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1591 | else if (HAS_BIGFRAME( dwStyle, dwExStyle)) { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1592 | DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST); |
| 1593 | } |
Bill Medland | cbfbf2a | 2001-07-20 18:36:49 +0000 | [diff] [blame] | 1594 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1595 | NC_DrawFrame95(hdc, &rect, active, dwStyle, dwExStyle ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1596 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1597 | if ((dwStyle & WS_CAPTION) == WS_CAPTION) |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1598 | { |
| 1599 | RECT r = rect; |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1600 | if (dwExStyle & WS_EX_TOOLWINDOW) { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1601 | r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION); |
| 1602 | rect.top += GetSystemMetrics(SM_CYSMCAPTION); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1603 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1604 | else { |
| 1605 | r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION); |
| 1606 | rect.top += GetSystemMetrics(SM_CYCAPTION); |
| 1607 | } |
| 1608 | if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) ) |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1609 | NC_DrawCaption95 (hdc, &r, hwnd, dwStyle, |
| 1610 | dwExStyle, active); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1611 | } |
| 1612 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1613 | if (has_menu) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1614 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1615 | RECT r = rect; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1616 | r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1617 | |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1618 | TRACE("Calling DrawMenuBar with rect (%ld, %ld)-(%ld, %ld)\n", |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1619 | r.left, r.top, r.right, r.bottom); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1620 | |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1621 | rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1622 | } |
| 1623 | |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1624 | TRACE("After MenuBar, rect is (%ld, %ld)-(%ld, %ld).\n", |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1625 | rect.left, rect.top, rect.right, rect.bottom ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1626 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1627 | if (dwExStyle & WS_EX_CLIENTEDGE) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1628 | DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1629 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1630 | /* Draw the scroll-bars */ |
| 1631 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1632 | if (dwStyle & WS_VSCROLL) |
Alex Korobka | d208584 | 1998-10-18 10:37:46 +0000 | [diff] [blame] | 1633 | SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE ); |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1634 | if (dwStyle & WS_HSCROLL) |
Alex Korobka | d208584 | 1998-10-18 10:37:46 +0000 | [diff] [blame] | 1635 | SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1636 | |
| 1637 | /* Draw the "size-box" */ |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1638 | if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL)) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1639 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1640 | RECT r = rect; |
Alberto Massari | bf9390e | 2003-01-14 23:41:01 +0000 | [diff] [blame] | 1641 | if((dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) |
| 1642 | r.right = r.left + GetSystemMetrics(SM_CXVSCROLL) + 1; |
| 1643 | else |
| 1644 | r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1645 | r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1646 | FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1647 | } |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1648 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1649 | ReleaseDC( hwnd, hdc ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1650 | } |
| 1651 | |
| 1652 | |
| 1653 | |
Alexandre Julliard | 988ca97 | 1994-06-21 16:15:21 +0000 | [diff] [blame] | 1654 | |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1655 | /*********************************************************************** |
| 1656 | * NC_HandleNCPaint |
| 1657 | * |
| 1658 | * Handle a WM_NCPAINT message. Called from DefWindowProc(). |
| 1659 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1660 | LONG NC_HandleNCPaint( HWND hwnd , HRGN clip) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1661 | { |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1662 | DWORD dwStyle = GetWindowLongW( hwnd, GWL_STYLE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1663 | |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1664 | if( dwStyle & WS_VISIBLE ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1665 | { |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1666 | if( dwStyle & WS_MINIMIZE ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1667 | WINPOS_RedrawIconTitle( hwnd ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1668 | else if (TWEAK_WineLook == WIN31_LOOK) |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1669 | NC_DoNCPaint( hwnd, clip, FALSE ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1670 | else |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1671 | NC_DoNCPaint95( hwnd, clip, FALSE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1672 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1673 | return 0; |
| 1674 | } |
| 1675 | |
| 1676 | |
| 1677 | /*********************************************************************** |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1678 | * NC_HandleNCActivate |
| 1679 | * |
| 1680 | * Handle a WM_NCACTIVATE message. Called from DefWindowProc(). |
| 1681 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1682 | LONG NC_HandleNCActivate( HWND hwnd, WPARAM wParam ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1683 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1684 | WND* wndPtr = WIN_FindWndPtr( hwnd ); |
| 1685 | |
Dmitry Timoshkov | d1e648f | 2001-06-04 02:49:22 +0000 | [diff] [blame] | 1686 | /* Lotus Notes draws menu descriptions in the caption of its main |
| 1687 | * window. When it wants to restore original "system" view, it just |
| 1688 | * sends WM_NCACTIVATE message to itself. Any optimizations here in |
| 1689 | * attempt to minimize redrawings lead to a not restored caption. |
| 1690 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1691 | if (wndPtr) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1692 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1693 | if (wParam) wndPtr->flags |= WIN_NCACTIVATED; |
| 1694 | else wndPtr->flags &= ~WIN_NCACTIVATED; |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1695 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1696 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1697 | if (IsIconic(hwnd)) WINPOS_RedrawIconTitle( hwnd ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1698 | else if (TWEAK_WineLook == WIN31_LOOK) |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1699 | NC_DoNCPaint( hwnd, (HRGN)1, FALSE ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1700 | else |
Gerard Patel | e9b4fd1 | 2001-11-30 23:13:22 +0000 | [diff] [blame] | 1701 | NC_DoNCPaint95( hwnd, (HRGN)1, FALSE ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1702 | } |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1703 | return TRUE; |
| 1704 | } |
| 1705 | |
| 1706 | |
| 1707 | /*********************************************************************** |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1708 | * NC_HandleSetCursor |
| 1709 | * |
| 1710 | * Handle a WM_SETCURSOR message. Called from DefWindowProc(). |
| 1711 | */ |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 1712 | LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1713 | { |
Dmitry Timoshkov | 5474aa9 | 2002-04-09 01:37:06 +0000 | [diff] [blame] | 1714 | hwnd = WIN_GetFullHandle( (HWND)wParam ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1715 | |
| 1716 | switch(LOWORD(lParam)) |
| 1717 | { |
| 1718 | case HTERROR: |
| 1719 | { |
| 1720 | WORD msg = HIWORD( lParam ); |
| 1721 | if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) || |
| 1722 | (msg == WM_RBUTTONDOWN)) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1723 | MessageBeep(0); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1724 | } |
| 1725 | break; |
| 1726 | |
| 1727 | case HTCLIENT: |
| 1728 | { |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 1729 | HCURSOR hCursor = (HCURSOR)GetClassLongA(hwnd, GCL_HCURSOR); |
Gerard Patel | 5773dad | 1999-06-12 14:45:56 +0000 | [diff] [blame] | 1730 | if(hCursor) { |
Alexandre Julliard | d44e495 | 2001-08-20 18:09:39 +0000 | [diff] [blame] | 1731 | SetCursor(hCursor); |
Gerard Patel | 5773dad | 1999-06-12 14:45:56 +0000 | [diff] [blame] | 1732 | return TRUE; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1733 | } |
Gerard Patel | 5773dad | 1999-06-12 14:45:56 +0000 | [diff] [blame] | 1734 | return FALSE; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1735 | } |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1736 | |
| 1737 | case HTLEFT: |
| 1738 | case HTRIGHT: |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 1739 | return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZEWEA ) ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1740 | |
| 1741 | case HTTOP: |
| 1742 | case HTBOTTOM: |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 1743 | return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENSA ) ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1744 | |
| 1745 | case HTTOPLEFT: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1746 | case HTBOTTOMRIGHT: |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 1747 | return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENWSEA ) ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1748 | |
| 1749 | case HTTOPRIGHT: |
| 1750 | case HTBOTTOMLEFT: |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 1751 | return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENESWA ) ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1752 | } |
| 1753 | |
| 1754 | /* Default cursor: arrow */ |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 1755 | return (LONG)SetCursor( LoadCursorA( 0, IDC_ARROWA ) ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1756 | } |
| 1757 | |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1758 | /*********************************************************************** |
| 1759 | * NC_GetSysPopupPos |
| 1760 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1761 | void NC_GetSysPopupPos( HWND hwnd, RECT* rect ) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1762 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1763 | if (IsIconic(hwnd)) GetWindowRect( hwnd, rect ); |
| 1764 | else |
| 1765 | { |
| 1766 | WND *wndPtr = WIN_FindWndPtr( hwnd ); |
| 1767 | if (!wndPtr) return; |
| 1768 | |
| 1769 | NC_GetInsideRect( hwnd, rect ); |
| 1770 | OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top); |
| 1771 | if (wndPtr->dwStyle & WS_CHILD) |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1772 | ClientToScreen( GetParent(hwnd), (POINT *)rect ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1773 | if (TWEAK_WineLook == WIN31_LOOK) { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1774 | rect->right = rect->left + GetSystemMetrics(SM_CXSIZE); |
| 1775 | rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1776 | } |
| 1777 | else { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 1778 | rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1; |
| 1779 | rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1780 | } |
| 1781 | WIN_ReleaseWndPtr( wndPtr ); |
| 1782 | } |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1783 | } |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1784 | |
| 1785 | /*********************************************************************** |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1786 | * NC_TrackMinMaxBox95 |
| 1787 | * |
| 1788 | * Track a mouse button press on the minimize or maximize box. |
| 1789 | * |
| 1790 | * The big difference between 3.1 and 95 is the disabled button state. |
| 1791 | * In win95 the system button can be disabled, so it can ignore the mouse |
| 1792 | * event. |
| 1793 | * |
| 1794 | */ |
| 1795 | static void NC_TrackMinMaxBox95( HWND hwnd, WORD wParam ) |
| 1796 | { |
| 1797 | MSG msg; |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1798 | HDC hdc = GetWindowDC( hwnd ); |
| 1799 | BOOL pressed = TRUE; |
| 1800 | UINT state; |
| 1801 | DWORD wndStyle = GetWindowLongA( hwnd, GWL_STYLE); |
| 1802 | HMENU hSysMenu = GetSystemMenu(hwnd, FALSE); |
| 1803 | |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1804 | void (*paintButton)(HWND, HDC, BOOL, BOOL); |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1805 | |
| 1806 | if (wParam == HTMINBUTTON) |
| 1807 | { |
| 1808 | /* If the style is not present, do nothing */ |
| 1809 | if (!(wndStyle & WS_MINIMIZEBOX)) |
| 1810 | return; |
| 1811 | |
| 1812 | /* Check if the sysmenu item for minimize is there */ |
| 1813 | state = GetMenuState(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1814 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1815 | paintButton = &NC_DrawMinButton95; |
| 1816 | } |
| 1817 | else |
| 1818 | { |
| 1819 | /* If the style is not present, do nothing */ |
| 1820 | if (!(wndStyle & WS_MAXIMIZEBOX)) |
| 1821 | return; |
| 1822 | |
| 1823 | /* Check if the sysmenu item for maximize is there */ |
| 1824 | state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1825 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1826 | paintButton = &NC_DrawMaxButton95; |
| 1827 | } |
| 1828 | |
| 1829 | SetCapture( hwnd ); |
| 1830 | |
| 1831 | (*paintButton)( hwnd, hdc, TRUE, FALSE); |
| 1832 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1833 | while(1) |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1834 | { |
| 1835 | BOOL oldstate = pressed; |
Alexandre Julliard | bfb4a23 | 2001-08-06 18:05:47 +0000 | [diff] [blame] | 1836 | |
| 1837 | if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break; |
| 1838 | if (CallMsgFilterW( &msg, MSGF_MAX )) continue; |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1839 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1840 | if(msg.message == WM_LBUTTONUP) |
| 1841 | break; |
| 1842 | |
| 1843 | if(msg.message != WM_MOUSEMOVE) |
| 1844 | continue; |
| 1845 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1846 | pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam); |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1847 | if (pressed != oldstate) |
| 1848 | (*paintButton)( hwnd, hdc, pressed, FALSE); |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1849 | } |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1850 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1851 | if(pressed) |
| 1852 | (*paintButton)(hwnd, hdc, FALSE, FALSE); |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1853 | |
| 1854 | ReleaseCapture(); |
| 1855 | ReleaseDC( hwnd, hdc ); |
| 1856 | |
| 1857 | /* If the item minimize or maximize of the sysmenu are not there */ |
| 1858 | /* or if the style is not present, do nothing */ |
| 1859 | if ((!pressed) || (state == 0xFFFFFFFF)) |
| 1860 | return; |
| 1861 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1862 | if (wParam == HTMINBUTTON) |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1863 | SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) ); |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1864 | else |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1865 | SendMessageA( hwnd, WM_SYSCOMMAND, |
| 1866 | IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) ); |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1867 | } |
| 1868 | |
| 1869 | /*********************************************************************** |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1870 | * NC_TrackMinMaxBox |
| 1871 | * |
| 1872 | * Track a mouse button press on the minimize or maximize box. |
| 1873 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1874 | static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1875 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1876 | MSG msg; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1877 | HDC hdc = GetWindowDC( hwnd ); |
| 1878 | BOOL pressed = TRUE; |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 1879 | void (*paintButton)(HWND, HDC, BOOL); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1880 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1881 | SetCapture( hwnd ); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1882 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1883 | if (wParam == HTMINBUTTON) |
| 1884 | paintButton = &NC_DrawMinButton; |
| 1885 | else |
| 1886 | paintButton = &NC_DrawMaxButton; |
| 1887 | |
| 1888 | (*paintButton)( hwnd, hdc, TRUE); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1889 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1890 | while(1) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1891 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1892 | BOOL oldstate = pressed; |
Alexandre Julliard | bfb4a23 | 2001-08-06 18:05:47 +0000 | [diff] [blame] | 1893 | |
| 1894 | if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break; |
| 1895 | if (CallMsgFilterW( &msg, MSGF_MAX )) continue; |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1896 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1897 | if(msg.message == WM_LBUTTONUP) |
| 1898 | break; |
| 1899 | |
| 1900 | if(msg.message != WM_MOUSEMOVE) |
| 1901 | continue; |
| 1902 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1903 | pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1904 | if (pressed != oldstate) |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1905 | (*paintButton)( hwnd, hdc, pressed); |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1906 | } |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1907 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1908 | if(pressed) |
| 1909 | (*paintButton)( hwnd, hdc, FALSE); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1910 | |
| 1911 | ReleaseCapture(); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1912 | ReleaseDC( hwnd, hdc ); |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1913 | |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1914 | if (!pressed) return; |
| 1915 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1916 | if (wParam == HTMINBUTTON) |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1917 | SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) ); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1918 | else |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1919 | SendMessageA( hwnd, WM_SYSCOMMAND, |
| 1920 | IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) ); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1921 | } |
| 1922 | |
| 1923 | |
| 1924 | /*********************************************************************** |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1925 | * NC_TrackCloseButton95 |
| 1926 | * |
| 1927 | * Track a mouse button press on the Win95 close button. |
| 1928 | */ |
| 1929 | static void |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1930 | NC_TrackCloseButton95 (HWND hwnd, WORD wParam) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1931 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1932 | MSG msg; |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1933 | HDC hdc; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1934 | BOOL pressed = TRUE; |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1935 | HMENU hSysMenu = GetSystemMenu(hwnd, FALSE); |
| 1936 | UINT state; |
| 1937 | |
| 1938 | if(hSysMenu == 0) |
| 1939 | return; |
| 1940 | |
| 1941 | state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1942 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1943 | /* If the item close of the sysmenu is disabled or not there do nothing */ |
| 1944 | if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF)) |
| 1945 | return; |
| 1946 | |
| 1947 | hdc = GetWindowDC( hwnd ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1948 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1949 | SetCapture( hwnd ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1950 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1951 | NC_DrawCloseButton95 (hwnd, hdc, TRUE, FALSE); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1952 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1953 | while(1) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1954 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1955 | BOOL oldstate = pressed; |
Alexandre Julliard | bfb4a23 | 2001-08-06 18:05:47 +0000 | [diff] [blame] | 1956 | |
| 1957 | if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break; |
| 1958 | if (CallMsgFilterW( &msg, MSGF_MAX )) continue; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1959 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1960 | if(msg.message == WM_LBUTTONUP) |
| 1961 | break; |
| 1962 | |
| 1963 | if(msg.message != WM_MOUSEMOVE) |
| 1964 | continue; |
| 1965 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1966 | pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1967 | if (pressed != oldstate) |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 1968 | NC_DrawCloseButton95 (hwnd, hdc, pressed, FALSE); |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1969 | } |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1970 | |
Dmitry Timoshkov | 63ba91d | 2000-10-15 00:22:29 +0000 | [diff] [blame] | 1971 | if(pressed) |
| 1972 | NC_DrawCloseButton95 (hwnd, hdc, FALSE, FALSE); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1973 | |
| 1974 | ReleaseCapture(); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1975 | ReleaseDC( hwnd, hdc ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1976 | if (!pressed) return; |
| 1977 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1978 | SendMessageA( hwnd, WM_SYSCOMMAND, SC_CLOSE, MAKELONG(msg.pt.x,msg.pt.y) ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1979 | } |
| 1980 | |
| 1981 | |
| 1982 | /*********************************************************************** |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1983 | * NC_TrackScrollBar |
| 1984 | * |
| 1985 | * Track a mouse button press on the horizontal or vertical scroll-bar. |
| 1986 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1987 | static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt ) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1988 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1989 | INT scrollbar; |
Alexandre Julliard | ecc3712 | 1994-11-22 16:31:29 +0000 | [diff] [blame] | 1990 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1991 | if ((wParam & 0xfff0) == SC_HSCROLL) |
| 1992 | { |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 1993 | if ((wParam & 0x0f) != HTHSCROLL) return; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1994 | scrollbar = SB_HORZ; |
| 1995 | } |
| 1996 | else /* SC_VSCROLL */ |
| 1997 | { |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 1998 | if ((wParam & 0x0f) != HTVSCROLL) return; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1999 | scrollbar = SB_VERT; |
| 2000 | } |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2001 | SCROLL_TrackScrollBar( hwnd, scrollbar, pt ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 2002 | } |
| 2003 | |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2004 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 2005 | /*********************************************************************** |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2006 | * NC_HandleNCLButtonDown |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 2007 | * |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2008 | * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc(). |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 2009 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2010 | LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 2011 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2012 | LONG style = GetWindowLongA( hwnd, GWL_STYLE ); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 2013 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2014 | switch(wParam) /* Hit test */ |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 2015 | { |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2016 | case HTCAPTION: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2017 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2018 | HWND top = GetAncestor( hwnd, GA_ROOT ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2019 | |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 2020 | if (FOCUS_MouseActivate( top ) || (GetActiveWindow() == top)) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2021 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam ); |
| 2022 | break; |
| 2023 | } |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2024 | |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 2025 | case HTSYSMENU: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2026 | if( style & WS_SYSMENU ) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 2027 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2028 | if( !(style & WS_MINIMIZE) ) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 2029 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2030 | HDC hDC = GetWindowDC(hwnd); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2031 | if (TWEAK_WineLook == WIN31_LOOK) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 2032 | NC_DrawSysButton( hwnd, hDC, TRUE ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2033 | else |
| 2034 | NC_DrawSysButton95( hwnd, hDC, TRUE ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2035 | ReleaseDC( hwnd, hDC ); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 2036 | } |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 2037 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam ); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 2038 | } |
| 2039 | break; |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2040 | |
| 2041 | case HTMENU: |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 2042 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2043 | break; |
| 2044 | |
| 2045 | case HTHSCROLL: |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 2046 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2047 | break; |
| 2048 | |
| 2049 | case HTVSCROLL: |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 2050 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2051 | break; |
| 2052 | |
| 2053 | case HTMINBUTTON: |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2054 | case HTMAXBUTTON: |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2055 | if (TWEAK_WineLook == WIN31_LOOK) |
| 2056 | NC_TrackMinMaxBox( hwnd, wParam ); |
| 2057 | else |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2058 | NC_TrackMinMaxBox95( hwnd, wParam ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2059 | break; |
| 2060 | |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 2061 | case HTCLOSE: |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2062 | if (TWEAK_WineLook >= WIN95_LOOK) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 2063 | NC_TrackCloseButton95 (hwnd, wParam); |
| 2064 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2065 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2066 | case HTLEFT: |
| 2067 | case HTRIGHT: |
| 2068 | case HTTOP: |
| 2069 | case HTTOPLEFT: |
| 2070 | case HTTOPRIGHT: |
| 2071 | case HTBOTTOM: |
| 2072 | case HTBOTTOMLEFT: |
| 2073 | case HTBOTTOMRIGHT: |
Duane Clark | 5d35bc7 | 2003-02-18 23:24:57 +0000 | [diff] [blame] | 2074 | /* Old comment: |
| 2075 | * "make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU" |
| 2076 | * This was previously done by setting wParam=SC_SIZE + wParam - 2 |
| 2077 | */ |
| 2078 | /* But that is not what WinNT does. Instead it sends this. This |
| 2079 | * is easy to differentiate from HTSYSMENU, because HTSYSMENU adds |
| 2080 | * SC_MOUSEMENU into wParam. |
| 2081 | */ |
| 2082 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - (HTLEFT-WMSZ_LEFT), lParam); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2083 | break; |
| 2084 | |
| 2085 | case HTBORDER: |
| 2086 | break; |
| 2087 | } |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2088 | return 0; |
| 2089 | } |
| 2090 | |
| 2091 | |
| 2092 | /*********************************************************************** |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2093 | * NC_HandleNCLButtonDblClk |
| 2094 | * |
| 2095 | * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc(). |
| 2096 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2097 | LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2098 | { |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2099 | /* |
| 2100 | * if this is an icon, send a restore since we are handling |
| 2101 | * a double click |
| 2102 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2103 | if (IsIconic(hwnd)) |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2104 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2105 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam ); |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 2106 | return 0; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2107 | } |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2108 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2109 | switch(wParam) /* Hit test */ |
| 2110 | { |
| 2111 | case HTCAPTION: |
Alexandre Julliard | 902da69 | 1995-11-05 14:39:02 +0000 | [diff] [blame] | 2112 | /* stop processing if WS_MAXIMIZEBOX is missing */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2113 | if (GetWindowLongA( hwnd, GWL_STYLE ) & WS_MAXIMIZEBOX) |
| 2114 | SendMessageW( hwnd, WM_SYSCOMMAND, |
| 2115 | IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, lParam ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2116 | break; |
| 2117 | |
| 2118 | case HTSYSMENU: |
Alexandre Julliard | d44e495 | 2001-08-20 18:09:39 +0000 | [diff] [blame] | 2119 | if (!(GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE)) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2120 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 2121 | break; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 2122 | |
| 2123 | case HTHSCROLL: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2124 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 2125 | break; |
| 2126 | |
| 2127 | case HTVSCROLL: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 2128 | SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 2129 | break; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 2130 | } |
| 2131 | return 0; |
| 2132 | } |
| 2133 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2134 | |
| 2135 | /*********************************************************************** |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2136 | * NC_HandleSysCommand |
| 2137 | * |
| 2138 | * Handle a WM_SYSCOMMAND message. Called from DefWindowProc(). |
| 2139 | */ |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2140 | LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2141 | { |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2142 | TRACE("Handling WM_SYSCOMMAND %x %lx\n", wParam, lParam ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2143 | |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2144 | switch (wParam & 0xfff0) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2145 | { |
| 2146 | case SC_SIZE: |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2147 | case SC_MOVE: |
Alexandre Julliard | 3abeae8 | 2001-05-09 17:21:04 +0000 | [diff] [blame] | 2148 | if (USER_Driver.pSysCommandSizeMove) |
| 2149 | USER_Driver.pSysCommandSizeMove( hwnd, wParam ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2150 | break; |
| 2151 | |
| 2152 | case SC_MINIMIZE: |
Noomen Hamza | d1a1f7d | 1999-10-24 00:02:27 +0000 | [diff] [blame] | 2153 | if (hwnd == GetForegroundWindow()) |
| 2154 | ShowOwnedPopups(hwnd,FALSE); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2155 | ShowWindow( hwnd, SW_MINIMIZE ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2156 | break; |
| 2157 | |
| 2158 | case SC_MAXIMIZE: |
Noomen Hamza | d1a1f7d | 1999-10-24 00:02:27 +0000 | [diff] [blame] | 2159 | if (IsIconic(hwnd) && hwnd == GetForegroundWindow()) |
| 2160 | ShowOwnedPopups(hwnd,TRUE); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2161 | ShowWindow( hwnd, SW_MAXIMIZE ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2162 | break; |
| 2163 | |
| 2164 | case SC_RESTORE: |
Noomen Hamza | d1a1f7d | 1999-10-24 00:02:27 +0000 | [diff] [blame] | 2165 | if (IsIconic(hwnd) && hwnd == GetForegroundWindow()) |
| 2166 | ShowOwnedPopups(hwnd,TRUE); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2167 | ShowWindow( hwnd, SW_RESTORE ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2168 | break; |
| 2169 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2170 | case SC_CLOSE: |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 2171 | return SendMessageA( hwnd, WM_CLOSE, 0, 0 ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2172 | |
| 2173 | case SC_VSCROLL: |
| 2174 | case SC_HSCROLL: |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2175 | { |
| 2176 | POINT pt; |
| 2177 | pt.x = SLOWORD(lParam); |
| 2178 | pt.y = SHIWORD(lParam); |
| 2179 | NC_TrackScrollBar( hwnd, wParam, pt ); |
| 2180 | } |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2181 | break; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 2182 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2183 | case SC_MOUSEMENU: |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2184 | { |
| 2185 | POINT pt; |
| 2186 | pt.x = SLOWORD(lParam); |
| 2187 | pt.y = SHIWORD(lParam); |
| 2188 | MENU_TrackMouseMenuBar( hwnd, wParam & 0x000F, pt ); |
| 2189 | } |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 2190 | break; |
| 2191 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2192 | case SC_KEYMENU: |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2193 | MENU_TrackKbdMenuBar( hwnd, wParam, LOWORD(lParam) ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 2194 | break; |
Alexandre Julliard | b662e11 | 2001-10-16 21:52:26 +0000 | [diff] [blame] | 2195 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2196 | case SC_TASKLIST: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2197 | WinExec( "taskman.exe", SW_SHOWNORMAL ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2198 | break; |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 2199 | |
| 2200 | case SC_SCREENSAVE: |
| 2201 | if (wParam == SC_ABOUTWINE) |
Alexandre Julliard | 563561e | 2000-01-24 05:46:47 +0000 | [diff] [blame] | 2202 | { |
| 2203 | HMODULE hmodule = LoadLibraryA( "shell32.dll" ); |
| 2204 | if (hmodule) |
| 2205 | { |
| 2206 | FARPROC aboutproc = GetProcAddress( hmodule, "ShellAboutA" ); |
Alexandre Julliard | daa2886 | 2002-04-11 21:54:01 +0000 | [diff] [blame] | 2207 | if (aboutproc) aboutproc( hwnd, PACKAGE_NAME, PACKAGE_STRING, 0 ); |
Alexandre Julliard | 563561e | 2000-01-24 05:46:47 +0000 | [diff] [blame] | 2208 | FreeLibrary( hmodule ); |
| 2209 | } |
| 2210 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2211 | else |
Uwe Bonnes | 3700777 | 1998-11-01 15:07:24 +0000 | [diff] [blame] | 2212 | if (wParam == SC_PUTMARK) |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 2213 | TRACE_(shell)("Mark requested by user\n"); |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 2214 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2215 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 2216 | case SC_HOTKEY: |
| 2217 | case SC_ARRANGE: |
| 2218 | case SC_NEXTWINDOW: |
| 2219 | case SC_PREVWINDOW: |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2220 | FIXME("unimplemented!\n"); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 2221 | break; |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2222 | } |
| 2223 | return 0; |
| 2224 | } |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2225 | |
| 2226 | /************************************************************* |
| 2227 | * NC_DrawGrayButton |
| 2228 | * |
| 2229 | * Stub for the grayed button of the caption |
| 2230 | * |
| 2231 | *************************************************************/ |
| 2232 | |
| 2233 | BOOL NC_DrawGrayButton(HDC hdc, int x, int y) |
| 2234 | { |
| 2235 | HBITMAP hMaskBmp; |
Mike McCormack | 2d106a5 | 2002-11-13 19:43:53 +0000 | [diff] [blame] | 2236 | HDC hdcMask; |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2237 | HBRUSH hOldBrush; |
| 2238 | |
| 2239 | hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2240 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2241 | if(hMaskBmp == 0) |
| 2242 | return FALSE; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2243 | |
Mike McCormack | 2d106a5 | 2002-11-13 19:43:53 +0000 | [diff] [blame] | 2244 | hdcMask = CreateCompatibleDC (0); |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2245 | SelectObject (hdcMask, hMaskBmp); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2246 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2247 | /* Draw the grayed bitmap using the mask */ |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 2248 | hOldBrush = SelectObject (hdc, (HGDIOBJ)RGB(128, 128, 128)); |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2249 | BitBlt (hdc, x, y, 12, 10, |
| 2250 | hdcMask, 0, 0, 0xB8074A); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2251 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2252 | /* Clean up */ |
| 2253 | SelectObject (hdc, hOldBrush); |
| 2254 | DeleteObject(hMaskBmp); |
| 2255 | DeleteDC (hdcMask); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2256 | |
Pascal Lessard | d814bb6 | 1999-07-31 13:02:02 +0000 | [diff] [blame] | 2257 | return TRUE; |
| 2258 | } |