2 * Default window procedure
4 * Copyright 1993 Alexandre Julliard
12 #include "nonclient.h"
16 /* #define DEBUG_MESSAGE */
20 #define COLOR_MAX COLOR_BTNHIGHLIGHT
22 /***********************************************************************
25 * Set the window text.
27 void DEFWND_SetText( HWND hwnd
, LPSTR text
)
30 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
33 if (wndPtr
->hText
) USER_HEAP_FREE( wndPtr
->hText
);
34 wndPtr
->hText
= USER_HEAP_ALLOC( strlen(text
) + 1 );
35 textPtr
= (LPSTR
) USER_HEAP_LIN_ADDR( wndPtr
->hText
);
36 strcpy( textPtr
, text
);
40 /***********************************************************************
41 * DefWindowProc (USER.107)
43 LONG
DefWindowProc( HWND hwnd
, WORD msg
, WORD wParam
, LONG lParam
)
48 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
50 dprintf_message(stddeb
, "DefWindowProc: %d %d %d %08lx\n",
51 hwnd
, msg
, wParam
, lParam
);
57 CREATESTRUCT
*createStruct
= (CREATESTRUCT
*)PTR_SEG_TO_LIN(lParam
);
58 if (createStruct
->lpszName
)
60 (LPSTR
)PTR_SEG_TO_LIN(createStruct
->lpszName
) );
65 return NC_HandleNCCalcSize( hwnd
,
66 (NCCALCSIZE_PARAMS
*)PTR_SEG_TO_LIN(lParam
) );
70 return NC_HandleNCPaint( hwnd
);
73 return NC_HandleNCHitTest( hwnd
, MAKEPOINT(lParam
) );
75 case WM_NCLBUTTONDOWN
:
76 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
78 case WM_LBUTTONDBLCLK
:
79 case WM_NCLBUTTONDBLCLK
:
80 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
83 return NC_HandleNCActivate( hwnd
, wParam
);
86 if (wndPtr
->hText
) USER_HEAP_FREE(wndPtr
->hText
);
87 if (wndPtr
->hVScroll
) USER_HEAP_FREE(wndPtr
->hVScroll
);
88 if (wndPtr
->hHScroll
) USER_HEAP_FREE(wndPtr
->hHScroll
);
89 wndPtr
->hText
= wndPtr
->hVScroll
= wndPtr
->hHScroll
= 0;
94 PAINTSTRUCT paintstruct
;
95 BeginPaint( hwnd
, &paintstruct
);
96 EndPaint( hwnd
, &paintstruct
);
103 ValidateRect( hwnd
, NULL
);
104 wndPtr
->flags
|= WIN_NO_REDRAW
;
106 else wndPtr
->flags
&= ~WIN_NO_REDRAW
;
110 DestroyWindow( hwnd
);
113 case WM_MOUSEACTIVATE
:
114 if (wndPtr
->dwStyle
& WS_CHILD
)
116 LONG ret
= SendMessage( wndPtr
->hwndParent
, WM_MOUSEACTIVATE
,
123 if (wParam
) SetFocus( hwnd
);
126 case WM_WINDOWPOSCHANGING
:
127 return WINPOS_HandleWindowPosChanging( (WINDOWPOS
*)PTR_SEG_TO_LIN(lParam
) );
129 case WM_WINDOWPOSCHANGED
:
131 WINDOWPOS
* winPos
= (WINDOWPOS
*)PTR_SEG_TO_LIN(lParam
);
132 if (!(winPos
->flags
& SWP_NOMOVE
))
133 SendMessage( hwnd
, WM_MOVE
, 0,
134 MAKELONG( wndPtr
->rectClient
.left
,
135 wndPtr
->rectClient
.top
));
136 if (!(winPos
->flags
& SWP_NOSIZE
))
137 SendMessage( hwnd
, WM_SIZE
, SIZE_RESTORED
,
138 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
139 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
144 case WM_ICONERASEBKGND
:
146 if (!(classPtr
= CLASS_FindClassPtr( wndPtr
->hClass
))) return 0;
147 if (!classPtr
->wc
.hbrBackground
) return 0;
148 if (classPtr
->wc
.hbrBackground
<= COLOR_MAX
+1)
151 hbrush
= CreateSolidBrush(
152 GetSysColor(classPtr
->wc
.hbrBackground
-1));
153 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
, hbrush
);
154 DeleteObject (hbrush
);
157 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
,
158 classPtr
->wc
.hbrBackground
);
167 if (HIWORD(lParam
) == CTLCOLOR_SCROLLBAR
)
169 SetBkColor( (HDC
)wParam
, RGB(255, 255, 255) );
170 SetTextColor( (HDC
)wParam
, RGB(0, 0, 0) );
171 UnrealizeObject( sysColorObjects
.hbrushScrollbar
);
172 return sysColorObjects
.hbrushScrollbar
;
176 SetBkColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOW
) );
177 SetTextColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOWTEXT
) );
178 return sysColorObjects
.hbrushWindow
;
188 textPtr
= (LPSTR
)USER_HEAP_LIN_ADDR(wndPtr
->hText
);
189 if ((int)wParam
> (len
= strlen(textPtr
)))
191 strcpy((char *)PTR_SEG_TO_LIN(lParam
), textPtr
);
199 case WM_GETTEXTLENGTH
:
203 textPtr
= (LPSTR
)USER_HEAP_LIN_ADDR(wndPtr
->hText
);
204 return (DWORD
)strlen(textPtr
);
210 DEFWND_SetText( hwnd
, (LPSTR
)PTR_SEG_TO_LIN(lParam
) );
211 NC_HandleNCPaint( hwnd
); /* Repaint caption */
215 if (wndPtr
->dwStyle
& WS_CHILD
)
216 if (SendMessage(wndPtr
->hwndParent
, WM_SETCURSOR
, wParam
, lParam
))
218 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
221 return NC_HandleSysCommand( hwnd
, wParam
, MAKEPOINT(lParam
) );
224 if (wParam
== VK_MENU
)
225 { /* Send to WS_OVERLAPPED parent. TODO: Handle MDI */
226 SendMessage( WIN_GetTopParent(hwnd
), WM_SYSCOMMAND
,