From f9aaee3029230a7541d3b859ef801ce9004fdb72 Mon Sep 17 00:00:00 2001 From: sje Date: Fri, 27 Apr 2007 04:45:36 +0000 Subject: added 'remove frame' service destroy services on unload git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@163 4f64403b-2f21-0410-a795-97e2b3489a10 --- xframes/frames.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'xframes/frames.cpp') diff --git a/xframes/frames.cpp b/xframes/frames.cpp index 7130257..b16dc78 100644 --- a/xframes/frames.cpp +++ b/xframes/frames.cpp @@ -429,6 +429,33 @@ int AddFrame(WPARAM wParam, LPARAM lParam) { return node->id; } +int RemoveFrame(WPARAM wParam, LPARAM lParam) { + int id = (int)wParam; + struct FrameListNode *current, *prev = 0; + + EnterCriticalSection(&cs); + current = frame_list; + while(current) { + if(current->id == id) { + if(!prev) frame_list = current->next; + else prev->next = current->next; + break; + } + prev = current; + current = current->next; + } + LeaveCriticalSection(&cs); + + if(current) { + DestroyWindow(current->hwndParent); + free(current->frame_data.name); + free(current); + + return 0; + } + return 1; +} + int ShowHideFrame(WPARAM wParam, LPARAM lParam) { int id = (int)wParam; struct FrameListNode *node = GetFrame(id); @@ -537,13 +564,21 @@ int SetFrameOptions(WPARAM wParam, LPARAM lParam) { return 0; } +HANDLE hServices[7] = {0}; + void MakeFrameServices() { - CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME, AddFrame); - CreateServiceFunction(MS_CLIST_FRAMES_SHFRAME, ShowHideFrame); - CreateServiceFunction(MS_CLIST_FRAMES_UPDATEFRAME, UpdateFrame); - CreateServiceFunction(MS_CLIST_FRAMES_GETFRAMEOPTIONS, GetFrameOptions); - CreateServiceFunction(MS_CLIST_FRAMES_SETFRAMEOPTIONS, SetFrameOptions); - CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMES, ShowAllFrames); + hServices[0] = CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME, AddFrame); + hServices[1] = CreateServiceFunction(MS_CLIST_FRAMES_SHFRAME, ShowHideFrame); + hServices[2] = CreateServiceFunction(MS_CLIST_FRAMES_UPDATEFRAME, UpdateFrame); + hServices[3] = CreateServiceFunction(MS_CLIST_FRAMES_GETFRAMEOPTIONS, GetFrameOptions); + hServices[4] = CreateServiceFunction(MS_CLIST_FRAMES_SETFRAMEOPTIONS, SetFrameOptions); + hServices[5] = CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMES, ShowAllFrames); + hServices[6] = CreateServiceFunction(MS_CLIST_FRAMES_REMOVEFRAME, RemoveFrame); +} + +void DestroyFrameServices() { + for(int i = 0; i < 7; i++) + DestroyServiceFunction(hServices[i]); } void AddMainMenuItem() { @@ -848,6 +883,7 @@ void InitFrames() { void DeinitFrames() { struct FrameListNode *current; + DestroyFrameServices(); UnsubclassCListWndProc(); EnterCriticalSection(&cs); -- cgit v1.2.3