示例#1
0
//***********************************************************************************
BOOL CBCGWorkspace::IsStateExists(LPCTSTR lpszSectionName /*=NULL*/)
{
	 if (lpszSectionName != NULL)
	 {
		m_strRegSection = lpszSectionName;
	 }

	 CString strSection = GetRegSectionPath ();

	//------------------------
	// Loaded library version:
	//------------------------
	 CBCGRegistrySP regSP;
	 CBCGRegistry& reg = regSP.Create (FALSE, TRUE);

	 return reg.Open (GetRegSectionPath (strRegEntryVersion));
}
示例#2
0
//*************************************************************************************
BOOL CBCGWorkspace::CleanState (LPCTSTR lpszSectionName /*=NULL*/)
{
	if (lpszSectionName != NULL)
	{
		m_strRegSection = lpszSectionName;
	}

	CString strSection = GetRegSectionPath ();

	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, FALSE);

	return reg.DeleteKey(strSection);
}
示例#3
0
//***********************************************************************************
BOOL CBCGWorkspace::StoreWindowPlacement (
					const CRect& rectNormalPosition, int nFlags, int nShowCmd)
{
	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, FALSE);

	if (!reg.CreateKey (GetRegSectionPath (strWindowPlacementRegSection)))
	{
		return FALSE;
	}

	return	reg.Write (strRectMainKey, rectNormalPosition) &&
			reg.Write (strFlagsKey, nFlags) &&
			reg.Write (strShowCmdKey, nShowCmd);
}
示例#4
0
//***********************************************************************************
BOOL CBCGWorkspace::LoadWindowPlacement (
					CRect& rectNormalPosition, int& nFlags, int& nShowCmd)
{
	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, TRUE);

	if (!reg.Open (GetRegSectionPath (strWindowPlacementRegSection)))
	{
		return FALSE;
	}

	return	reg.Read (strRectMainKey, rectNormalPosition) &&
			reg.Read (strFlagsKey, nFlags) &&
			reg.Read (strShowCmdKey, nShowCmd);
}
示例#5
0
BOOL CBCGPIE7DemoApp::SaveAllModified()
{
	if (!CWinApp::SaveAllModified ())
	{
		return FALSE;
	}

	CBCGPMDIFrameWnd* pMainFrame = 
		DYNAMIC_DOWNCAST (CBCGPMDIFrameWnd, m_pMainWnd);
	if (pMainFrame != NULL)
	{
		pMainFrame->SaveMDIState (GetRegSectionPath ());
	}

	return TRUE;
}
示例#6
0
//*************************************************************************************
BOOL CBCGWorkspace::WriteSectionInt( LPCTSTR lpszSubSection, LPCTSTR lpszEntry, int nValue )
{
	ASSERT(lpszSubSection);
	ASSERT(lpszEntry);
	
	CString strSection = GetRegSectionPath(lpszSubSection);

	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, FALSE);

	if (reg.CreateKey (strSection))
	{
		return reg.Write (lpszEntry, nValue);
	}
	return FALSE;
}
示例#7
0
//*************************************************************************************
BOOL CBCGWorkspace::GetSectionObject(LPCTSTR lpszSubSection, LPCTSTR lpszEntry, CObject& obj)
{
	ASSERT(lpszSubSection);
	ASSERT(lpszEntry);
	ASSERT_VALID(&obj);
	
	CString strSection = GetRegSectionPath(lpszSubSection);

	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, TRUE);

	if (reg.Open (strSection) && reg.Read (lpszEntry, obj)) 
	{
		return TRUE;
	}
	return FALSE;
}
示例#8
0
//*************************************************************************************
BOOL CBCGWorkspace::WriteSectionBinary(LPCTSTR lpszSubSection, LPCTSTR lpszEntry, LPBYTE pData, UINT nBytes)
{
	ASSERT(lpszSubSection);
	ASSERT(lpszEntry);
	ASSERT(pData);

	CString strSection = GetRegSectionPath(lpszSubSection);

	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, FALSE);

	if (reg.CreateKey (strSection))
	{
		return reg.Write (lpszEntry, pData, nBytes);
	}
	return FALSE;
}
示例#9
0
//*************************************************************************************
BOOL CBCGWorkspace::GetSectionBinary(LPCTSTR lpszSubSection, LPCTSTR lpszEntry, LPBYTE* ppData, UINT* pBytes)
{
	ASSERT(lpszSubSection);
	ASSERT(lpszEntry);
	ASSERT(ppData);
	
	CString strSection = GetRegSectionPath(lpszSubSection);

	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, TRUE);

	if (reg.Open (strSection) 
		&& reg.Read (lpszEntry, ppData, pBytes) ) 
	{
		return TRUE;
	}
	return FALSE;
}
示例#10
0
//*************************************************************************************
//*************************************************************************************
// These functions load and store values from a given subkey
// of the "Custom" subkey. For simpler access you may use
// GetInt() etc.
int CBCGWorkspace::GetSectionInt( LPCTSTR lpszSubSection, LPCTSTR lpszEntry, int nDefault /*= 0*/)
{
	ASSERT(lpszSubSection);
	ASSERT(lpszEntry);
	
	int nRet = nDefault;

	CString strSection = GetRegSectionPath(lpszSubSection);

	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, TRUE);

	if (reg.Open (strSection))
	{
		reg.Read (lpszEntry, nRet);
	}
	return nRet;
}
示例#11
0
//*************************************************************************************
BOOL CBCGWorkspace::WriteSectionObject(LPCTSTR lpszSubSection, LPCTSTR lpszEntry, CObject& obj)
{
	ASSERT(lpszSubSection);
	ASSERT(lpszEntry);
	ASSERT_VALID(&obj);

	CString strSection = GetRegSectionPath(lpszSubSection);

	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, FALSE);

	if (reg.CreateKey (strSection))
	{
		return reg.Write (lpszEntry, obj);
	}

	return FALSE;
}
示例#12
0
//*************************************************************************************
CString CBCGWorkspace::GetSectionString( LPCTSTR lpszSubSection, LPCTSTR lpszEntry, LPCTSTR lpszDefault /*= ""*/)
{
	ASSERT(lpszSubSection);
	ASSERT(lpszEntry);
	ASSERT(lpszDefault);
	
	CString strRet = lpszDefault;

	CString strSection = GetRegSectionPath(lpszSubSection);

	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, TRUE);

	if (reg.Open (strSection))
	{
		reg.Read (lpszEntry, strRet);
	}
	return strRet;
}
示例#13
0
BOOL CTest2App::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();

	globalData.SetDPIAware ();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("BCGP AppWizard-Generated Applications"));
	LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)

	SetRegistryBase (_T("Settings"));

	// Initialize all Managers for usage. They are automatically constructed
	// if not yet present
	InitContextMenuManager();
	InitKeyboardManager();

	// TODO: Remove this if you don't want extended tooltips:
	InitTooltipManager();

	CBCGPToolTipParams params;
	params.m_bVislManagerTheme = TRUE;

	theApp.GetTooltipManager ()->SetTooltipParams (
		BCGP_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS (CBCGPToolTipCtrl),
		&params);

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(IDR_Test2TYPE,
		RUNTIME_CLASS(CTest2Doc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CTest2View));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;
	// call DragAcceptFiles only if there's a suffix
	//  In an MDI app, this should occur immediately after setting m_pMainWnd


	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);


	if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
	{
		if (!pMainFrame->LoadMDIState (GetRegSectionPath ()))
		{
			if (!ProcessShellCommand(cmdInfo))
				return FALSE;
		}
	}
	else
	{
		// Dispatch commands specified on the command line
		if (!ProcessShellCommand(cmdInfo))
			return FALSE;
	}
	// The main window has been initialized, so show and update it
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}
示例#14
0
//*************************************************************************************
BOOL CBCGWorkspace::SaveState (LPCTSTR lpszSectionName  /*=NULL*/, CBCGFrameImpl* pFrameImpl /*= NULL*/)
{
	if (!m_bSaveState)
	{
		return FALSE;
	}

	if (lpszSectionName != NULL)
	{
		m_strRegSection = lpszSectionName;
	}

	CString strSection = GetRegSectionPath ();

	//-----------------------------
	// Other things to do before ?:
	//-----------------------------
	PreSaveState();

	//----------------------
	// Save library version:
	//----------------------
	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, FALSE);

	if (reg.CreateKey (GetRegSectionPath (strRegEntryVersion)))
	{
		reg.Write (strVersionMajorKey, _BCGCB_VERSION_MAJOR);
		reg.Write (strVersionMinorKey, _BCGCB_VERSION_MINOR);
	}

	//--------------------------------------
	// Save general toolbar/menu parameters:
	//--------------------------------------
	CBCGToolBar::SaveParameters (strSection);
	CMD_MGR.SaveState (strSection);

	if (pFrameImpl != NULL) 
	{
		CBCGDockState dockState;
		
		pFrameImpl->m_pFrame->GetDockState (dockState);
		dockState.SaveState (m_strRegSection + strRegEntryNameControlBars);

		//-----------------------------------------------------
		// Save all toolbars, menubar and docking control bars:
		//-----------------------------------------------------
		for (POSITION posTlb = gAllToolbars.GetHeadPosition (); posTlb != NULL;)
		{
			CBCGToolBar* pToolBar = (CBCGToolBar*) gAllToolbars.GetNext (posTlb);
			ASSERT (pToolBar != NULL);

			if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
			{
				ASSERT_VALID(pToolBar);

				if (!m_bLoadSaveFrameBarsOnly ||
					pToolBar->GetTopLevelFrame () == pFrameImpl->m_pFrame)
				{
					if (!pToolBar->m_bLocked && 
						!pFrameImpl->IsUserDefinedToolbar (pToolBar))
					{
						pToolBar->SaveState (strSection);
					}
				}
			}
		}

#ifndef BCG_NO_SIZINGBAR
		for (POSITION posCb = gAllSizingControlBars.GetHeadPosition (); posCb != NULL;)
		{
			CBCGSizingControlBar* pBar = (CBCGSizingControlBar*) gAllSizingControlBars.GetNext (posCb);
			ASSERT (pBar != NULL);

			if (CWnd::FromHandlePermanent (pBar->m_hWnd) != NULL)
			{
				ASSERT_VALID (pBar);

				if (!m_bLoadSaveFrameBarsOnly ||
					pBar->GetTopLevelFrame () == pFrameImpl->m_pFrame)
				{
					pBar->SaveState (m_strRegSection + strRegEntryNameSizingBars);
				}
			}
		}
#endif //BCG_NO_SIZINGBAR

		//----------------------------
		// Save user defined toolbars:
		//----------------------------
		pFrameImpl->SaveUserToolbars (m_bLoadSaveFrameBarsOnly);

		//------------------------
		// Save tear-off toolbars:
		//------------------------
		pFrameImpl->SaveTearOffMenus (m_bLoadSaveFrameBarsOnly);

		//-------------------
		// Save rebars state:
		//-------------------
#ifndef BCG_NO_REBAR
		CBCGRebarState::SaveState (strSection, pFrameImpl->m_pFrame);
#endif
	}

	//------------------
	// Save user images:
	//------------------
	if (CBCGToolBar::m_pUserImages != NULL)
	{
		ASSERT_VALID (CBCGToolBar::m_pUserImages);
		CBCGToolBar::m_pUserImages->Save ();
	}

	//--------------------------------------
	// Save mouse/keyboard/menu managers:
	//--------------------------------------
	if (g_pMouseManager != NULL)
	{
		g_pMouseManager->SaveState (strSection);
	}

	if (g_pContextMenuManager != NULL)
	{
		g_pContextMenuManager->SaveState (strSection);
	}

	if (g_pKeyboardManager != NULL)
	{
		g_pKeyboardManager->SaveState (strSection,
			pFrameImpl == NULL ? NULL : pFrameImpl->m_pFrame);
	}

	if (g_pUserToolsManager != NULL)
	{
		g_pUserToolsManager->SaveState (strSection);
	}

#if defined _AFXDLL && !defined _BCGCONTROLBAR_STATIC_	// Skins manager can not be used in the static version
	if (g_pSkinManager != NULL)
	{
		g_pSkinManager->SaveState (strSection);
	}
#endif

	SaveCustomState();
	return TRUE;
}
示例#15
0
//*************************************************************************************
BOOL CBCGWorkspace::LoadState (LPCTSTR lpszSectionName /*=NULL*/, CBCGFrameImpl* pFrameImpl /*= NULL*/)
{
	if (lpszSectionName != NULL)
	{
		m_strRegSection = lpszSectionName;
	}

	CString strSection = GetRegSectionPath ();

	//-----------------------------
	// Other things to do before ?:
	//-----------------------------
	PreLoadState();

	//------------------------
	// Loaded library version:
	//------------------------
	CBCGRegistrySP regSP;
	CBCGRegistry& reg = regSP.Create (FALSE, TRUE);

	if (reg.Open (GetRegSectionPath (strRegEntryVersion)))
	{
		reg.Read (strVersionMajorKey, m_iSavedVersionMajor);
		reg.Read (strVersionMinorKey, m_iSavedVersionMinor);
	}

	//--------------------------------------
	// Save general toolbar/menu parameters:
	//--------------------------------------
	CBCGToolBar::LoadParameters (strSection);
	CMD_MGR.LoadState (strSection);

	BOOL bResetImages = FALSE;	// Reset images to default 

	if (m_bResourceSmartUpdate)
	{
		CBCGToolbarButton::m_bUpdateImages = FALSE;
	}

	if (pFrameImpl != NULL) 
	{
		//-------------------
		// Load rebars state:
		//-------------------
#ifndef BCG_NO_REBAR
		CBCGRebarState::LoadState (strSection, pFrameImpl->m_pFrame);
#endif

		//-----------------------------------------------------
		// Load all toolbars, menubar and docking control bars:
		//-----------------------------------------------------
		for (POSITION posTlb = gAllToolbars.GetHeadPosition (); posTlb != NULL;)
		{
			CBCGToolBar* pToolBar = (CBCGToolBar*) gAllToolbars.GetNext (posTlb);
			ASSERT (pToolBar != NULL);

			if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
			{
				ASSERT_VALID(pToolBar);

				if (!m_bLoadSaveFrameBarsOnly ||
					pToolBar->GetTopLevelFrame () == pFrameImpl->m_pFrame)
				{
					if (!pToolBar->m_bLocked && 
						!pFrameImpl->IsUserDefinedToolbar(pToolBar)) 
					{
						pToolBar->LoadState (strSection);
						if (pToolBar->IsResourceChanged ())
						{
							bResetImages = TRUE;
						}
					}
				}
			}
		}

#ifndef BCG_NO_SIZINGBAR
		for (POSITION posCb = gAllSizingControlBars.GetHeadPosition (); posCb != NULL;)
		{
			CBCGSizingControlBar* pBar = (CBCGSizingControlBar*) gAllSizingControlBars.GetNext (posCb);
			ASSERT (pBar != NULL);

			if (CWnd::FromHandlePermanent (pBar->m_hWnd) != NULL)
			{
				ASSERT_VALID (pBar);

				if (!m_bLoadSaveFrameBarsOnly ||
					pBar->GetTopLevelFrame () == pFrameImpl->m_pFrame)
				{
					pBar->LoadState (m_strRegSection + strRegEntryNameSizingBars);
				}
			}
		}
#endif // BCG_NO_SIZINGBAR

		//----------------------------
		// Load user defined toolbars:
		//----------------------------
		pFrameImpl->LoadUserToolbars ();

		//------------------------
		// Load tear-off toolbars:
		//------------------------
		pFrameImpl->LoadTearOffMenus ();

		CBCGDockState dockState;
		dockState.LoadState(m_strRegSection + strRegEntryNameControlBars);

		if (m_bForceDockStateLoad || pFrameImpl->IsDockStateValid (dockState))
		{
			pFrameImpl->SetDockState (dockState);
		}
	}

	//--------------------------------------
	// Load mouse/keyboard/menu managers:
	//--------------------------------------
	if (g_pMouseManager != NULL)
	{
		g_pMouseManager->LoadState (strSection);
	}

	if (g_pContextMenuManager != NULL)
	{
		g_pContextMenuManager->LoadState(strSection);
	}

	if (g_pKeyboardManager != NULL)
	{
		g_pKeyboardManager->LoadState (strSection,
			pFrameImpl == NULL ? NULL : pFrameImpl->m_pFrame);
	}

	if (g_pUserToolsManager != NULL)
	{
		g_pUserToolsManager->LoadState (strSection);
	}

#if defined _AFXDLL && !defined _BCGCONTROLBAR_STATIC_	// Skins manager can not be used in the static version
	if (g_pSkinManager != NULL)
	{
		g_pSkinManager->LoadState (strSection);
	}
#endif

	if (m_bResourceSmartUpdate)
	{
		CBCGToolbarButton::m_bUpdateImages = TRUE;
	}

	if (m_bForceImageReset || (m_bResourceSmartUpdate && bResetImages))
	{
		for (POSITION posTlb = gAllToolbars.GetHeadPosition (); posTlb != NULL;)
		{
			CBCGToolBar* pToolBar = (CBCGToolBar*) gAllToolbars.GetNext (posTlb);
			ASSERT (pToolBar != NULL);

			if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
			{
				ASSERT_VALID (pToolBar);

				pToolBar->ResetImages ();
			}
		}

		if (pFrameImpl != NULL)
		{
			ASSERT_VALID (pFrameImpl->m_pFrame);
			pFrameImpl->m_pFrame->RecalcLayout ();
		}
	}

	//----------
	// Call Hook
	//----------
	LoadCustomState();

	//----------------------------------------------------------------------
	// To not confuse internal serialization, set version number to current:
	//----------------------------------------------------------------------
	m_iSavedVersionMajor = _BCGCB_VERSION_MAJOR;
	m_iSavedVersionMinor = _BCGCB_VERSION_MINOR;

	return TRUE;
}