2 * Default window procedure
4 * Copyright 1993 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1993";
18 #define COLOR_MAX COLOR_BTNHIGHLIGHT
20 extern LONG
NC_HandleNCPaint( HWND hwnd
, HRGN hrgn
);
21 extern LONG
NC_HandleNCActivate( HWND hwnd
, WORD wParam
);
22 extern LONG
NC_HandleNCCalcSize( HWND hwnd
, NCCALCSIZE_PARAMS
*params
);
23 extern LONG
NC_HandleNCHitTest( HWND hwnd
, POINT pt
);
24 extern LONG
NC_HandleNCLButtonDown( HWND hwnd
, WORD wParam
, LONG lParam
);
25 extern LONG
NC_HandleNCLButtonDblClk( HWND hwnd
, WORD wParam
, LONG lParam
);
26 extern LONG
NC_HandleSysCommand( HWND hwnd
, WORD wParam
, POINT pt
);
27 extern LONG
NC_HandleSetCursor( HWND hwnd
, WORD wParam
, LONG lParam
);
28 extern LONG
WINPOS_HandleWindowPosChanging( WINDOWPOS
*winpos
); /* winpos.c */
29 extern void NC_TrackSysMenu( HWND hwnd
); /* menu.c */
30 extern BOOL
ActivateMenuBarFocus(HWND hWnd
); /* menu.c */
34 /***********************************************************************
37 * Set the window text.
39 void DEFWND_SetText( HWND hwnd
, LPSTR text
)
42 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
44 if (wndPtr
->hText
) USER_HEAP_FREE( wndPtr
->hText
);
45 wndPtr
->hText
= USER_HEAP_ALLOC( LMEM_MOVEABLE
, strlen(text
) + 1 );
46 textPtr
= (LPSTR
) USER_HEAP_ADDR( wndPtr
->hText
);
47 strcpy( textPtr
, text
);
51 /***********************************************************************
52 * DefWindowProc (USER.107)
54 LONG
DefWindowProc( HWND hwnd
, WORD msg
, WORD wParam
, LONG lParam
)
56 MEASUREITEMSTRUCT
*measure
;
60 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
63 printf( "DefWindowProc: %d %d %d %08x\n", hwnd
, msg
, wParam
, lParam
);
70 CREATESTRUCT
* createStruct
= (CREATESTRUCT
*)lParam
;
71 if (createStruct
->lpszName
)
72 DEFWND_SetText( hwnd
, createStruct
->lpszName
);
73 if ((createStruct
->style
& WS_VSCROLL
) ||
74 (createStruct
->style
& WS_HSCROLL
)) NC_CreateScrollBars(hwnd
);
79 return NC_HandleNCCalcSize( hwnd
, (NCCALCSIZE_PARAMS
*)lParam
);
82 return NC_HandleNCPaint( hwnd
, (HRGN
)wParam
);
85 printf("going to call NC_HandleNCPaintIcon\n");
86 return NC_HandleNCPaintIcon( hwnd
);
90 return NC_HandleNCHitTest( hwnd
, MAKEPOINT(lParam
) );
92 case WM_NCLBUTTONDOWN
:
93 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
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
);
117 DestroyWindow( hwnd
);
120 case WM_MOUSEACTIVATE
:
121 if (wndPtr
->dwStyle
& WS_CHILD
)
123 LONG ret
= SendMessage( wndPtr
->hwndParent
, WM_MOUSEACTIVATE
,
130 if (wParam
) SetFocus( hwnd
);
133 case WM_WINDOWPOSCHANGING
:
134 return WINPOS_HandleWindowPosChanging( (WINDOWPOS
*)lParam
);
136 case WM_WINDOWPOSCHANGED
:
138 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
139 if (!(winPos
->flags
& SWP_NOMOVE
))
140 SendMessage( hwnd
, WM_MOVE
, 0,
141 MAKELONG( wndPtr
->rectClient
.left
,
142 wndPtr
->rectClient
.top
));
143 if (!(winPos
->flags
& SWP_NOSIZE
))
144 SendMessage( hwnd
, WM_SIZE
, SIZE_RESTORED
,
145 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
146 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
151 case WM_ICONERASEBKGND
:
153 if (!(classPtr
= CLASS_FindClassPtr( wndPtr
->hClass
))) return 1;
154 if (!classPtr
->wc
.hbrBackground
) return 1;
155 if (classPtr
->wc
.hbrBackground
<= COLOR_MAX
+1)
158 hbrush
= CreateSolidBrush(
159 GetSysColor(classPtr
->wc
.hbrBackground
-1));
160 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
, hbrush
);
161 DeleteObject (hbrush
);
164 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
,
165 classPtr
->wc
.hbrBackground
);
174 if (HIWORD(lParam
) == CTLCOLOR_SCROLLBAR
)
176 SetBkColor( (HDC
)wParam
, RGB(255, 255, 255) );
177 SetTextColor( (HDC
)wParam
, RGB(0, 0, 0) );
178 UnrealizeObject( sysColorObjects
.hbrushScrollbar
);
179 return sysColorObjects
.hbrushScrollbar
;
183 SetBkColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOW
) );
184 SetTextColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOWTEXT
) );
185 return sysColorObjects
.hbrushWindow
;
195 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
196 if ((int)wParam
> (len
= strlen(textPtr
)))
198 strcpy((char *)lParam
, textPtr
);
202 lParam
= (DWORD
)NULL
;
207 case WM_GETTEXTLENGTH
:
211 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
212 return (DWORD
)strlen(textPtr
);
218 DEFWND_SetText( hwnd
, (LPSTR
)lParam
);
219 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
223 if (wndPtr
->dwStyle
& WS_CHILD
)
224 if (SendMessage(wndPtr
->hwndParent
, WM_SETCURSOR
, wParam
, lParam
))
226 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
229 return NC_HandleSysCommand( hwnd
, wParam
, MAKEPOINT(lParam
) );
232 if (wParam
== VK_MENU
) ActivateMenuBarFocus(hwnd
);
240 measure
= (MEASUREITEMSTRUCT
*)lParam
;
241 switch(measure
->CtlType
) {
245 measure
->itemHeight
= 10;
246 /* printf("defwndproc WM_MEASUREITEM // ODT_COMBOBOX !\n");*/
249 measure
->itemHeight
= 10;
250 /* printf("defwndproc WM_MEASUREITEM // ODT_LISTBOX !\n");*/