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 */
31 /***********************************************************************
34 * Set the window text.
36 void DEFWND_SetText( HWND hwnd
, LPSTR text
)
39 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
41 if (wndPtr
->hText
) USER_HEAP_FREE( wndPtr
->hText
);
42 wndPtr
->hText
= USER_HEAP_ALLOC( LMEM_MOVEABLE
, strlen(text
) + 1 );
43 textPtr
= (LPSTR
) USER_HEAP_ADDR( wndPtr
->hText
);
44 strcpy( textPtr
, text
);
49 /***********************************************************************
50 * DefWindowProc (USER.107)
52 LONG
DefWindowProc( HWND hwnd
, WORD msg
, WORD wParam
, LONG lParam
)
54 MEASUREITEMSTRUCT
*measure
;
58 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
61 printf( "DefWindowProc: %d %d %d %08x\n", hwnd
, msg
, wParam
, lParam
);
68 CREATESTRUCT
* createStruct
= (CREATESTRUCT
*)lParam
;
69 if (createStruct
->lpszName
)
70 DEFWND_SetText( hwnd
, createStruct
->lpszName
);
71 if ((createStruct
->style
& WS_VSCROLL
) ||
72 (createStruct
->style
& WS_HSCROLL
)) NC_CreateScrollBars(hwnd
);
77 return NC_HandleNCCalcSize( hwnd
, (NCCALCSIZE_PARAMS
*)lParam
);
81 return NC_HandleNCPaint( hwnd
, (HRGN
)wParam
);
85 return NC_HandleNCHitTest( hwnd
, MAKEPOINT(lParam
) );
87 case WM_NCLBUTTONDOWN
:
88 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
90 case WM_LBUTTONDBLCLK
:
91 case WM_NCLBUTTONDBLCLK
:
92 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
95 return NC_HandleNCActivate( hwnd
, wParam
);
98 if (wndPtr
->hText
) USER_HEAP_FREE(wndPtr
->hText
);
100 if (wndPtr
->VScroll
) free(wndPtr
->VScroll
);
101 if (wndPtr
->HScroll
) free(wndPtr
->HScroll
);
106 PAINTSTRUCT paintstruct
;
107 BeginPaint( hwnd
, &paintstruct
);
108 EndPaint( hwnd
, &paintstruct
);
113 DestroyWindow( hwnd
);
116 case WM_MOUSEACTIVATE
:
117 if (wndPtr
->dwStyle
& WS_CHILD
)
119 LONG ret
= SendMessage( wndPtr
->hwndParent
, WM_MOUSEACTIVATE
,
126 if (wParam
) SetFocus( hwnd
);
129 case WM_WINDOWPOSCHANGING
:
130 return WINPOS_HandleWindowPosChanging( (WINDOWPOS
*)lParam
);
132 case WM_WINDOWPOSCHANGED
:
134 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
135 if (!(winPos
->flags
& SWP_NOMOVE
))
136 SendMessage( hwnd
, WM_MOVE
, 0,
137 MAKELONG( wndPtr
->rectClient
.left
,
138 wndPtr
->rectClient
.top
));
139 if (!(winPos
->flags
& SWP_NOSIZE
))
140 SendMessage( hwnd
, WM_SIZE
, SIZE_RESTORED
,
141 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
142 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
147 case WM_ICONERASEBKGND
:
149 if (!(classPtr
= CLASS_FindClassPtr( wndPtr
->hClass
))) return 1;
150 if (!classPtr
->wc
.hbrBackground
) return 1;
151 if (classPtr
->wc
.hbrBackground
<= COLOR_MAX
+1)
154 hbrush
= CreateSolidBrush(
155 GetSysColor(classPtr
->wc
.hbrBackground
-1));
156 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
, hbrush
);
157 DeleteObject (hbrush
);
160 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
,
161 classPtr
->wc
.hbrBackground
);
170 if (HIWORD(lParam
) == CTLCOLOR_SCROLLBAR
)
172 SetBkColor( (HDC
)wParam
, RGB(255, 255, 255) );
173 SetTextColor( (HDC
)wParam
, RGB(0, 0, 0) );
174 UnrealizeObject( sysColorObjects
.hbrushScrollbar
);
175 return sysColorObjects
.hbrushScrollbar
;
179 SetBkColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOW
) );
180 SetTextColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOWTEXT
) );
181 return sysColorObjects
.hbrushWindow
;
191 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
192 if ((int)wParam
> (len
= strlen(textPtr
)))
194 strcpy((char *)lParam
, textPtr
);
198 lParam
= (DWORD
)NULL
;
203 case WM_GETTEXTLENGTH
:
207 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
208 return (DWORD
)strlen(textPtr
);
214 DEFWND_SetText( hwnd
, (LPSTR
)lParam
);
215 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
219 if (wndPtr
->dwStyle
& WS_CHILD
)
220 if (SendMessage(wndPtr
->hwndParent
, WM_SETCURSOR
, wParam
, lParam
))
222 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
225 return NC_HandleSysCommand( hwnd
, wParam
, MAKEPOINT(lParam
) );
228 if (wParam
== VK_MENU
)
229 SendMessage( hwnd
, WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
235 measure
= (MEASUREITEMSTRUCT
*)lParam
;
236 switch(measure
->CtlType
) {
240 measure
->itemHeight
= 10;
241 /* printf("defwndproc WM_MEASUREITEM // ODT_COMBOBOX !\n");*/
244 measure
->itemHeight
= 10;
245 /* printf("defwndproc WM_MEASUREITEM // ODT_LISTBOX !\n");*/