// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #if !defined(AFX_STDAFX_H__5B5ECFB3_4FF6_4FD7_9854_14531AE40C54__INCLUDED_) #define AFX_STDAFX_H__5B5ECFB3_4FF6_4FD7_9854_14531AE40C54__INCLUDED_ // Change these values to use different versions #define WINVER 0x0400 #define _WIN32_IE 0x0400 #define _RICHEDIT_VER 0x0100 #include #include #include "SingleInstance.H" const int c_Msg_NewDocument = WM_USER+256; //--------------------------------------------------------------------------------- class CMySingleInstanceMgr : public CSingleInstanceMgr { public: virtual PFNCALLBACK GetDDeCallBack() { return CMySingleInstanceMgr::DdeCallback; } static HDDEDATA CALLBACK DdeCallback(UINT uType, UINT, HCONV ,HSZ hszTopic, HSZ , HDDEDATA hDdeData, DWORD, DWORD); }; //--------------------------------------------------------------------------------- class CMySingleInstanceModule : public CAppModule { public: HRESULT Init(LPTSTR lpCmdLine, _ATL_OBJMAP_ENTRY* p, HINSTANCE h, const GUID* plibid = NULL) { HRESULT hr = CAppModule::Init(NULL,h); m_SingleInstance.Start(lpCmdLine); return hr; } void Term() { m_SingleInstance.End(); CAppModule::Term(); } //Called from the 2nd instance void InvokeCmdLine(LPTSTR psz) { lstrcpy(m_pszCmdLine,psz); //send the cmd line to the mainframe SendMessage(m_hWndApp, c_Msg_NewDocument,0,(LPARAM)m_pszCmdLine); } bool IsAnInstanceRunning() { return m_SingleInstance.IsAnInstanceRunning(); } DWORD GetInstanceID() { return m_SingleInstance.GetInstanceID(); } void SetAppWnd(HWND& hWnd) { m_hWndApp = hWnd; } HWND GetAppWnd(void) { return m_hWndApp; } private: CMySingleInstanceMgr m_SingleInstance; HWND m_hWndApp; TCHAR m_pszCmdLine[256]; }; extern CMySingleInstanceModule _Module; #include #include #include #include //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_STDAFX_H__5B5ECFB3_4FF6_4FD7_9854_14531AE40C54__INCLUDED_)