Пример #1
0
//---------------------------------------------------------------------------
__fastcall TForm21::TForm21(TComponent* Owner, TData &AData, const TDraw &ADraw, const boost::shared_ptr<TTextLabel> &ALabel)
  : TForm(Owner), Label(ALabel), Data(AData), Draw(ADraw), OldPlacement(ALabel->GetPlacement())
{
  ScaleForm(this);
  TranslateProperties(this);
  SetAccelerators(this);
  FlipForm(this);

  const int PlacementToIndex[] = {0, -1, -1, -1, -1, 1, 2, 3};
  ComboBox1->ItemIndex = PlacementToIndex[Label->GetPlacement()];
  Edit1->Text = ToUString(Label->GetXPos().Text);
  Edit2->Text = ToUString(Label->GetYPos().Text);
}
Пример #2
0
BOOL COXShortkeysOrganizer::
LoadState(LPCTSTR lpszProfileName/*=_T("ShortkeysOrganizerState")*/,
		  BOOL bApply/*=TRUE*/)
{
#ifndef _MAC
	if(!IsAttached())
	{
		TRACE(_T("COXShortkeysOrganizer::SaveState: there is no attached frame window. You have to attach frame window before calling this function\n"));
		return FALSE;
	}

	CString m_sProfileName=lpszProfileName;
	ASSERT(!m_sProfileName.IsEmpty());

	ASSERT(m_pFrameWnd!=NULL);
	ASSERT(m_pFrameWnd->GetSafeHwnd());

	CWinApp* pApp=AfxGetApp();

	// make sure you called CWinApp::SetRegistryKey() functions before
	if(pApp->m_pszRegistryKey==NULL || pApp->m_pszProfileName==NULL)
	{
		TRACE(_T("COXShortkeysOrganizer::SaveState: CWinApp::SetRegistryKey() must be called in InitInstance()\n"));
		return FALSE;
	}
	// we use default registry key assigned to your application by MFC
	HKEY hSecKey=pApp->GetSectionKey(_T(""));
	if (hSecKey==NULL)
	{
		TRACE(_T("COXShortkeysOrganizer::SaveState: unable to get section key\n"));
		return FALSE;
	}
	
	BOOL bResult=TRUE;
	try
	{
		COXRegistryValFile regAccelState(hSecKey,m_sProfileName,
			_T("AcceleratorsState"));
		if(regAccelState.GetLength()>0)
		{
			CArchive ar(&regAccelState, CArchive::load);
			Serialize(ar);
			ar.Close();
		}
	}
	catch(CException* e)
	{
		UNREFERENCED_PARAMETER(e);
		bResult=FALSE;
	}

	::RegCloseKey(hSecKey);

	if(bResult && bApply)
		VERIFY(SetAccelerators());

	return bResult;
#else
	return FALSE;
#endif
}