2 * Default window procedure
4 * Copyright 1993 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1993";
15 extern LONG
NC_HandleNCPaint( HWND hwnd
, HRGN hrgn
);
16 extern LONG
NC_HandleNCActivate( HWND hwnd
, WORD wParam
);
17 extern LONG
NC_HandleNCCalcSize( HWND hwnd
, NCCALCSIZE_PARAMS
*params
);
18 extern LONG
NC_HandleNCHitTest( HWND hwnd
, POINT pt
);
19 extern LONG
NC_HandleNCLButtonDown( HWND hwnd
, WORD wParam
, LONG lParam
);
20 extern LONG
NC_HandleNCLButtonDblClk( HWND hwnd
, WORD wParam
, LONG lParam
);
21 extern LONG
NC_HandleSysCommand( HWND hwnd
, WORD wParam
, POINT pt
);
22 extern LONG
NC_HandleSetCursor( HWND hwnd
, WORD wParam
, LONG lParam
);
23 extern void NC_TrackSysMenu( HWND hwnd
); /* menu.c */
27 /***********************************************************************
30 * Set the window text.
32 void DEFWND_SetText( HWND hwnd
, LPSTR text
)
35 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
37 if (wndPtr
->hText
) USER_HEAP_FREE( wndPtr
->hText
);
38 wndPtr
->hText
= USER_HEAP_ALLOC( LMEM_MOVEABLE
, strlen(text
) + 2 );
39 textPtr
= (LPSTR
) USER_HEAP_ADDR( wndPtr
->hText
);
40 strcpy( textPtr
, text
);
41 /* for use by edit control */
42 *(textPtr
+ strlen(text
) + 1) = '\0';
46 /***********************************************************************
47 * DefWindowProc (USER.107)
49 LONG
DefWindowProc( HWND hwnd
, WORD msg
, WORD wParam
, LONG lParam
)
54 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
57 printf( "DefWindowProc: %d %d %d %08x\n", hwnd
, msg
, wParam
, lParam
);
64 CREATESTRUCT
* createStruct
= (CREATESTRUCT
*)lParam
;
65 if (createStruct
->lpszName
)
66 DEFWND_SetText( hwnd
, createStruct
->lpszName
);
67 if ((createStruct
->style
& WS_VSCROLL
) ||
68 (createStruct
->style
& WS_HSCROLL
)) NC_CreateScrollBars(hwnd
);
73 return NC_HandleNCCalcSize( hwnd
, (NCCALCSIZE_PARAMS
*)lParam
);
76 return NC_HandleNCPaint( hwnd
, (HRGN
)wParam
);
79 return NC_HandleNCHitTest( hwnd
, MAKEPOINT(lParam
) );
81 case WM_NCLBUTTONDOWN
:
82 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
84 case WM_NCLBUTTONDBLCLK
:
85 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
88 return NC_HandleNCActivate( hwnd
, wParam
);
91 if (wndPtr
->hText
) USER_HEAP_FREE(wndPtr
->hText
);
93 if (wndPtr
->VScroll
) free(wndPtr
->VScroll
);
94 if (wndPtr
->HScroll
) free(wndPtr
->HScroll
);
99 PAINTSTRUCT paintstruct
;
100 BeginPaint( hwnd
, &paintstruct
);
101 EndPaint( hwnd
, &paintstruct
);
106 DestroyWindow( hwnd
);
109 case WM_MOUSEACTIVATE
:
110 if (wndPtr
->dwStyle
& WS_CHILD
)
112 LONG ret
= SendMessage( wndPtr
->hwndParent
, WM_MOUSEACTIVATE
,
119 if (wParam
) SetFocus( hwnd
);
122 case WM_WINDOWPOSCHANGED
:
124 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
125 if (!(winPos
->flags
& SWP_NOMOVE
))
126 SendMessage( hwnd
, WM_MOVE
, 0,
127 MAKELONG( wndPtr
->rectClient
.left
,
128 wndPtr
->rectClient
.top
));
129 if (!(winPos
->flags
& SWP_NOSIZE
))
130 SendMessage( hwnd
, WM_SIZE
, SIZE_RESTORED
,
131 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
132 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
137 case WM_ICONERASEBKGND
:
139 if (!(classPtr
= CLASS_FindClassPtr( wndPtr
->hClass
))) return 1;
140 if (!classPtr
->wc
.hbrBackground
) return 1;
141 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
,
142 classPtr
->wc
.hbrBackground
);
151 if (HIWORD(lParam
) == CTLCOLOR_SCROLLBAR
)
153 SetBkColor( (HDC
)wParam
, RGB(255, 255, 255) );
154 SetTextColor( (HDC
)wParam
, RGB(0, 0, 0) );
155 /* hbr = sysClrObjects.hbrScrollbar;
156 UnrealizeObject(hbr); */
157 return GetStockObject(LTGRAY_BRUSH
);
161 SetBkColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOW
) );
162 SetTextColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOWTEXT
) );
163 /* hbr = sysClrObjects.hbrWindow; */
164 return GetStockObject(WHITE_BRUSH
);
174 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
175 if ((int)wParam
> (len
= strlen(textPtr
)))
177 strcpy((char *)lParam
, textPtr
);
181 lParam
= (DWORD
)NULL
;
186 case WM_GETTEXTLENGTH
:
190 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
191 return (DWORD
)strlen(textPtr
);
197 DEFWND_SetText( hwnd
, (LPSTR
)lParam
);
198 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
202 if (wndPtr
->dwStyle
& WS_CHILD
)
203 if (SendMessage(wndPtr
->hwndParent
, WM_SETCURSOR
, wParam
, lParam
))
205 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
208 return NC_HandleSysCommand( hwnd
, wParam
, MAKEPOINT(lParam
) );
211 if (wParam
== VK_MENU
) {
212 printf("VK_MENU Pressed // hMenu=%04X !\n", GetMenu(hwnd
));
213 NC_TrackSysMenu(hwnd
);
217 if (wParam
== VK_MENU
) {
218 printf("VK_MENU Released // hMenu=%04X !\n", GetMenu(hwnd
));