2 * Default window procedure
4 * Copyright 1993 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1993";
17 /* #define DEBUG_MESSAGE /* */
18 /* #undef DEBUG_MESSAGE /* */
23 #define COLOR_MAX COLOR_BTNHIGHLIGHT
25 extern LONG
NC_HandleNCPaint( HWND hwnd
, HRGN hrgn
);
26 extern LONG
NC_HandleNCActivate( HWND hwnd
, WORD wParam
);
27 extern LONG
NC_HandleNCCalcSize( HWND hwnd
, NCCALCSIZE_PARAMS
*params
);
28 extern LONG
NC_HandleNCHitTest( HWND hwnd
, POINT pt
);
29 extern LONG
NC_HandleNCLButtonDown( HWND hwnd
, WORD wParam
, LONG lParam
);
30 extern LONG
NC_HandleNCLButtonDblClk( HWND hwnd
, WORD wParam
, LONG lParam
);
31 extern LONG
NC_HandleSysCommand( HWND hwnd
, WORD wParam
, POINT pt
);
32 extern LONG
NC_HandleSetCursor( HWND hwnd
, WORD wParam
, LONG lParam
);
33 extern LONG
WINPOS_HandleWindowPosChanging( WINDOWPOS
*winpos
); /* winpos.c */
36 /***********************************************************************
39 * Set the window text.
41 void DEFWND_SetText( HWND hwnd
, LPSTR text
)
44 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
46 if (wndPtr
->hText
) USER_HEAP_FREE( wndPtr
->hText
);
47 wndPtr
->hText
= USER_HEAP_ALLOC( LMEM_MOVEABLE
, strlen(text
) + 1 );
48 textPtr
= (LPSTR
) USER_HEAP_ADDR( wndPtr
->hText
);
49 strcpy( textPtr
, text
);
54 /***********************************************************************
55 * DefWindowProc (USER.107)
57 LONG
DefWindowProc( HWND hwnd
, WORD msg
, WORD wParam
, LONG lParam
)
59 MEASUREITEMSTRUCT
*measure
;
63 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
65 dprintf_message(stddeb
, "DefWindowProc: %d %d %d %08x\n",
66 hwnd
, msg
, wParam
, lParam
);
72 CREATESTRUCT
* createStruct
= (CREATESTRUCT
*)lParam
;
73 if (createStruct
->lpszName
)
74 DEFWND_SetText( hwnd
, createStruct
->lpszName
);
75 if ((createStruct
->style
& WS_VSCROLL
) ||
76 (createStruct
->style
& WS_HSCROLL
)) NC_CreateScrollBars(hwnd
);
81 return NC_HandleNCCalcSize( hwnd
, (NCCALCSIZE_PARAMS
*)lParam
);
85 return NC_HandleNCPaint( hwnd
, (HRGN
)wParam
);
89 return NC_HandleNCHitTest( hwnd
, MAKEPOINT(lParam
) );
91 case WM_NCLBUTTONDOWN
:
92 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
94 case WM_LBUTTONDBLCLK
:
95 case WM_NCLBUTTONDBLCLK
:
96 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
99 return NC_HandleNCActivate( hwnd
, wParam
);
102 if (wndPtr
->hText
) USER_HEAP_FREE(wndPtr
->hText
);
104 if (wndPtr
->VScroll
) free(wndPtr
->VScroll
);
105 if (wndPtr
->HScroll
) free(wndPtr
->HScroll
);
110 PAINTSTRUCT paintstruct
;
111 BeginPaint( hwnd
, &paintstruct
);
112 EndPaint( hwnd
, &paintstruct
);
119 ValidateRect( hwnd
, NULL
);
120 wndPtr
->flags
|= WIN_NO_REDRAW
;
122 else wndPtr
->flags
&= ~WIN_NO_REDRAW
;
126 DestroyWindow( hwnd
);
129 case WM_MOUSEACTIVATE
:
130 if (wndPtr
->dwStyle
& WS_CHILD
)
132 LONG ret
= SendMessage( wndPtr
->hwndParent
, WM_MOUSEACTIVATE
,
139 if (wParam
) SetFocus( hwnd
);
142 case WM_WINDOWPOSCHANGING
:
143 return WINPOS_HandleWindowPosChanging( (WINDOWPOS
*)lParam
);
145 case WM_WINDOWPOSCHANGED
:
147 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
148 if (!(winPos
->flags
& SWP_NOMOVE
))
149 SendMessage( hwnd
, WM_MOVE
, 0,
150 MAKELONG( wndPtr
->rectClient
.left
,
151 wndPtr
->rectClient
.top
));
152 if (!(winPos
->flags
& SWP_NOSIZE
))
153 SendMessage( hwnd
, WM_SIZE
, SIZE_RESTORED
,
154 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
155 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
160 case WM_ICONERASEBKGND
:
162 if (!(classPtr
= CLASS_FindClassPtr( wndPtr
->hClass
))) return 1;
163 if (!classPtr
->wc
.hbrBackground
) return 1;
164 if (classPtr
->wc
.hbrBackground
<= COLOR_MAX
+1)
167 hbrush
= CreateSolidBrush(
168 GetSysColor(classPtr
->wc
.hbrBackground
-1));
169 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
, hbrush
);
170 DeleteObject (hbrush
);
173 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
,
174 classPtr
->wc
.hbrBackground
);
183 if (HIWORD(lParam
) == CTLCOLOR_SCROLLBAR
)
185 SetBkColor( (HDC
)wParam
, RGB(255, 255, 255) );
186 SetTextColor( (HDC
)wParam
, RGB(0, 0, 0) );
187 UnrealizeObject( sysColorObjects
.hbrushScrollbar
);
188 return sysColorObjects
.hbrushScrollbar
;
192 SetBkColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOW
) );
193 SetTextColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOWTEXT
) );
194 return sysColorObjects
.hbrushWindow
;
204 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
205 if ((int)wParam
> (len
= strlen(textPtr
)))
207 strcpy((char *)lParam
, textPtr
);
211 lParam
= (DWORD
)NULL
;
216 case WM_GETTEXTLENGTH
:
220 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
221 return (DWORD
)strlen(textPtr
);
227 DEFWND_SetText( hwnd
, (LPSTR
)lParam
);
228 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
232 if (wndPtr
->dwStyle
& WS_CHILD
)
233 if (SendMessage(wndPtr
->hwndParent
, WM_SETCURSOR
, wParam
, lParam
))
235 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
238 return NC_HandleSysCommand( hwnd
, wParam
, MAKEPOINT(lParam
) );
241 if (wParam
== VK_MENU
)
242 SendMessage( hwnd
, WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
248 measure
= (MEASUREITEMSTRUCT
*)lParam
;
249 switch(measure
->CtlType
) {
253 measure
->itemHeight
= 10;
254 /* printf("defwndproc WM_MEASUREITEM // ODT_COMBOBOX !\n");*/
257 measure
->itemHeight
= 10;
258 /* printf("defwndproc WM_MEASUREITEM // ODT_LISTBOX !\n");*/