Mercurial > dwindows
comparison win/dw.c @ 167:0b3debaa9c6c
Added new container functions, and fixed resource leaks.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 26 Nov 2002 07:10:37 +0000 |
parents | d03716228b7f |
children | 627e531ca530 |
comparison
equal
deleted
inserted
replaced
166:fb2987817924 | 167:0b3debaa9c6c |
---|---|
57 | 57 |
58 HBRUSH _colors[18]; | 58 HBRUSH _colors[18]; |
59 | 59 |
60 | 60 |
61 void _resize_notebook_page(HWND handle, int pageid); | 61 void _resize_notebook_page(HWND handle, int pageid); |
62 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); | |
62 int _lookup_icon(HWND handle, HICON hicon, int type); | 63 int _lookup_icon(HWND handle, HICON hicon, int type); |
63 | 64 |
64 typedef struct _sighandler | 65 typedef struct _sighandler |
65 { | 66 { |
66 struct _sighandler *next; | 67 struct _sighandler *next; |
320 * the user memory allocated to it. | 321 * the user memory allocated to it. |
321 */ | 322 */ |
322 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam) | 323 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam) |
323 { | 324 { |
324 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | 325 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); |
326 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | |
327 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0); | |
328 char tmpbuf[100]; | |
329 | |
330 /* Delete font, icon and bitmap GDI objects in use */ | |
331 if(oldfont) | |
332 DeleteObject(oldfont); | |
333 if(oldicon) | |
334 DeleteObject(oldicon); | |
335 | |
336 GetClassName(handle, tmpbuf, 99); | |
337 | |
338 if(strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0) | |
339 { | |
340 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); | |
341 | |
342 if(oldbitmap) | |
343 DeleteObject(oldbitmap); | |
344 } | |
345 if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0) | |
346 { | |
347 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); | |
348 | |
349 if(oldbitmap) | |
350 DeleteObject(oldbitmap); | |
351 } | |
352 else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ | |
353 { | |
354 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); | |
355 | |
356 if(array) | |
357 { | |
358 int z, refid = -1; | |
359 | |
360 for(z=0;z<256;z++) | |
361 { | |
362 if(array[z]) | |
363 { | |
364 _free_window_memory(array[z]->hwnd, 0); | |
365 EnumChildWindows(array[z]->hwnd, _free_window_memory, 0); | |
366 DestroyWindow(array[z]->hwnd); | |
367 free(array[z]); | |
368 } | |
369 } | |
370 } | |
371 } | |
325 | 372 |
326 dw_signal_disconnect_by_window(handle); | 373 dw_signal_disconnect_by_window(handle); |
327 | 374 |
328 if(thiscinfo) | 375 if(thiscinfo) |
329 { | 376 { |
334 /* Free user data linked list memory */ | 381 /* Free user data linked list memory */ |
335 if(thiscinfo->root) | 382 if(thiscinfo->root) |
336 dw_window_set_data(handle, NULL, NULL); | 383 dw_window_set_data(handle, NULL, NULL); |
337 | 384 |
338 SetWindowLong(handle, GWL_USERDATA, 0); | 385 SetWindowLong(handle, GWL_USERDATA, 0); |
339 #if 0 | |
340 free(thiscinfo); | 386 free(thiscinfo); |
341 #endif | |
342 } | 387 } |
343 return TRUE; | 388 return TRUE; |
344 } | 389 } |
345 | 390 |
346 /* This function returns 1 if the window (widget) handle | 391 /* This function returns 1 if the window (widget) handle |
1004 | 1049 |
1005 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 1050 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
1006 { | 1051 { |
1007 /* Handle special case Combobox */ | 1052 /* Handle special case Combobox */ |
1008 MoveWindow(handle, currentx + pad, currenty + pad, | 1053 MoveWindow(handle, currentx + pad, currenty + pad, |
1009 width + vectorx, (height + vectory) + 400, TRUE); | 1054 width + vectorx, (height + vectory) + 400, FALSE); |
1010 } | 1055 } |
1011 else if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0) | 1056 else if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0) |
1012 { | 1057 { |
1013 /* Handle special case Spinbutton */ | 1058 /* Handle special case Spinbutton */ |
1014 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | 1059 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); |
1015 | 1060 |
1016 MoveWindow(handle, currentx + pad + ((width + vectorx) - 20), currenty + pad, | 1061 MoveWindow(handle, currentx + pad + ((width + vectorx) - 20), currenty + pad, |
1017 20, height + vectory, TRUE); | 1062 20, height + vectory, FALSE); |
1018 | 1063 |
1019 if(cinfo) | 1064 if(cinfo) |
1020 { | 1065 { |
1021 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad, | 1066 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad, |
1022 (width + vectorx) - 20, height + vectory, TRUE); | 1067 (width + vectorx) - 20, height + vectory, FALSE); |
1023 } | 1068 } |
1069 } | |
1070 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) | |
1071 { | |
1072 /* Then try the bottom or right box */ | |
1073 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); | |
1074 int type = (int)dw_window_get_data(handle, "_dw_type"); | |
1075 int cx = width + vectorx; | |
1076 int cy = height + vectory; | |
1077 | |
1078 MoveWindow(handle, currentx + pad, currenty + pad, | |
1079 cx, cy, FALSE); | |
1080 | |
1081 if(cx > 0 && cy > 0 && percent) | |
1082 _handle_splitbar_resize(handle, *percent, type, cx, cy); | |
1024 } | 1083 } |
1025 else if(strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0) | 1084 else if(strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0) |
1026 { | 1085 { |
1027 /* Handle special case Vertically Center static text */ | 1086 /* Handle special case Vertically Center static text */ |
1028 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | 1087 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); |
1039 dw_font_text_extents(handle, 0, tmpbuf, 0, &textheight); | 1098 dw_font_text_extents(handle, 0, tmpbuf, 0, &textheight); |
1040 | 1099 |
1041 diff = (total - textheight) / 2; | 1100 diff = (total - textheight) / 2; |
1042 | 1101 |
1043 MoveWindow(handle, currentx + pad, currenty + pad + diff, | 1102 MoveWindow(handle, currentx + pad, currenty + pad + diff, |
1044 width + vectorx, height + vectory - diff, TRUE); | 1103 width + vectorx, height + vectory - diff, FALSE); |
1045 } | 1104 } |
1046 else | 1105 else |
1047 { | 1106 { |
1048 MoveWindow(handle, currentx + pad, currenty + pad, | 1107 MoveWindow(handle, currentx + pad, currenty + pad, |
1049 width + vectorx, height + vectory, TRUE); | 1108 width + vectorx, height + vectory, FALSE); |
1050 } | 1109 } |
1051 } | 1110 } |
1052 else | 1111 else |
1053 { | 1112 { |
1054 /* Everything else */ | 1113 /* Everything else */ |
1055 MoveWindow(handle, currentx + pad, currenty + pad, | 1114 MoveWindow(handle, currentx + pad, currenty + pad, |
1056 width + vectorx, height + vectory, TRUE); | 1115 width + vectorx, height + vectory, FALSE); |
1057 if(thisbox->items[z].type == TYPEBOX) | 1116 if(thisbox->items[z].type == TYPEBOX) |
1058 { | 1117 { |
1059 Box *boxinfo = (Box *)GetWindowLong(handle, GWL_USERDATA); | 1118 Box *boxinfo = (Box *)GetWindowLong(handle, GWL_USERDATA); |
1060 | 1119 |
1061 if(boxinfo && boxinfo->grouphwnd) | 1120 if(boxinfo && boxinfo->grouphwnd) |
1062 MoveWindow(boxinfo->grouphwnd, 0, 0, | 1121 MoveWindow(boxinfo->grouphwnd, 0, 0, |
1063 width + vectorx, height + vectory, TRUE); | 1122 width + vectorx, height + vectory, FALSE); |
1064 | 1123 |
1065 } | 1124 } |
1066 } | 1125 } |
1067 | 1126 |
1068 /* Notebook dialog requires additional processing */ | 1127 /* Notebook dialog requires additional processing */ |
1075 if(pageid > -1 && array && array[pageid]) | 1134 if(pageid > -1 && array && array[pageid]) |
1076 { | 1135 { |
1077 GetClientRect(handle,&rect); | 1136 GetClientRect(handle,&rect); |
1078 TabCtrl_AdjustRect(handle,FALSE,&rect); | 1137 TabCtrl_AdjustRect(handle,FALSE,&rect); |
1079 MoveWindow(array[pageid]->hwnd, rect.left, rect.top, | 1138 MoveWindow(array[pageid]->hwnd, rect.left, rect.top, |
1080 rect.right - rect.left, rect.bottom-rect.top, TRUE); | 1139 rect.right - rect.left, rect.bottom-rect.top, FALSE); |
1081 } | 1140 } |
1082 } | 1141 } |
1083 | 1142 |
1084 if(thisbox->type == BOXHORZ) | 1143 if(thisbox->type == BOXHORZ) |
1085 currentx += width + vectorx + (pad * 2); | 1144 currentx += width + vectorx + (pad * 2); |
2245 { | 2304 { |
2246 if(type == BOXHORZ) | 2305 if(type == BOXHORZ) |
2247 { | 2306 { |
2248 int newx = x - SPLITBAR_WIDTH, newy = y; | 2307 int newx = x - SPLITBAR_WIDTH, newy = y; |
2249 float ratio = (float)percent/(float)100.0; | 2308 float ratio = (float)percent/(float)100.0; |
2250 HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); | 2309 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); |
2251 Box *tmp = (Box *)GetWindowLong(handle, GWL_USERDATA); | 2310 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); |
2311 Box *tmp = (Box *)GetWindowLong(handle1, GWL_USERDATA); | |
2252 | 2312 |
2253 newx = (int)((float)newx * ratio); | 2313 newx = (int)((float)newx * ratio); |
2254 | 2314 |
2255 SetWindowPos(handle, (HWND)NULL, 0, 0, newx, y, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); | 2315 ShowWindow(handle1, SW_HIDE); |
2316 ShowWindow(handle2, SW_HIDE); | |
2317 | |
2318 MoveWindow(handle1, 0, 0, newx, y, FALSE); | |
2256 _do_resize(tmp, newx, y); | 2319 _do_resize(tmp, newx, y); |
2257 | 2320 |
2258 handle = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); | 2321 tmp = (Box *)GetWindowLong(handle2, GWL_USERDATA); |
2259 tmp = (Box *)GetWindowLong(handle, GWL_USERDATA); | |
2260 | 2322 |
2261 newx = x - newx - SPLITBAR_WIDTH; | 2323 newx = x - newx - SPLITBAR_WIDTH; |
2262 | 2324 |
2263 SetWindowPos(handle, (HWND)NULL, x - newx, 0, newx, y, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); | 2325 MoveWindow(handle2, x - newx, 0, newx, y, FALSE); |
2264 _do_resize(tmp, newx, y); | 2326 _do_resize(tmp, newx, y); |
2327 | |
2328 ShowWindow(handle1, SW_SHOW); | |
2329 ShowWindow(handle2, SW_SHOW); | |
2265 | 2330 |
2266 dw_window_set_data(hwnd, "_dw_start", (void *)newx); | 2331 dw_window_set_data(hwnd, "_dw_start", (void *)newx); |
2267 } | 2332 } |
2268 else | 2333 else |
2269 { | 2334 { |
2270 int newx = x, newy = y - SPLITBAR_WIDTH; | 2335 int newx = x, newy = y - SPLITBAR_WIDTH; |
2271 float ratio = (float)(100.0-percent)/(float)100.0; | 2336 float ratio = (float)(100.0-percent)/(float)100.0; |
2272 HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); | 2337 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); |
2273 Box *tmp = (Box *)GetWindowLong(handle, GWL_USERDATA); | 2338 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); |
2339 Box *tmp = (Box *)GetWindowLong(handle1, GWL_USERDATA); | |
2274 | 2340 |
2275 newy = (int)((float)newy * ratio); | 2341 newy = (int)((float)newy * ratio); |
2276 | 2342 |
2277 SetWindowPos(handle, (HWND)NULL, 0, y - newy, x, newy, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); | 2343 ShowWindow(handle1, SW_HIDE); |
2344 ShowWindow(handle2, SW_HIDE); | |
2345 | |
2346 MoveWindow(handle1, 0, y - newy, x, newy, FALSE); | |
2278 _do_resize(tmp, x, newy); | 2347 _do_resize(tmp, x, newy); |
2279 | 2348 |
2280 handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); | 2349 tmp = (Box *)GetWindowLong(handle2, GWL_USERDATA); |
2281 tmp = (Box *)GetWindowLong(handle, GWL_USERDATA); | |
2282 | 2350 |
2283 newy = y - newy - SPLITBAR_WIDTH; | 2351 newy = y - newy - SPLITBAR_WIDTH; |
2284 | 2352 |
2285 SetWindowPos(handle, (HWND)NULL, 0, 0, x, newy, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); | 2353 MoveWindow(handle2, 0, 0, x, newy, FALSE); |
2286 _do_resize(tmp, x, newy); | 2354 _do_resize(tmp, x, newy); |
2355 | |
2356 ShowWindow(handle1, SW_SHOW); | |
2357 ShowWindow(handle2, SW_SHOW); | |
2287 | 2358 |
2288 dw_window_set_data(hwnd, "_dw_start", (void *)newy); | 2359 dw_window_set_data(hwnd, "_dw_start", (void *)newy); |
2289 } | 2360 } |
2290 } | 2361 } |
2291 | 2362 |
2300 { | 2371 { |
2301 case WM_ACTIVATE: | 2372 case WM_ACTIVATE: |
2302 case WM_SETFOCUS: | 2373 case WM_SETFOCUS: |
2303 return FALSE; | 2374 return FALSE; |
2304 | 2375 |
2305 case WM_SIZE: | 2376 case WM_PAINT: |
2306 { | 2377 { |
2307 int x = LOWORD(mp2), y = HIWORD(mp2); | 2378 PAINTSTRUCT ps; |
2308 | 2379 HDC hdcPaint; |
2309 if(x > 0 && y > 0 && percent) | 2380 |
2310 _handle_splitbar_resize(hwnd, *percent, type, x, y); | 2381 BeginPaint(hwnd, &ps); |
2311 } | 2382 |
2383 if((hdcPaint = GetDC(hwnd)) != NULL) | |
2384 { | |
2385 int cx, cy; | |
2386 HBRUSH oldBrush = SelectObject(hdcPaint, GetSysColorBrush(COLOR_3DFACE)); | |
2387 HPEN oldPen = SelectObject(hdcPaint, CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DFACE))); | |
2388 | |
2389 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy); | |
2390 | |
2391 if(type == BOXHORZ) | |
2392 Rectangle(hdcPaint, cx - start - 3, 0, cx - start, cy); | |
2393 else | |
2394 Rectangle(hdcPaint, 0, start, cx, start + 3); | |
2395 | |
2396 SelectObject(hdcPaint, oldBrush); | |
2397 DeleteObject(SelectObject(hdcPaint, oldPen)); | |
2398 ReleaseDC(hwnd, hdcPaint); | |
2399 } | |
2400 EndPaint(hwnd, &ps); | |
2401 } | |
2312 break; | 2402 break; |
2313 case WM_LBUTTONDOWN: | 2403 case WM_LBUTTONDOWN: |
2314 { | 2404 { |
2315 SetCapture(hwnd); | 2405 SetCapture(hwnd); |
2316 break; | 2406 break; |
2745 memset(&wc, 0, sizeof(WNDCLASS)); | 2835 memset(&wc, 0, sizeof(WNDCLASS)); |
2746 wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; | 2836 wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
2747 wc.lpfnWndProc = (WNDPROC)_splitwndproc; | 2837 wc.lpfnWndProc = (WNDPROC)_splitwndproc; |
2748 wc.cbClsExtra = 0; | 2838 wc.cbClsExtra = 0; |
2749 wc.cbWndExtra = 0; | 2839 wc.cbWndExtra = 0; |
2750 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE); | 2840 wc.hbrBackground = NULL; |
2751 wc.lpszMenuName = NULL; | 2841 wc.lpszMenuName = NULL; |
2752 wc.lpszClassName = SplitbarClassName; | 2842 wc.lpszClassName = SplitbarClassName; |
2753 | 2843 |
2754 RegisterClass(&wc); | 2844 RegisterClass(&wc); |
2755 | 2845 |
3050 } | 3140 } |
3051 | 3141 |
3052 thisbox->items = tmpitem; | 3142 thisbox->items = tmpitem; |
3053 free(thisitem); | 3143 free(thisitem); |
3054 thisbox->count--; | 3144 thisbox->count--; |
3145 _free_window_memory(handle, 0); | |
3146 EnumChildWindows(handle, _free_window_memory, 0); | |
3055 } | 3147 } |
3056 return DestroyWindow(handle); | 3148 return DestroyWindow(handle); |
3057 } | 3149 } |
3058 | 3150 |
3059 /* Causes entire window to be invalidated and redrawn. | 3151 /* Causes entire window to be invalidated and redrawn. |
3065 Box *mybox = (Box *)GetWindowLong(handle, GWL_USERDATA); | 3157 Box *mybox = (Box *)GetWindowLong(handle, GWL_USERDATA); |
3066 | 3158 |
3067 if(mybox) | 3159 if(mybox) |
3068 { | 3160 { |
3069 RECT rect; | 3161 RECT rect; |
3162 int istoplevel = (GetParent(handle) == HWND_DESKTOP); | |
3070 | 3163 |
3071 GetClientRect(handle, &rect); | 3164 GetClientRect(handle, &rect); |
3072 | 3165 |
3073 ShowWindow(mybox->items[0].hwnd, SW_HIDE); | 3166 ShowWindow(istoplevel ? mybox->items[0].hwnd : handle, SW_HIDE); |
3074 _do_resize(mybox, rect.right - rect.left, rect.bottom - rect.top); | 3167 _do_resize(mybox, rect.right - rect.left, rect.bottom - rect.top); |
3075 ShowWindow(mybox->items[0].hwnd, SW_SHOW); | 3168 ShowWindow(istoplevel ? mybox->items[0].hwnd : handle, SW_SHOW); |
3076 } | 3169 } |
3077 } | 3170 } |
3078 | 3171 |
3079 /* | 3172 /* |
3080 * Changes a window's parent to newparent. | 3173 * Changes a window's parent to newparent. |
3139 * handle: The window (widget) handle. | 3232 * handle: The window (widget) handle. |
3140 * fontname: Name and size of the font in the form "size.fontname" | 3233 * fontname: Name and size of the font in the form "size.fontname" |
3141 */ | 3234 */ |
3142 int dw_window_set_font(HWND handle, char *fontname) | 3235 int dw_window_set_font(HWND handle, char *fontname) |
3143 { | 3236 { |
3237 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | |
3144 HFONT hfont = _acquire_font(handle, fontname); | 3238 HFONT hfont = _acquire_font(handle, fontname); |
3145 ColorInfo *cinfo; | 3239 ColorInfo *cinfo; |
3146 | 3240 |
3147 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | 3241 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); |
3148 | 3242 |
3163 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); | 3257 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); |
3164 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); | 3258 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); |
3165 } | 3259 } |
3166 } | 3260 } |
3167 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); | 3261 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); |
3262 if(oldfont) | |
3263 DeleteObject(oldfont); | |
3168 return 0; | 3264 return 0; |
3169 } | 3265 } |
3170 | 3266 |
3171 /* | 3267 /* |
3172 * Sets the colors used by a specified window (widget) handle. | 3268 * Sets the colors used by a specified window (widget) handle. |
4169 * id: An ID to be used to specify the icon. | 4265 * id: An ID to be used to specify the icon. |
4170 */ | 4266 */ |
4171 void dw_window_set_bitmap(HWND handle, ULONG id) | 4267 void dw_window_set_bitmap(HWND handle, ULONG id) |
4172 { | 4268 { |
4173 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); | 4269 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); |
4270 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); | |
4174 | 4271 |
4175 SendMessage(handle, STM_SETIMAGE, | 4272 SendMessage(handle, STM_SETIMAGE, |
4176 (WPARAM) IMAGE_BITMAP, | 4273 (WPARAM) IMAGE_BITMAP, |
4177 (LPARAM) hbitmap); | 4274 (LPARAM) hbitmap); |
4275 | |
4276 if(oldbitmap) | |
4277 DeleteObject(oldbitmap); | |
4178 } | 4278 } |
4179 | 4279 |
4180 /* | 4280 /* |
4181 * Sets the text used for a given window. | 4281 * Sets the text used for a given window. |
4182 * Parameters: | 4282 * Parameters: |
5756 | 5856 |
5757 ListView_SetItem(handle, &lvi); | 5857 ListView_SetItem(handle, &lvi); |
5758 } | 5858 } |
5759 | 5859 |
5760 /* | 5860 /* |
5861 * Changes an existing item in specified row and column to the given data. | |
5862 * Parameters: | |
5863 * handle: Handle to the container window (widget). | |
5864 * column: Zero based column of data being set. | |
5865 * row: Zero based row of data being set. | |
5866 * data: Pointer to the data to be added. | |
5867 */ | |
5868 void dw_container_change_item(HWND handle, int column, int row, void *data) | |
5869 { | |
5870 dw_container_set_item(handle, NULL, column, row, data); | |
5871 } | |
5872 | |
5873 /* | |
5761 * Sets the width of a column in the container. | 5874 * Sets the width of a column in the container. |
5762 * Parameters: | 5875 * Parameters: |
5763 * handle: Handle to window (widget) of container. | 5876 * handle: Handle to window (widget) of container. |
5764 * column: Zero based column of width being set. | 5877 * column: Zero based column of width being set. |
5765 * width: Width of column in pixels. | 5878 * width: Width of column in pixels. |
5939 { | 6052 { |
5940 RECT viewport, item; | 6053 RECT viewport, item; |
5941 | 6054 |
5942 ListView_SetItemState(handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); | 6055 ListView_SetItemState(handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); |
5943 ListView_EnsureVisible(handle, index, TRUE); | 6056 ListView_EnsureVisible(handle, index, TRUE); |
6057 return; | |
6058 } | |
6059 | |
6060 index = ListView_GetNextItem(handle, index, LVNI_ALL); | |
6061 } | |
6062 } | |
6063 | |
6064 /* | |
6065 * Deletes the item with the text speficied. | |
6066 * Parameters: | |
6067 * handle: Handle to the window (widget). | |
6068 * text: Text usually returned by dw_container_query(). | |
6069 */ | |
6070 void dw_container_delete_row(HWND handle, char *text) | |
6071 { | |
6072 int index = ListView_GetNextItem(handle, -1, LVNI_ALL); | |
6073 | |
6074 while(index != -1) | |
6075 { | |
6076 LV_ITEM lvi; | |
6077 | |
6078 memset(&lvi, 0, sizeof(LV_ITEM)); | |
6079 | |
6080 lvi.iItem = index; | |
6081 lvi.mask = LVIF_PARAM; | |
6082 | |
6083 ListView_GetItem(handle, &lvi); | |
6084 | |
6085 if((char *)lvi.lParam == text) | |
6086 { | |
6087 ListView_DeleteItem(handle, index); | |
5944 return; | 6088 return; |
5945 } | 6089 } |
5946 | 6090 |
5947 index = ListView_GetNextItem(handle, index, LVNI_ALL); | 6091 index = ListView_GetNextItem(handle, index, LVNI_ALL); |
5948 } | 6092 } |