2 * Default window procedure
4 * Copyright 1993 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1993";
16 extern LONG
NC_HandleNCPaint( HWND hwnd
, HRGN hrgn
);
17 extern LONG
NC_HandleNCActivate( HWND hwnd
, WORD wParam
);
18 extern LONG
NC_HandleNCCalcSize( HWND hwnd
, NCCALCSIZE_PARAMS
*params
);
19 extern LONG
NC_HandleNCHitTest( HWND hwnd
, POINT pt
);
20 extern LONG
NC_HandleNCLButtonDown( HWND hwnd
, WORD wParam
, LONG lParam
);
21 extern LONG
NC_HandleNCLButtonDblClk( HWND hwnd
, WORD wParam
, LONG lParam
);
22 extern LONG
NC_HandleSysCommand( HWND hwnd
, WORD wParam
, POINT pt
);
23 extern LONG
NC_HandleSetCursor( HWND hwnd
, WORD wParam
, LONG lParam
);
24 extern void NC_TrackSysMenu( HWND hwnd
); /* menu.c */
25 extern BOOL
ActivateMenuFocus(HWND hWnd
); /* menu.c */
29 /***********************************************************************
32 * Set the window text.
34 void DEFWND_SetText( HWND hwnd
, LPSTR text
)
37 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
39 if (wndPtr
->hText
) USER_HEAP_FREE( wndPtr
->hText
);
40 wndPtr
->hText
= USER_HEAP_ALLOC( LMEM_MOVEABLE
, strlen(text
) + 2 );
41 textPtr
= (LPSTR
) USER_HEAP_ADDR( wndPtr
->hText
);
42 strcpy( textPtr
, text
);
43 /* for use by edit control */
44 *(textPtr
+ strlen(text
) + 1) = '\0';
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 return NC_HandleNCHitTest( hwnd
, MAKEPOINT(lParam
) );
84 case WM_NCLBUTTONDOWN
:
85 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
87 case WM_NCLBUTTONDBLCLK
:
88 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
91 return NC_HandleNCActivate( hwnd
, wParam
);
94 if (wndPtr
->hText
) USER_HEAP_FREE(wndPtr
->hText
);
96 if (wndPtr
->VScroll
) free(wndPtr
->VScroll
);
97 if (wndPtr
->HScroll
) free(wndPtr
->HScroll
);
102 PAINTSTRUCT paintstruct
;
103 BeginPaint( hwnd
, &paintstruct
);
104 EndPaint( hwnd
, &paintstruct
);
109 DestroyWindow( hwnd
);
112 case WM_MOUSEACTIVATE
:
113 if (wndPtr
->dwStyle
& WS_CHILD
)
115 LONG ret
= SendMessage( wndPtr
->hwndParent
, WM_MOUSEACTIVATE
,
122 if (wParam
) SetFocus( hwnd
);
125 case WM_WINDOWPOSCHANGED
:
127 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
128 if (!(winPos
->flags
& SWP_NOMOVE
))
129 SendMessage( hwnd
, WM_MOVE
, 0,
130 MAKELONG( wndPtr
->rectClient
.left
,
131 wndPtr
->rectClient
.top
));
132 if (!(winPos
->flags
& SWP_NOSIZE
))
133 SendMessage( hwnd
, WM_SIZE
, SIZE_RESTORED
,
134 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
135 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
140 case WM_ICONERASEBKGND
:
142 if (!(classPtr
= CLASS_FindClassPtr( wndPtr
->hClass
))) return 1;
143 if (!classPtr
->wc
.hbrBackground
) return 1;
144 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
,
145 classPtr
->wc
.hbrBackground
);
154 if (HIWORD(lParam
) == CTLCOLOR_SCROLLBAR
)
156 SetBkColor( (HDC
)wParam
, RGB(255, 255, 255) );
157 SetTextColor( (HDC
)wParam
, RGB(0, 0, 0) );
158 /* hbr = sysClrObjects.hbrScrollbar;
159 UnrealizeObject(hbr); */
160 return GetStockObject(LTGRAY_BRUSH
);
164 SetBkColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOW
) );
165 SetTextColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOWTEXT
) );
166 /* hbr = sysClrObjects.hbrWindow; */
167 return GetStockObject(WHITE_BRUSH
);
177 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
178 if ((int)wParam
> (len
= strlen(textPtr
)))
180 strcpy((char *)lParam
, textPtr
);
184 lParam
= (DWORD
)NULL
;
189 case WM_GETTEXTLENGTH
:
193 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
194 return (DWORD
)strlen(textPtr
);
200 DEFWND_SetText( hwnd
, (LPSTR
)lParam
);
201 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
205 if (wndPtr
->dwStyle
& WS_CHILD
)
206 if (SendMessage(wndPtr
->hwndParent
, WM_SETCURSOR
, wParam
, lParam
))
208 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
211 return NC_HandleSysCommand( hwnd
, wParam
, MAKEPOINT(lParam
) );
214 if (wParam
== VK_MENU
) ActivateMenuFocus(hwnd
);
222 measure
= (MEASUREITEMSTRUCT
*)lParam
;
223 switch(measure
->CtlType
) {
227 measure
->itemHeight
= 10;
228 /* printf("defwndproc WM_MEASUREITEM // ODT_COMBOBOX !\n");*/
231 measure
->itemHeight
= 10;
232 /* printf("defwndproc WM_MEASUREITEM // ODT_LISTBOX !\n");*/