1 /* $Id: defwnd.c,v 1.4 2002/07/04 19:56:34 dwelch Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS user32.dll
5 * FILE: lib/user32/windows/window.c
6 * PURPOSE: Window management
7 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
9 * 06-06-2001 CSH Created
12 /* INCLUDES ******************************************************************/
18 #include <user32/wininternal.h>
20 /* GLOBALS *******************************************************************/
22 static HBITMAP hbitmapClose
;
23 static HBITMAP hbitmapMinimize
;
24 static HBITMAP hbitmapMinimizeD
;
25 static HBITMAP hbitmapMaximize
;
26 static HBITMAP hbitmapMaximizeD
;
27 static HBITMAP hbitmapRestore
;
28 static HBITMAP hbitmapRestoreD
;
30 /* FUNCTIONS *****************************************************************/
33 DefFrameProcA(HWND hWnd
,
43 DefFrameProcW(HWND hWnd
,
54 DefWndRedrawIconTitle(HWND hWnd
)
59 UserHasAnyFrameStyle(ULONG Style
, ULONG ExStyle
)
61 return((Style
& (WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
)) ||
62 (ExStyle
& WS_EX_DLGMODALFRAME
) ||
63 (!(Style
& (WS_CHILD
| WS_POPUP
))));
67 UserHasDlgFrameStyle(ULONG Style
, ULONG ExStyle
)
69 return((ExStyle
& WS_EX_DLGMODALFRAME
) ||
70 ((Style
& WS_DLGFRAME
) && (!(Style
& WS_THICKFRAME
))));
74 UserHasThickFrameStyle(ULONG Style
, ULONG ExStyle
)
76 return((Style
& WS_THICKFRAME
) &&
77 (!((Style
& (WS_DLGFRAME
| WS_BORDER
)) == WS_DLGFRAME
)));
81 UserHasThinFrameStyle(ULONG Style
, ULONG ExStyle
)
83 return((Style
& WS_BORDER
) ||
84 (!(Style
& (WS_CHILD
| WS_POPUP
))));
88 UserHasBigFrameStyle(ULONG Style
, ULONG ExStyle
)
90 return((Style
& (WS_THICKFRAME
| WS_DLGFRAME
)) ||
91 (ExStyle
& WS_EX_DLGMODALFRAME
));
94 static void UserGetInsideRectNC( HWND hwnd
, RECT
*rect
)
100 Style
= GetWindowLong(hwnd
, GWL_STYLE
);
101 ExStyle
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
102 GetWindowRect(hwnd
, &WindowRect
);
103 rect
->top
= rect
->left
= 0;
104 rect
->right
= WindowRect
.right
- WindowRect
.left
;
105 rect
->bottom
= WindowRect
.bottom
- WindowRect
.top
;
107 if (Style
& WS_ICONIC
)
112 /* Remove frame from rectangle */
113 if (UserHasThickFrameStyle(Style
, ExStyle
))
115 InflateRect( rect
, -GetSystemMetrics(SM_CXFRAME
),
116 -GetSystemMetrics(SM_CYFRAME
) );
120 if (UserHasDlgFrameStyle(Style
, ExStyle
))
122 InflateRect( rect
, -GetSystemMetrics(SM_CXDLGFRAME
),
123 -GetSystemMetrics(SM_CYDLGFRAME
));
124 /* FIXME: this isn't in NC_AdjustRect? why not? */
125 if (ExStyle
& WS_EX_DLGMODALFRAME
)
126 InflateRect( rect
, -1, 0 );
130 if (UserHasThinFrameStyle(Style
, ExStyle
))
132 InflateRect( rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
) );
138 void UserDrawSysButton( HWND hwnd
, HDC hdc
, BOOL down
)
145 Style
= GetWindowLong(hwnd
, GWL_STYLE
);
146 UserGetInsideRectNC( hwnd
, &rect
);
147 hdcMem
= CreateCompatibleDC( hdc
);
148 hbitmap
= SelectObject( hdcMem
, hbitmapClose
);
149 BitBlt(hdc
, rect
.left
, rect
.top
, GetSystemMetrics(SM_CXSIZE
), GetSystemMetrics(SM_CYSIZE
),
150 hdcMem
, (Style
& WS_CHILD
) ? GetSystemMetrics(SM_CXSIZE
) : 0, 0,
151 down
? NOTSRCCOPY
: SRCCOPY
);
152 SelectObject( hdcMem
, hbitmap
);
156 static void UserDrawMaxButton( HWND hwnd
, HDC hdc
, BOOL down
)
161 UserGetInsideRectNC( hwnd
, &rect
);
162 hdcMem
= CreateCompatibleDC( hdc
);
163 SelectObject( hdcMem
, (IsZoomed(hwnd
)
164 ? (down
? hbitmapRestoreD
: hbitmapRestore
)
165 : (down
? hbitmapMaximizeD
: hbitmapMaximize
)) );
166 BitBlt( hdc
, rect
.right
- GetSystemMetrics(SM_CXSIZE
) - 1, rect
.top
,
167 GetSystemMetrics(SM_CXSIZE
) + 1, GetSystemMetrics(SM_CYSIZE
), hdcMem
, 0, 0,
172 static void UserDrawMinButton( HWND hwnd
, HDC hdc
, BOOL down
)
177 UserGetInsideRectNC(hwnd
, &rect
);
178 hdcMem
= CreateCompatibleDC(hdc
);
179 SelectObject(hdcMem
, (down
? hbitmapMinimizeD
: hbitmapMinimize
));
180 if (GetWindowLong(hwnd
, GWL_STYLE
) & WS_MAXIMIZEBOX
)
182 rect
.right
-= GetSystemMetrics(SM_CXSIZE
)+1;
184 BitBlt( hdc
, rect
.right
- GetSystemMetrics(SM_CXSIZE
) - 1, rect
.top
,
185 GetSystemMetrics(SM_CXSIZE
) + 1, GetSystemMetrics(SM_CYSIZE
),
191 static void UserDrawCaptionNC( HDC hdc
, RECT
*rect
, HWND hwnd
,
192 DWORD style
, BOOL active
)
199 if (!(hbitmapClose
= LoadBitmapW( 0, MAKEINTRESOURCE(OBM_CLOSE
) )))
203 hbitmapMinimize
= LoadBitmapW( 0, MAKEINTRESOURCE(OBM_REDUCE
) );
204 hbitmapMinimizeD
= LoadBitmapW( 0, MAKEINTRESOURCE(OBM_REDUCED
) );
205 hbitmapMaximize
= LoadBitmapW( 0, MAKEINTRESOURCE(OBM_ZOOM
) );
206 hbitmapMaximizeD
= LoadBitmapW( 0, MAKEINTRESOURCE(OBM_ZOOMD
) );
207 hbitmapRestore
= LoadBitmapW( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
208 hbitmapRestoreD
= LoadBitmapW( 0, MAKEINTRESOURCE(OBM_RESTORED
) );
211 if (GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_DLGMODALFRAME
)
213 HBRUSH hbrushOld
= SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOW
) );
214 PatBlt( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
215 PatBlt( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
216 PatBlt( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
219 SelectObject( hdc
, hbrushOld
);
222 MoveToEx( hdc
, r
.left
, r
.bottom
, NULL
);
223 LineTo( hdc
, r
.right
, r
.bottom
);
225 if (style
& WS_SYSMENU
)
227 UserDrawSysButton( hwnd
, hdc
, FALSE
);
228 r
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
229 MoveToEx( hdc
, r
.left
- 1, r
.top
, NULL
);
230 LineTo( hdc
, r
.left
- 1, r
.bottom
);
232 if (style
& WS_MAXIMIZEBOX
)
234 UserDrawMaxButton( hwnd
, hdc
, FALSE
);
235 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
237 if (style
& WS_MINIMIZEBOX
)
239 UserDrawMinButton( hwnd
, hdc
, FALSE
);
240 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
243 FillRect( hdc
, &r
, GetSysColorBrush(active
? COLOR_ACTIVECAPTION
:
244 COLOR_INACTIVECAPTION
) );
246 if (GetWindowTextA( hwnd
, buffer
, sizeof(buffer
) ))
248 if (active
) SetTextColor( hdc
, GetSysColor( COLOR_CAPTIONTEXT
) );
249 else SetTextColor( hdc
, GetSysColor( COLOR_INACTIVECAPTIONTEXT
) );
250 SetBkMode( hdc
, TRANSPARENT
);
251 DrawTextA( hdc
, buffer
, -1, &r
,
252 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
257 UserDrawFrameNC(HDC hdc
, RECT
* rect
, BOOL dlgFrame
, BOOL active
)
263 width
= GetSystemMetrics(SM_CXDLGFRAME
) - 1;
264 height
= GetSystemMetrics(SM_CYDLGFRAME
) - 1;
265 SelectObject( hdc
, GetSysColorBrush(active
? COLOR_ACTIVECAPTION
:
266 COLOR_INACTIVECAPTION
) );
270 width
= GetSystemMetrics(SM_CXFRAME
) - 2;
271 height
= GetSystemMetrics(SM_CYFRAME
) - 2;
272 SelectObject( hdc
, GetSysColorBrush(active
? COLOR_ACTIVEBORDER
:
273 COLOR_INACTIVEBORDER
) );
277 PatBlt( hdc
, rect
->left
, rect
->top
,
278 rect
->right
- rect
->left
, height
, PATCOPY
);
279 PatBlt( hdc
, rect
->left
, rect
->top
,
280 width
, rect
->bottom
- rect
->top
, PATCOPY
);
281 PatBlt( hdc
, rect
->left
, rect
->bottom
- 1,
282 rect
->right
- rect
->left
, -height
, PATCOPY
);
283 PatBlt( hdc
, rect
->right
- 1, rect
->top
,
284 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
288 InflateRect( rect
, -width
, -height
);
292 INT decYOff
= GetSystemMetrics(SM_CXFRAME
) +
293 GetSystemMetrics(SM_CXSIZE
) - 1;
294 INT decXOff
= GetSystemMetrics(SM_CYFRAME
) +
295 GetSystemMetrics(SM_CYSIZE
) - 1;
297 /* Draw inner rectangle */
299 SelectObject( hdc
, GetStockObject(NULL_BRUSH
) );
300 Rectangle( hdc
, rect
->left
+ width
, rect
->top
+ height
,
301 rect
->right
- width
, rect
->bottom
- height
);
303 /* Draw the decorations */
305 MoveToEx( hdc
, rect
->left
, rect
->top
+ decYOff
, NULL
);
306 LineTo( hdc
, rect
->left
+ width
, rect
->top
+ decYOff
);
307 MoveToEx( hdc
, rect
->right
- 1, rect
->top
+ decYOff
, NULL
);
308 LineTo( hdc
, rect
->right
- width
- 1, rect
->top
+ decYOff
);
309 MoveToEx( hdc
, rect
->left
, rect
->bottom
- decYOff
, NULL
);
310 LineTo( hdc
, rect
->left
+ width
, rect
->bottom
- decYOff
);
311 MoveToEx( hdc
, rect
->right
- 1, rect
->bottom
- decYOff
, NULL
);
312 LineTo( hdc
, rect
->right
- width
- 1, rect
->bottom
- decYOff
);
314 MoveToEx( hdc
, rect
->left
+ decXOff
, rect
->top
, NULL
);
315 LineTo( hdc
, rect
->left
+ decXOff
, rect
->top
+ height
);
316 MoveToEx( hdc
, rect
->left
+ decXOff
, rect
->bottom
- 1, NULL
);
317 LineTo( hdc
, rect
->left
+ decXOff
, rect
->bottom
- height
- 1 );
318 MoveToEx( hdc
, rect
->right
- decXOff
, rect
->top
, NULL
);
319 LineTo( hdc
, rect
->right
- decXOff
, rect
->top
+ height
);
320 MoveToEx( hdc
, rect
->right
- decXOff
, rect
->bottom
- 1, NULL
);
321 LineTo( hdc
, rect
->right
- decXOff
, rect
->bottom
- height
- 1 );
323 InflateRect( rect
, -width
- 1, -height
- 1 );
328 DefWndDoPaintNC(HWND hWnd
, HRGN clip
)
336 Active
= GetWindowLongW(hWnd
, GWL_STYLE
) & WIN_NCACTIVATED
;
337 Style
= GetWindowLong(hWnd
, GWL_STYLE
);
338 ExStyle
= GetWindowLong(hWnd
, GWL_EXSTYLE
);
340 hDc
= GetDCEx(hWnd
, (clip
> (HRGN
)1) ? clip
: 0, DCX_USESTYLE
| DCX_WINDOW
|
341 ((clip
> (HRGN
)1) ? (DCX_INTERSECTRGN
| DCX_KEEPCLIPRGN
) : 0));
347 /* FIXME: Test whether we need to draw anything at all. */
349 GetWindowRect(hWnd
, &rect
);
350 rect
.right
= rect
.right
- rect
.left
;
351 rect
.bottom
= rect
.bottom
- rect
.top
;
352 rect
.top
= rect
.left
= 0;
354 SelectObject(hDc
, GetSysColorPen(COLOR_WINDOWFRAME
));
355 if (UserHasAnyFrameStyle(Style
, ExStyle
))
357 SelectObject(hDc
, GetStockObject(NULL_BRUSH
));
358 Rectangle(hDc
, 0, 0, rect
.right
, rect
.bottom
);
359 InflateRect(&rect
, -1, -1);
362 if (UserHasThickFrameStyle(Style
, ExStyle
))
364 UserDrawFrameNC(hDc
, &rect
, FALSE
, Active
);
366 else if (UserHasDlgFrameStyle(Style
, ExStyle
))
368 UserDrawFrameNC(hDc
, &rect
, TRUE
, Active
);
371 if (Style
& WS_CAPTION
)
374 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYSIZE
);
375 rect
.top
+= GetSystemMetrics(SM_CYSIZE
) +
376 GetSystemMetrics(SM_CYBORDER
);
377 UserDrawCaptionNC(hDc
, &r
, hWnd
, Style
, Active
);
380 /* FIXME: Draw menu bar. */
382 /* FIXME: Draw scroll bars. */
384 /* FIXME: Draw size box. */
386 ReleaseDC(hWnd
, hDc
);
390 DefWndPaintNC(HWND hWnd
, HRGN clip
)
392 if (IsWindowVisible(hWnd
))
396 DefWndRedrawIconTitle(hWnd
);
400 DefWndDoPaintNC(hWnd
, clip
);
407 DefWndHitTestNC(HWND hWnd
, POINT Point
)
412 DefWndHandleLButtonDownNC(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
417 DefWndHandleLButtonDblClkNC(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
422 DefWndHandleActiveNC(HWND hWnd
, WPARAM wParam
)
427 DefWndSetRedraw(HWND hWnd
, WPARAM wParam
)
432 DefWndHandleSetCursor(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
434 /* Not for child windows. */
435 if (hWnd
!= (HWND
)wParam
)
440 switch(LOWORD(lParam
))
444 WORD Msg
= HIWORD(lParam
);
445 if (Msg
== WM_LBUTTONDOWN
|| Msg
== WM_MBUTTONDOWN
||
446 Msg
== WM_RBUTTONDOWN
)
455 HICON hCursor
= (HICON
)GetClassLong(hWnd
, GCL_HCURSOR
);
467 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZEWE
)));
473 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENS
)));
479 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENWSE
)));
485 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENESW
)));
488 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_ARROW
)));
492 DefWndHandleSysCommand(HWND hWnd
, WPARAM wParam
, POINT Pt
)
494 /* FIXME: Implement system commands. */
499 DefWndAdjustRect(RECT
* Rect
, ULONG Style
, BOOL Menu
, ULONG ExStyle
)
501 if (Style
& WS_ICONIC
)
506 if (UserHasThickFrameStyle(Style
, ExStyle
))
508 InflateRect(Rect
, GetSystemMetrics(SM_CXFRAME
),
509 GetSystemMetrics(SM_CYFRAME
));
511 else if (UserHasDlgFrameStyle(Style
, ExStyle
))
513 InflateRect(Rect
, GetSystemMetrics(SM_CXDLGFRAME
),
514 GetSystemMetrics(SM_CYDLGFRAME
));
516 else if (UserHasThinFrameStyle(Style
, ExStyle
))
518 InflateRect(Rect
, GetSystemMetrics(SM_CXBORDER
),
519 GetSystemMetrics(SM_CYBORDER
));
521 if (Style
& WS_CAPTION
)
523 Rect
->top
-= GetSystemMetrics(SM_CYCAPTION
) -
524 GetSystemMetrics(SM_CYBORDER
);
528 Rect
->top
-= GetSystemMetrics(SM_CYMENU
) + GetSystemMetrics(SM_CYBORDER
);
530 if (Style
& WS_VSCROLL
)
532 Rect
->right
+= GetSystemMetrics(SM_CXVSCROLL
) - 1;
533 if (UserHasAnyFrameStyle(Style
, ExStyle
))
538 if (Style
& WS_HSCROLL
)
540 Rect
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
) - 1;
541 if (UserHasAnyFrameStyle(Style
, ExStyle
))
549 DefWndNCCalcSize(HWND hWnd
, RECT
* Rect
)
552 LONG Style
= GetClassLongW(hWnd
, GCL_STYLE
);
553 RECT TmpRect
= {0, 0, 0, 0};
555 if (Style
& CS_VREDRAW
)
557 Result
|= WVR_VREDRAW
;
559 if (Style
& CS_HREDRAW
)
561 Result
|= WVR_HREDRAW
;
564 if (!(GetWindowLong(hWnd
, GWL_STYLE
) & WS_MINIMIZE
))
566 DefWndAdjustRect(&TmpRect
, GetWindowLong(hWnd
, GWL_STYLE
),
567 FALSE
, GetWindowLong(hWnd
, GWL_EXSTYLE
));
568 Rect
->left
-= TmpRect
.left
;
569 Rect
->top
-= TmpRect
.top
;
570 Rect
->right
-= TmpRect
.right
;
571 Rect
->bottom
-= TmpRect
.bottom
;
572 /* FIXME: Adjust if the window has a menu. */
573 Rect
->bottom
= max(Rect
->top
, Rect
->bottom
);
574 Rect
->right
= max(Rect
->left
, Rect
->right
);
580 DefWndHandleWindowPosChanging(HWND hWnd
, WINDOWPOS
* Pos
)
582 /* FIXME: Implement this. */
586 User32DefWindowProc(HWND hWnd
,
596 return(DefWndPaintNC(hWnd
, (HRGN
)wParam
));
602 Point
.x
= SLOWORD(lParam
);
603 Point
.y
= SHIWORD(lParam
);
604 return(DefWndHitTestNC(hWnd
, Point
));
607 case WM_NCLBUTTONDOWN
:
609 return(DefWndHandleLButtonDownNC(hWnd
, wParam
, lParam
));
612 case WM_LBUTTONDBLCLK
:
613 case WM_NCLBUTTONDBLCLK
:
615 return(DefWndHandleLButtonDblClkNC(hWnd
, wParam
, lParam
));
618 case WM_NCRBUTTONDOWN
:
620 if (wParam
== HTCAPTION
)
630 if (hWnd
== GetCapture())
634 Pt
.x
= SLOWORD(lParam
);
635 Pt
.y
= SHIWORD(lParam
);
636 ClientToScreen(hWnd
, &Pt
);
637 lParam
= MAKELPARAM(Pt
.x
, Pt
.y
);
640 SendMessageW(hWnd
, WM_CONTEXTMENU
, (WPARAM
)hWnd
, lParam
);
644 SendMessageA (hWnd
, WM_CONTEXTMENU
, (WPARAM
)hWnd
, lParam
);
651 /* Wine does nothing here. */
657 if (GetWindowLong(hWnd
, GWL_STYLE
) & WS_CHILD
)
661 SendMessageW(GetParent(hWnd
), Msg
, wParam
, lParam
);
665 SendMessageA(hWnd
, WM_CONTEXTMENU
, wParam
, lParam
);
673 Pt
.x
= SLOWORD(lParam
);
674 Pt
.y
= SHIWORD(lParam
);
676 if (GetWindowLong(hWnd
, GWL_STYLE
) & WS_CHILD
)
678 ScreenToClient(GetParent(hWnd
), &Pt
);
681 HitCode
= DefWndHitTestNC(hWnd
, Pt
);
683 if (HitCode
== HTCAPTION
|| HitCode
== HTSYSMENU
)
685 TrackPopupMenu(GetSystemMenu(hWnd
, FALSE
),
686 TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
,
687 Pt
.x
, Pt
.y
, 0, hWnd
, NULL
);
695 return(DefWndHandleActiveNC(hWnd
, wParam
));
712 HDC hDc
= BeginPaint(hWnd
, &Ps
);
716 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MINIMIZE
&&
717 (hIcon
= (HICON
)GetClassLongW(hWnd
, GCL_HICON
)) != NULL
)
721 GetWindowRect(hWnd
, &WindowRect
);
722 x
= (WindowRect
.right
- WindowRect
.left
-
723 GetSystemMetrics(SM_CXICON
)) / 2;
724 y
= (WindowRect
.bottom
- WindowRect
.top
-
725 GetSystemMetrics(SM_CYICON
)) / 2;
726 DrawIcon(hDc
, x
, y
, hIcon
);
736 hRgn
= CreateRectRgn(0, 0, 0, 0);
737 if (GetUpdateRgn(hWnd
, hRgn
, FALSE
) != NULLREGION
)
739 RedrawWindow(hWnd
, NULL
, hRgn
,
740 RDW_ERASENOW
| RDW_ERASE
| RDW_FRAME
|
749 DefWndSetRedraw(hWnd
, wParam
);
759 case WM_MOUSEACTIVATE
:
761 if (GetWindowLong(hWnd
, GWL_STYLE
) & WS_CHILD
)
766 Ret
= SendMessageW(GetParent(hWnd
), WM_MOUSEACTIVATE
,
771 Ret
= SendMessageA(GetParent(hWnd
), WM_MOUSEACTIVATE
,
779 return((LOWORD(lParam
) >= HTCLIENT
) ? MA_ACTIVATE
: MA_NOACTIVATE
);
784 if (LOWORD(lParam
) != WA_INACTIVE
&&
785 GetWindowLong(hWnd
, GWL_STYLE
) & WS_MINIMIZE
)
787 /* Check if the window is minimized. */
795 if (GetWindowLong(hWnd
, GWL_STYLE
& WS_CHILD
))
799 return(SendMessageW(GetParent(hWnd
), WM_MOUSEWHEEL
,
804 return(SendMessageA(GetParent(hWnd
), WM_MOUSEWHEEL
,
812 case WM_ICONERASEBKGND
:
815 HBRUSH hBrush
= (HBRUSH
)GetClassLongW(hWnd
, GCL_HBRBACKGROUND
);
816 GetClipBox((HDC
)wParam
, &Rect
);
817 FillRect((HDC
)wParam
, &Rect
, hBrush
);
826 /* FIXME: Implement colour controls. */
830 if (GetWindowLong(hWnd
, GWL_STYLE
) & WS_CHILD
)
832 if (LOWORD(lParam
) < HTLEFT
|| LOWORD(lParam
) > HTBOTTOMRIGHT
)
837 bResult
= SendMessageW(GetParent(hWnd
), WM_SETCURSOR
,
842 bResult
= SendMessageA(GetParent(hWnd
), WM_SETCURSOR
,
851 return(DefWndHandleSetCursor(hWnd
, wParam
, lParam
));
857 Pt
.x
= SLOWORD(lParam
);
858 Pt
.y
= SHIWORD(lParam
);
859 return(DefWndHandleSysCommand(hWnd
, wParam
, Pt
));
862 /* FIXME: Handle key messages. */
870 /* FIXME: Check for a popup window. */
871 if ((GetWindowLongW(hWnd
, GWL_STYLE
) & WS_VISIBLE
&& !wParam
) ||
872 (!(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_VISIBLE
) && wParam
))
876 ShowWindow(hWnd
, wParam
? SW_SHOWNOACTIVATE
: SW_HIDE
);
882 /* FIXME: Check for a desktop. */
883 if (GetCapture() == hWnd
)
895 /* FIXME: Implement this. */
898 case WM_QUERYDROPOBJECT
:
900 if (GetWindowLongW(hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
)
907 case WM_QUERYDRAGICON
:
912 hIcon
= (HICON
)GetClassLongW(hWnd
, GCL_HICON
);
915 return((LRESULT
)hIcon
);
917 for (Len
= 1; Len
< 64; Len
++)
919 if ((hIcon
= LoadIconW(NULL
, MAKEINTRESOURCE(Len
))) != NULL
)
921 return((LRESULT
)hIcon
);
924 return((LRESULT
)LoadIconW(0, IDI_APPLICATION
));
927 /* FIXME: WM_ISACTIVEICON */
929 case WM_NOTIFYFORMAT
:
931 if (IsWindowUnicode(hWnd
))
943 INT Index
= (wParam
!= 0) ? GCL_HICON
: GCL_HICONSM
;
944 HICON hOldIcon
= (HICON
)GetClassLongW(hWnd
, Index
);
945 SetClassLongW(hWnd
, Index
, lParam
);
946 SetWindowPos(hWnd
, 0, 0, 0, 0, 0,
947 SWP_FRAMECHANGED
| SWP_NOSIZE
| SWP_NOMOVE
|
948 SWP_NOACTIVATE
| SWP_NOZORDER
);
949 return((LRESULT
)hOldIcon
);
954 INT Index
= (wParam
!= 0) ? GCL_HICON
: GCL_HICONSM
;
955 return(GetClassLongW(hWnd
, Index
));
962 SendMessageW(GetParent(hWnd
), Msg
, wParam
, lParam
);
966 SendMessageA(GetParent(hWnd
), Msg
, wParam
, lParam
);
975 DefWindowProcA(HWND hWnd
,
981 static ATOM WindowTextAtom
= 0;
988 CREATESTRUCTA
* Cs
= (CREATESTRUCTA
*)lParam
;
989 if (HIWORD(Cs
->lpszName
))
991 WindowTextAtom
= GlobalAddAtomA("USER32!WindowTextAtomA");
992 WindowText
= User32AllocHeap(strlen(Cs
->lpszName
) * sizeof(CHAR
));
993 strcpy(WindowText
, Cs
->lpszName
);
994 SetPropA(hWnd
, WindowTextAtom
, WindowText
);
1001 return(DefWndNCCalcSize(hWnd
, (RECT
*)lParam
));
1004 case WM_WINDOWPOSCHANGING
:
1006 return(DefWndHandleWindowPosChanging(hWnd
, (WINDOWPOS
*)lParam
));
1009 case WM_GETTEXTLENGTH
:
1011 if (WindowTextAtom
== 0 ||
1012 (WindowText
= GetPropA(hWnd
, WindowTextAtom
)) == NULL
)
1016 return(wcslen(WindowText
));
1021 if (WindowTextAtom
== 0 ||
1022 (WindowText
= GetPropA(hWnd
, WindowTextAtom
)) == NULL
)
1026 ((PSTR
)lParam
) = '\0';
1030 strncpy((PWSTR
)lParam
, WindowText
, wParam
);
1031 return(min(wParam
, wcslen(WindowText
)));
1036 if (WindowTextAtom
!= 0)
1038 WindowTextAtom
= GlobalAddAtomA("USER32!WindowTextAtomW");
1040 if (WindowTextAtom
!= 0 &&
1041 (WindowText
= GetPropA(hWnd
, WindowTextAtom
)) == NULL
)
1043 User32FreeHeap(WindowText
);
1045 WindowText
= User32AllocHeap(strlen((PSTR
)lParam
) * sizeof(CHAR
));
1046 strcpy(WindowText
, (PSTR
)lParam
);
1047 SetPropA(hWnd
, WindowTextAtom
, WindowText
);
1052 if (WindowTextAtom
!= 0 &&
1053 (WindowText
= RemovePropA(hWnd
, WindowTextAtom
)) == NULL
)
1055 User32FreeHeap(WindowText
);
1057 if (WindowTextAtom
!= 0)
1059 GlobalDeleteAtom(WindowTextAtom
);
1061 /* FIXME: Destroy scroll bars here as well. */
1066 Result
= User32DefWindowProc(hWnd
, Msg
, wParam
, lParam
, FALSE
);
1074 DefWindowProcW(HWND hWnd
,
1080 static ATOM WindowTextAtom
= 0;
1087 CREATESTRUCTW
* Cs
= (CREATESTRUCTW
*)lParam
;
1088 if (HIWORD(Cs
->lpszName
))
1090 WindowTextAtom
= GlobalAddAtomW(L
"USER32!WindowTextAtomW");
1091 WindowText
= User32AllocHeap(wcslen(Cs
->lpszName
) * sizeof(WCHAR
));
1092 wcscpy(WindowText
, Cs
->lpszName
);
1093 SetPropW(hWnd
, WindowTextAtom
, WindowText
);
1100 return(DefWndNCCalcSize(hWnd
, (RECT
*)lParam
));
1103 case WM_WINDOWPOSCHANGING
:
1105 return(DefWndHandleWindowPosChanging(hWnd
, (WINDOWPOS
*)lParam
));
1108 case WM_GETTEXTLENGTH
:
1110 if (WindowTextAtom
== 0 ||
1111 (WindowText
= GetPropW(hWnd
, WindowTextAtom
)) == NULL
)
1115 return(wcslen(WindowText
));
1120 if (WindowTextAtom
== 0 ||
1121 (WindowText
= GetPropW(hWnd
, WindowTextAtom
)) == NULL
)
1125 ((PWSTR
)lParam
) = '\0';
1129 wcsncpy((PWSTR
)lParam
, WindowText
, wParam
);
1130 return(min(wParam
, wcslen(WindowText
)));
1135 if (WindowTextAtom
!= 0)
1137 WindowTextAtom
= GlobalAddAtom(L
"USER32!WindowTextAtomW");
1139 if (WindowTextAtom
!= 0 &&
1140 (WindowText
= GetPropW(hWnd
, WindowTextAtom
)) == NULL
)
1142 User32FreeHeap(WindowText
);
1144 WindowText
= User32AllocHeap(wcslen((PWSTR
)lParam
) * sizeof(WCHAR
));
1145 wcscpy(WindowText
, (PWSTR
)lParam
);
1146 SetPropW(hWnd
, WindowTextAtom
, WindowText
);
1151 if (WindowTextAtom
!= 0 &&
1152 (WindowText
= RemovePropW(hWnd
, WindowTextAtom
)) == NULL
)
1154 User32FreeHeap(WindowText
);
1156 if (WindowTextAtom
!= 0)
1158 GlobalDeleteAtom(WindowTextAtom
);
1160 /* FIXME: Destroy scroll bars here as well. */
1165 Result
= User32DefWindowProc(hWnd
, Msg
, wParam
, lParam
, TRUE
);