HRESULT CMiniMule::OnOpenIncomingFolder(IHTMLElement* pElement) { CCounter cc(m_iInCallback); if (theApp.emuledlg->IsRunning()) { theApp.emuledlg->SendMessage(WM_COMMAND, MP_HM_OPENINC); if (GetAutoClose()) PostMessage(WM_CLOSE); } return S_OK; }
HRESULT CMiniMule::OnOpenIncomingFolder(IHTMLElement* /*pElement*/) { ASSERT( GetCurrentThreadId() == _uMainThreadId ); CCounter cc(m_iInCallback); if (theApp.emuledlg->IsRunning()) { theApp.emuledlg->SendMessage(WM_COMMAND, MP_HM_OPENINC); if (GetAutoClose()) PostMessage(WM_CLOSE); } return S_OK; }
HRESULT CMiniMule::OnOptions(IHTMLElement* pElement) { CCounter cc(m_iInCallback); if (theApp.emuledlg->IsRunning()) { // showing the 'Pref' dialog will process the message queue -> timer messages will be dispatched -> kill auto close timer! KillAutoCloseTimer(); if (theApp.emuledlg->ShowPreferences() == -1) MessageBeep(MB_OK); if (GetAutoClose()) CreateAutoCloseTimer(); } return S_OK; }
void CMiniMule::OnClose() { ASSERT( m_iInCallback == 0 ); KillAutoCloseTimer(); if (GetAutoClose()) { BOOL (WINAPI *pfnAnimateWindow)(HWND hWnd, DWORD dwTime, DWORD dwFlags); (FARPROC&)pfnAnimateWindow = GetProcAddress(GetModuleHandle(_T("user32")), "AnimateWindow"); if (pfnAnimateWindow) (*pfnAnimateWindow)(m_hWnd, 200, AW_HIDE | AW_BLEND | AW_CENTER); } CDHtmlDialog::OnClose(); theApp.emuledlg->PostMessage(UM_CLOSE_MINIMULE, (WPARAM)m_bRestoreMainWnd); }
void CMiniMule::OnClose() { TRACE("%s\n", __FUNCTION__); ASSERT( GetCurrentThreadId() == _uMainThreadId ); ASSERT( m_iInCallback == 0 ); KillAutoCloseTimer(); if (GetAutoClose()) { BOOL (WINAPI *pfnAnimateWindow)(HWND hWnd, DWORD dwTime, DWORD dwFlags); (FARPROC&)pfnAnimateWindow = GetProcAddress(GetModuleHandle(_T("user32")), "AnimateWindow"); if (pfnAnimateWindow) (*pfnAnimateWindow)(m_hWnd, 200, AW_HIDE | AW_BLEND | AW_CENTER); } CDHtmlDialog::OnClose(); /////////////////////////////////////////////////////////////////////////// // Destroy the MiniMule window // Solution #1: Posting a close-message to main window (can not be done with 'SendMessage') may // create message queue sync. problems when having high system load. //theApp.emuledlg->PostMessage(UM_CLOSE_MINIMULE, (WPARAM)m_bRestoreMainWnd); // Solution #2: 'DestroyModeless' -- posts a 'destroy' message to 'this' which will have a very // similar effect (and most likely problems) than using PostMessage(<main-window>). //DestroyModeless(); // Solution #3: 'DestroyWindow' -- destroys the window and *deletes* 'this'. On return of // 'DestroyWindow' the 'this' is no longer valid! However, this should be safe because MFC // is also using the same 'technique' for several window classes. theApp.emuledlg->m_pMiniMule = NULL; bool bRestoreMainWnd = m_bRestoreMainWnd; DestroyWindow(); //NOTE: 'this' IS NO LONGER VALID! if (bRestoreMainWnd) theApp.emuledlg->RestoreWindow(); }