4 * Copyright 1998 Eric Kohl
7 * This is just a dummy control. An author is needed! Any volunteers?
8 * I will only improve this control once in a while.
9 * Eric <ekohl@abo.rhein-zeitung.de>
13 * - All notifications.
24 #define TREEVIEW_GetInfoPtr(wndPtr) ((TREEVIEW_INFO *)wndPtr->wExtra[0])
29 TREEVIEW_SetImageList (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
31 TREEVIEW_INFO
*infoPtr
= TREEVIEW_GetInfoPtr(wndPtr
);
34 if ((INT32
)wParam
== TVSIL_NORMAL
) {
35 himlTemp
= infoPtr
->himlNormal
;
36 infoPtr
->himlNormal
= (HIMAGELIST
)lParam
;
38 else if ((INT32
)wParam
== TVSIL_STATE
) {
39 himlTemp
= infoPtr
->himlState
;
40 infoPtr
->himlState
= (HIMAGELIST
)lParam
;
45 return (LRESULT
)himlTemp
;
51 TREEVIEW_Create (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
53 TREEVIEW_INFO
*infoPtr
;
55 /* allocate memory for info structure */
56 infoPtr
= (TREEVIEW_INFO
*)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
57 sizeof(TREEVIEW_INFO
));
58 wndPtr
->wExtra
[0] = (DWORD
)infoPtr
;
60 if (infoPtr
== NULL
) {
61 ERR (treeview
, "could not allocate info memory!\n");
65 if ((TREEVIEW_INFO
*)wndPtr
->wExtra
[0] != infoPtr
) {
66 ERR (treeview
, "pointer assignment error!\n");
70 /* set default settings */
71 infoPtr
->clrBk
= GetSysColor32 (COLOR_WINDOW
);
72 infoPtr
->clrText
= GetSysColor32 (COLOR_BTNTEXT
);
73 infoPtr
->himlNormal
= NULL
;
74 infoPtr
->himlState
= NULL
;
82 TREEVIEW_Destroy (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
84 TREEVIEW_INFO
*infoPtr
= TREEVIEW_GetInfoPtr(wndPtr
);
89 /* free tree view info data */
90 HeapFree (GetProcessHeap (), 0, infoPtr
);
97 TREEVIEW_EraseBackground (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
99 TREEVIEW_INFO
*infoPtr
= TREEVIEW_GetInfoPtr(wndPtr
);
100 HBRUSH32 hBrush
= CreateSolidBrush32 (infoPtr
->clrBk
);
103 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
104 FillRect32 ((HDC32
)wParam
, &rect
, hBrush
);
105 DeleteObject32 (hBrush
);
112 TreeviewWindowProc (HWND32 hwnd
, UINT32 uMsg
, WPARAM32 wParam
, LPARAM lParam
)
114 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
120 // case TVM_GETIMAGELIST:
121 // return TREEVIEW_GetImageList (wndPtr, wParam, lParam);
125 case TVM_SETIMAGELIST
:
126 return TREEVIEW_SetImageList (wndPtr
, wParam
, lParam
);
131 return TREEVIEW_Create (wndPtr
, wParam
, lParam
);
134 return TREEVIEW_Destroy (wndPtr
, wParam
, lParam
);
139 return TREEVIEW_EraseBackground (wndPtr
, wParam
, lParam
);
142 return DLGC_WANTARROWS
| DLGC_WANTCHARS
;
146 // return TREEVIEW_Paint (wndPtr, wParam);
156 ERR (treeview
, "unknown msg %04x wp=%08x lp=%08lx\n",
157 uMsg
, wParam
, lParam
);
158 return DefWindowProc32A (hwnd
, uMsg
, wParam
, lParam
);
165 TREEVIEW_Register (void)
167 WNDCLASS32A wndClass
;
169 if (GlobalFindAtom32A (WC_TREEVIEW32A
)) return;
171 ZeroMemory (&wndClass
, sizeof(WNDCLASS32A
));
172 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
173 wndClass
.lpfnWndProc
= (WNDPROC32
)TreeviewWindowProc
;
174 wndClass
.cbClsExtra
= 0;
175 wndClass
.cbWndExtra
= sizeof(TREEVIEW_INFO
*);
176 wndClass
.hCursor
= LoadCursor32A (0, IDC_ARROW32A
);
177 wndClass
.hbrBackground
= 0;
178 wndClass
.lpszClassName
= WC_TREEVIEW32A
;
180 RegisterClass32A (&wndClass
);