Mercurial > dwindows
diff 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 |
line wrap: on
line diff
--- a/os2/dw.c Wed Oct 08 10:01:09 2003 +0000 +++ b/os2/dw.c Wed Oct 08 21:40:06 2003 +0000 @@ -36,6 +36,7 @@ int _load_bitmap_file(char *file, HWND handle, HBITMAP *hbm, HDC *hdc, HPS *hps, unsigned long *width, unsigned long *height); void _dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname); void _dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname); +void _free_menu_data(HWND menu); char ClassName[] = "dynamicwindows"; char SplitbarClassName[] = "dwsplitbar"; @@ -288,6 +289,9 @@ dw_signal_disconnect_by_window(handle); + if((child = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE) + _free_menu_data(child); + if((child = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE) { Box *box = (Box *)WinQueryWindowPtr(child, QWP_USER); @@ -354,6 +358,24 @@ return; } +void _free_menu_data(HWND menu) +{ + int i, count = (int)WinSendMsg(menu, MM_QUERYITEMCOUNT, 0, 0);; + + dw_signal_disconnect_by_name(menu, DW_SIGNAL_CLICKED); + _free_window_memory(menu); + + for(i=0;i<count;i++) + { + SHORT menuid = (SHORT)WinSendMsg(menu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(i), 0); + MENUITEM mi; + + if(WinSendMsg(menu, MM_QUERYITEM, MPFROMSHORT(menuid), MPFROMP(&mi)) + && mi.hwndSubMenu) + _free_menu_data(mi.hwndSubMenu); + } +} + /* This function returns 1 if the window (widget) handle * passed to it is a valid window that can gain input focus. */ @@ -2618,11 +2640,20 @@ } break; case WM_DESTROY: - /* Free memory before destroying */ - _free_window_memory(hWnd); + { + HWND parent = WinQueryWindow(hWnd, QW_PARENT); + + /* Free memory before destroying */ + if(parent && WinWindowFromID(parent, FID_CLIENT) == hWnd) + _free_window_memory(parent); + else + _free_window_memory(hWnd); + } break; case WM_MENUEND: _clear_emphasis(); + if(dw_window_get_data((HWND)mp2, "_dw_popup")) + _free_menu_data((HWND)mp2); break; } @@ -3534,7 +3565,7 @@ */ int API dw_window_destroy(HWND handle) { - HWND frame, parent = WinQueryWindow(handle, QW_PARENT); + HWND frame, menu, parent = WinQueryWindow(handle, QW_PARENT); Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); if(!handle) @@ -3542,6 +3573,9 @@ frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); + if((menu = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE) + _free_menu_data(menu); + if(parent != desktop && thisbox && thisbox->count) { int z, index = -1;