/***********************************************************************/ /* Copyright (C) 2002 Definitive Solutions, Inc. All Rights Reserved. */ /* THIS COMPUTER PROGRAM IS PROPRIETARY AND CONFIDENTIAL TO DEFINITIVE */ /* SOLUTIONS, INC. AND ITS LICENSORS AND CONTAINS TRADE SECRETS OF */ /* DEFINITIVE SOLUTIONS, INC. THAT ARE PROVIDED PURSUANT TO A WRITTEN */ /* AGREEMENT CONTAINING RESTRICTIONS ON USE AND DISCLOSURE. ANY USE, */ /* REPRODUCTION, OR TRANSFER EXCEPT AS PROVIDED IN SUCH AGREEMENT */ /* IS STRICTLY PROHIBITED. */ /***********************************************************************/ #include "stdafx.h" // See the MyApp.h file for more information on this #define. #define MYAPPCPP_BUILDING_ #include "MyApp.h" #include "MyRegistry.h" #include "Generic.h" #include // COleMessageFilter #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // MyApp IMPLEMENT_DYNCREATE(MyApp, CWinApp) // Constructor. MyApp::MyApp(const CString& sLogFileName) : TheLog(sLogFileName) { HRESULT hr(S_OK); // Initialize the OLE DLLs. Can fail if incorrect versions of the OLE // system DLLs are installed. Required, so that a COleMessageFilter // CWinApp member gets initialized, for use by AfxOleGetMessageFilter(). if (! AfxGetModuleState()->m_bDLL) { EC_B(AfxOleInit()); // "Prevent Server Busy Dialog Box From Appearing During a Lengthy COM // Operation" (Q248019). Change from default of 5 seconds to 60 seconds. if (SUCCEEDED(hr)) { if (AfxOleGetMessageFilter()) { AfxOleGetMessageFilter()->EnableBusyDialog(false); AfxOleGetMessageFilter()->EnableNotRespondingDialog(false); //AfxOleGetMessageFilter()->SetMessagePendingDelay(60 * 1000); } else { _ASSERTE(! "Error"); DOMYLOGE ("AfxOleGetMessageFilter() failed. AfxOleInit() must be " "called in this applications's InitInstance - see Q248019. " "This may not apply to DLLs - not sure.\n"); } } } } // Default constructor. MyApp::MyApp() : TheLog("__Unused__") { _ASSERTE(! "This constructor is required by MFC, but never called."); } // Destructor. /* virtual */ MyApp::~MyApp() { } // Called once per program run. /* virtual */ BOOL MyApp::InitInstance() { VALIDATE; // Read tool tip sound setting from Registry. if (! GetCompanyName().IsEmpty()) { CString sKey("Software\\" + GetCompanyName() + "\\" + AfxGetAppName() + "\\MyToolTipCtrl"); MyRegistry reg(HKEY_CURRENT_USER, sKey, /* bCreate */ true); if (reg.IsOpen()) { reg.ReadValueBool("MyToolTipSound", m_bIsToolTipSoundEnabled); } } CWinApp::InitInstance(); return TRUE; } // Called once per program run. int MyApp::ExitInstance() { VALIDATE; return CWinApp::ExitInstance(); } BEGIN_MESSAGE_MAP(MyApp, CWinApp) //{{AFX_MSG_MAP(MyApp) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // MyApp message handlers // Derived classes must implement this! /* virtual */ CString MyApp::GetCompanyName() const { VALIDATE; TRACE("You must override MyApp::GetCompanyName() in your MyApp-derived class!\n"); return ""; } // Read the cached value. bool MyApp::GetToolTipSoundEnabled() const { VALIDATE; return m_bIsToolTipSoundEnabled; } // Set the cached value. void MyApp::SetToolTipSoundEnabled(bool b) { VALIDATE; // Write to the Registry. if (! GetCompanyName().IsEmpty()) { CString sKey("Software\\" + GetCompanyName() + "\\" + AfxGetAppName() + "\\MyToolTipCtrl"); MyRegistry reg(HKEY_CURRENT_USER, sKey, /* bCreate */ true); if (reg.IsOpen()) { VERIFY(reg.SaveValueBool("MyToolTipSound", b)); } // Update the cache. m_bIsToolTipSoundEnabled = b; } }