Mercurial > dwindows
comparison os2/dw.c @ 468:0a2f13ba2d5c
More menu fixes, free signal handlers and memory on OS/2, and the begining
for Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 08 Oct 2003 21:40:06 +0000 |
parents | c3dfa117b080 |
children | 6ccac112f1e5 |
comparison
equal
deleted
inserted
replaced
467:ecf1df2edcee | 468:0a2f13ba2d5c |
---|---|
34 void _do_resize(Box *thisbox, int x, int y); | 34 void _do_resize(Box *thisbox, int x, int y); |
35 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); | 35 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); |
36 int _load_bitmap_file(char *file, HWND handle, HBITMAP *hbm, HDC *hdc, HPS *hps, unsigned long *width, unsigned long *height); | 36 int _load_bitmap_file(char *file, HWND handle, HBITMAP *hbm, HDC *hdc, HPS *hps, unsigned long *width, unsigned long *height); |
37 void _dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname); | 37 void _dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname); |
38 void _dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname); | 38 void _dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname); |
39 void _free_menu_data(HWND menu); | |
39 | 40 |
40 char ClassName[] = "dynamicwindows"; | 41 char ClassName[] = "dynamicwindows"; |
41 char SplitbarClassName[] = "dwsplitbar"; | 42 char SplitbarClassName[] = "dwsplitbar"; |
42 char *DefaultFont = "9.WarpSans"; | 43 char *DefaultFont = "9.WarpSans"; |
43 | 44 |
286 HWND child; | 287 HWND child; |
287 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER); | 288 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER); |
288 | 289 |
289 dw_signal_disconnect_by_window(handle); | 290 dw_signal_disconnect_by_window(handle); |
290 | 291 |
292 if((child = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE) | |
293 _free_menu_data(child); | |
294 | |
291 if((child = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE) | 295 if((child = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE) |
292 { | 296 { |
293 Box *box = (Box *)WinQueryWindowPtr(child, QWP_USER); | 297 Box *box = (Box *)WinQueryWindowPtr(child, QWP_USER); |
294 | 298 |
295 if(box) | 299 if(box) |
350 while((child = WinGetNextWindow(henum)) != NULLHANDLE) | 354 while((child = WinGetNextWindow(henum)) != NULLHANDLE) |
351 _free_window_memory(child); | 355 _free_window_memory(child); |
352 | 356 |
353 WinEndEnumWindows(henum); | 357 WinEndEnumWindows(henum); |
354 return; | 358 return; |
359 } | |
360 | |
361 void _free_menu_data(HWND menu) | |
362 { | |
363 int i, count = (int)WinSendMsg(menu, MM_QUERYITEMCOUNT, 0, 0);; | |
364 | |
365 dw_signal_disconnect_by_name(menu, DW_SIGNAL_CLICKED); | |
366 _free_window_memory(menu); | |
367 | |
368 for(i=0;i<count;i++) | |
369 { | |
370 SHORT menuid = (SHORT)WinSendMsg(menu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(i), 0); | |
371 MENUITEM mi; | |
372 | |
373 if(WinSendMsg(menu, MM_QUERYITEM, MPFROMSHORT(menuid), MPFROMP(&mi)) | |
374 && mi.hwndSubMenu) | |
375 _free_menu_data(mi.hwndSubMenu); | |
376 } | |
355 } | 377 } |
356 | 378 |
357 /* This function returns 1 if the window (widget) handle | 379 /* This function returns 1 if the window (widget) handle |
358 * passed to it is a valid window that can gain input focus. | 380 * passed to it is a valid window that can gain input focus. |
359 */ | 381 */ |
2616 _shift_focus(hWnd); | 2638 _shift_focus(hWnd); |
2617 return FALSE; | 2639 return FALSE; |
2618 } | 2640 } |
2619 break; | 2641 break; |
2620 case WM_DESTROY: | 2642 case WM_DESTROY: |
2621 /* Free memory before destroying */ | 2643 { |
2622 _free_window_memory(hWnd); | 2644 HWND parent = WinQueryWindow(hWnd, QW_PARENT); |
2645 | |
2646 /* Free memory before destroying */ | |
2647 if(parent && WinWindowFromID(parent, FID_CLIENT) == hWnd) | |
2648 _free_window_memory(parent); | |
2649 else | |
2650 _free_window_memory(hWnd); | |
2651 } | |
2623 break; | 2652 break; |
2624 case WM_MENUEND: | 2653 case WM_MENUEND: |
2625 _clear_emphasis(); | 2654 _clear_emphasis(); |
2655 if(dw_window_get_data((HWND)mp2, "_dw_popup")) | |
2656 _free_menu_data((HWND)mp2); | |
2626 break; | 2657 break; |
2627 } | 2658 } |
2628 | 2659 |
2629 if(result != -1) | 2660 if(result != -1) |
2630 return (MRESULT)result; | 2661 return (MRESULT)result; |
3532 * Parameters: | 3563 * Parameters: |
3533 * handle: The window handle to destroy. | 3564 * handle: The window handle to destroy. |
3534 */ | 3565 */ |
3535 int API dw_window_destroy(HWND handle) | 3566 int API dw_window_destroy(HWND handle) |
3536 { | 3567 { |
3537 HWND frame, parent = WinQueryWindow(handle, QW_PARENT); | 3568 HWND frame, menu, parent = WinQueryWindow(handle, QW_PARENT); |
3538 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); | 3569 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); |
3539 | 3570 |
3540 if(!handle) | 3571 if(!handle) |
3541 return -1; | 3572 return -1; |
3542 | 3573 |
3543 frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); | 3574 frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); |
3575 | |
3576 if((menu = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE) | |
3577 _free_menu_data(menu); | |
3544 | 3578 |
3545 if(parent != desktop && thisbox && thisbox->count) | 3579 if(parent != desktop && thisbox && thisbox->count) |
3546 { | 3580 { |
3547 int z, index = -1; | 3581 int z, index = -1; |
3548 Item *tmpitem, *thisitem = thisbox->items; | 3582 Item *tmpitem, *thisitem = thisbox->items; |