--- trunk/xvidcore/dshow/src/CXvidDecoder.cpp 2010/10/24 08:50:54 1900 +++ trunk/xvidcore/dshow/src/CXvidDecoder.cpp 2010/10/29 14:33:39 1901 @@ -20,7 +20,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: CXvidDecoder.cpp,v 1.21 2010-10-17 18:36:12 Isibaar Exp $ + * $Id: CXvidDecoder.cpp,v 1.22 2010-10-29 14:33:39 Isibaar Exp $ * ****************************************************************************/ @@ -170,6 +170,7 @@ extern HINSTANCE g_xvid_hInst; static int GUI_Page = 0; +static int Tray_Icon = 0; extern "C" void CALLBACK Configure(HWND hWndParent, HINSTANCE hInstParent, LPSTR lpCmdLine, int nCmdShow ); LRESULT CALLBACK msg_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -190,7 +191,17 @@ return DefWindowProc(hwnd, uMsg, wParam, lParam); }; break; + + case WM_DESTROY: + NOTIFYICONDATA nid; + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + + nid.cbSize = NOTIFYICONDATA_V1_SIZE; + nid.hWnd = hwnd; + nid.uID = 1456; + Shell_NotifyIcon(NIM_DELETE, &nid); + Tray_Icon = 0; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } @@ -301,10 +312,6 @@ xvid_decore_func = NULL; // Hmm, some strange errors appearing if I try to initialize... xvid_global_func = NULL; // ...this in constructor's init-list. So, they assigned here. -#ifdef XVID_USE_TRAYICON - MSG_hwnd = NULL; -#endif - #if defined(XVID_USE_MFT) InitializeCriticalSection(&m_mft_lock); m_pInputType = NULL; @@ -456,22 +463,24 @@ CXvidDecoder::~CXvidDecoder() { DPRINTF("Destructor"); - CloseLib(); #ifdef XVID_USE_TRAYICON - if (MSG_hwnd != NULL) { + if (Tray_Icon) { /* Destroy tray icon */ NOTIFYICONDATA nid; - nid.cbSize = sizeof(NOTIFYICONDATA); + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + + nid.cbSize = NOTIFYICONDATA_V1_SIZE; nid.hWnd = MSG_hwnd; - nid.uID = 100; + nid.uID = 1456; - Shell_NotifyIcon(NIM_DELETE, &nid); - - DestroyWindow(MSG_hwnd); - MSG_hwnd = NULL; + Shell_NotifyIcon(NIM_DELETE, &nid); + Tray_Icon = 0; } #endif + /* Close xvidcore library */ + CloseLib(); + #if defined(XVID_USE_MFT) DeleteCriticalSection(&m_mft_lock); #endif @@ -874,7 +883,7 @@ DPRINTF("CompleteConnect"); #ifdef XVID_USE_TRAYICON - if ((direction == PINDIR_OUTPUT) && (MSG_hwnd == NULL)) + if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)) { WNDCLASSEX wc; @@ -897,17 +906,20 @@ /* display the tray icon */ NOTIFYICONDATA nid; - - nid.cbSize = sizeof(NOTIFYICONDATA); + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + + nid.cbSize = NOTIFYICONDATA_V1_SIZE; nid.hWnd = MSG_hwnd; - nid.uID = 100; - nid.uVersion = NOTIFYICON_VERSION; + nid.uID = 1456; nid.uCallbackMessage = WM_ICONMESSAGE; nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; Shell_NotifyIcon(NIM_ADD, &nid); + + DestroyIcon(nid.hIcon); + Tray_Icon = 1; } #endif @@ -919,22 +931,6 @@ { DPRINTF("BreakConnect"); -#ifdef XVID_USE_TRAYICON - if ((direction == PINDIR_OUTPUT) && (MSG_hwnd != NULL)) { - NOTIFYICONDATA nid; - - nid.cbSize = sizeof(NOTIFYICONDATA); - nid.hWnd = MSG_hwnd; - nid.uID = 100; - nid.uVersion = NOTIFYICON_VERSION; - - if(Shell_NotifyIcon(NIM_DELETE, &nid) == TRUE) { - DestroyWindow(MSG_hwnd); - MSG_hwnd = NULL; - } - } -#endif - return S_OK; } @@ -1584,7 +1580,7 @@ } #ifdef XVID_USE_TRAYICON - if (SUCCEEDED(hr) && MSG_hwnd == NULL) /* Create message passing window */ + if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */ { WNDCLASSEX wc; @@ -1607,17 +1603,20 @@ /* display the tray icon */ NOTIFYICONDATA nid; - - nid.cbSize = sizeof(NOTIFYICONDATA); + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + + nid.cbSize = NOTIFYICONDATA_V1_SIZE; nid.hWnd = MSG_hwnd; - nid.uID = 100; - nid.uVersion = NOTIFYICON_VERSION; + nid.uID = 1456; nid.uCallbackMessage = WM_ICONMESSAGE; nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; Shell_NotifyIcon(NIM_ADD, &nid); + + DestroyIcon(nid.hIcon); + Tray_Icon = 1; } #endif