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
);
48 /***********************************************************************
49 * DefWindowProc (USER.107)
51 LONG
DefWindowProc( HWND hwnd
, WORD msg
, WORD wParam
, LONG lParam
)
53 MEASUREITEMSTRUCT
*measure
;
57 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
60 printf( "DefWindowProc: %d %d %d %08x\n", hwnd
, msg
, wParam
, lParam
);
67 CREATESTRUCT
* createStruct
= (CREATESTRUCT
*)lParam
;
68 if (createStruct
->lpszName
)
69 DEFWND_SetText( hwnd
, createStruct
->lpszName
);
70 if ((createStruct
->style
& WS_VSCROLL
) ||
71 (createStruct
->style
& WS_HSCROLL
)) NC_CreateScrollBars(hwnd
);
76 return NC_HandleNCCalcSize( hwnd
, (NCCALCSIZE_PARAMS
*)lParam
);
79 return NC_HandleNCPaint( hwnd
, (HRGN
)wParam
);
82 printf("going to call NC_HandleNCPaintIcon\n");
83 return NC_HandleNCPaintIcon( hwnd
);
87 return NC_HandleNCHitTest( hwnd
, MAKEPOINT(lParam
) );
89 case WM_NCLBUTTONDOWN
:
90 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
92 case WM_NCLBUTTONDBLCLK
:
93 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
96 return NC_HandleNCActivate( hwnd
, wParam
);
99 if (wndPtr
->hText
) USER_HEAP_FREE(wndPtr
->hText
);
101 if (wndPtr
->VScroll
) free(wndPtr
->VScroll
);
102 if (wndPtr
->HScroll
) free(wndPtr
->HScroll
);
107 PAINTSTRUCT paintstruct
;
108 BeginPaint( hwnd
, &paintstruct
);
109 EndPaint( hwnd
, &paintstruct
);
114 DestroyWindow( hwnd
);
117 case WM_MOUSEACTIVATE
:
118 if (wndPtr
->dwStyle
& WS_CHILD
)
120 LONG ret
= SendMessage( wndPtr
->hwndParent
, WM_MOUSEACTIVATE
,
127 if (wParam
) SetFocus( hwnd
);
130 case WM_WINDOWPOSCHANGING
:
131 return WINPOS_HandleWindowPosChanging( (WINDOWPOS
*)lParam
);
133 case WM_WINDOWPOSCHANGED
:
135 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
136 if (!(winPos
->flags
& SWP_NOMOVE
))
137 SendMessage( hwnd
, WM_MOVE
, 0,
138 MAKELONG( wndPtr
->rectClient
.left
,
139 wndPtr
->rectClient
.top
));
140 if (!(winPos
->flags
& SWP_NOSIZE
))
141 SendMessage( hwnd
, WM_SIZE
, SIZE_RESTORED
,
142 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
143 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
148 case WM_ICONERASEBKGND
:
150 if (!(classPtr
= CLASS_FindClassPtr( wndPtr
->hClass
))) return 1;
151 if (!classPtr
->wc
.hbrBackground
) return 1;
152 if (classPtr
->wc
.hbrBackground
<= COLOR_MAX
+1)
155 hbrush
= CreateSolidBrush(
156 GetSysColor(classPtr
->wc
.hbrBackground
-1));
157 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
, hbrush
);
158 DeleteObject (hbrush
);
161 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
,
162 classPtr
->wc
.hbrBackground
);
171 if (HIWORD(lParam
) == CTLCOLOR_SCROLLBAR
)
173 SetBkColor( (HDC
)wParam
, RGB(255, 255, 255) );
174 SetTextColor( (HDC
)wParam
, RGB(0, 0, 0) );
175 UnrealizeObject( sysColorObjects
.hbrushScrollbar
);
176 return sysColorObjects
.hbrushScrollbar
;
180 SetBkColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOW
) );
181 SetTextColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOWTEXT
) );
182 return sysColorObjects
.hbrushWindow
;
192 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
193 if ((int)wParam
> (len
= strlen(textPtr
)))
195 strcpy((char *)lParam
, textPtr
);
199 lParam
= (DWORD
)NULL
;
204 case WM_GETTEXTLENGTH
:
208 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
209 return (DWORD
)strlen(textPtr
);
215 DEFWND_SetText( hwnd
, (LPSTR
)lParam
);
216 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
220 if (wndPtr
->dwStyle
& WS_CHILD
)
221 if (SendMessage(wndPtr
->hwndParent
, WM_SETCURSOR
, wParam
, lParam
))
223 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
226 return NC_HandleSysCommand( hwnd
, wParam
, MAKEPOINT(lParam
) );
229 if (wParam
== VK_MENU
)
230 SendMessage( hwnd
, WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
236 measure
= (MEASUREITEMSTRUCT
*)lParam
;
237 switch(measure
->CtlType
) {
241 measure
->itemHeight
= 10;
242 /* printf("defwndproc WM_MEASUREITEM // ODT_COMBOBOX !\n");*/
245 measure
->itemHeight
= 10;
246 /* printf("defwndproc WM_MEASUREITEM // ODT_LISTBOX !\n");*/