Example #1
0
BOOL CSettingsPage::Create(const CRect& rcPage, CWnd* pSheetWnd)
{
	ASSERT_VALID(this);
	ASSERT( m_lpszTemplateName != NULL );

	CDialogTemplate pTemplate;
	LPDLGTEMPLATE pData;

	if ( ! pTemplate.Load( m_lpszTemplateName ) ) return FALSE;
	pData = (LPDLGTEMPLATE)GlobalLock( pTemplate.m_hTemplate );
	if ( ! pData ) return FALSE;

	DWORD dwExStyle = Settings.General.LanguageRTL ? WS_EX_RTLREADING|WS_EX_RIGHT|WS_EX_LEFTSCROLLBAR|WS_EX_LAYOUTRTL :
		WS_EX_LTRREADING|WS_EX_LEFT|WS_EX_RIGHTSCROLLBAR;

	if ( ((DLGTEMPLATEEX*)pData)->signature == 0xFFFF )
	{
		DLGTEMPLATEEX* pEx = (DLGTEMPLATEEX*)pData;
		pEx->style		= WS_CHILDWINDOW|WS_OVERLAPPED|DS_3DLOOK|DS_SETFONT|DS_CONTROL;
		pEx->exStyle	= dwExStyle|WS_EX_WINDOWEDGE|WS_EX_CONTROLPARENT;
	}
	else
	{
		pData->style			= WS_CHILDWINDOW|WS_OVERLAPPED|DS_3DLOOK|DS_SETFONT|DS_CONTROL;
		pData->dwExtendedStyle	= dwExStyle|WS_EX_WINDOWEDGE|WS_EX_CONTROLPARENT;
	}

	GlobalUnlock( pTemplate.m_hTemplate );
	CreateIndirect( pTemplate.m_hTemplate, pSheetWnd );
	SetFont( &theApp.m_gdiFont );

	MoveWindow( rcPage );

	return ( m_hWnd != NULL );
}
Example #2
0
int EditBoardText::DoModal() 
{
   CDialogTemplate dlt;
   int             nResult;

   // load dialog template
   if (!dlt.Load(MAKEINTRESOURCE(EditBoardText::IDD))) return -1;

   // set your own font, for example "Arial", 10 pts. 
   dlt.SetFont(m_strFaceName, 10);
	
   // get pointer to the modified dialog template
   LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
	
   // let MFC know that you are using your own template
   m_lpszTemplateName = NULL;
   m_hDialogTemplate  = NULL;

   InitModalIndirect(pdata);

   // display dialog box
   nResult = CDialog::DoModal();

   // unlock memory object
   GlobalUnlock(dlt.m_hTemplate);

   return nResult;	
}
Example #3
0
BOOL CSettingsPage::LoadDefaultCaption()
{
	CDialogTemplate pTemplate;
	DLGTEMPLATE* pData;
	LPWORD pWord;

	if ( ! pTemplate.Load( m_lpszTemplateName ) ) return FALSE;

	pData = (DLGTEMPLATE*)GlobalLock( pTemplate.m_hTemplate );
	if ( ! pData ) return FALSE;

	if ( ((DLGTEMPLATEEX*)pData)->signature == 0xFFFF )
		pWord = (WORD*)( (DLGTEMPLATEEX*)pData + 1 );
	else
		pWord = (WORD*)( pData + 1 );

	if ( *pWord == 0xFFFF )
		pWord += 2;
	else
		while ( *pWord++ );

	if ( *pWord == 0xFFFF )
		pWord += 2;
	else
		while ( *pWord++ );

	m_sCaption = (wchar_t*)pWord;

	GlobalUnlock( pTemplate.m_hTemplate );

	return ! m_sCaption.IsEmpty();
}
Example #4
0
BOOL CSettingsSheet::SkinMe(LPCTSTR pszSkin, UINT nIcon, BOOL bLanguage)
{
	EnableBanner( FALSE );

	m_szPages.cx = m_szPages.cy = 0;

	for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ )
	{
		CSettingsPage* pPage = GetPage( nPage );
		CDialogTemplate pTemplate;

		if ( pPage->GetTemplateName() == NULL )  continue;

		if ( pTemplate.Load( pPage->GetTemplateName() ) )
		{
			CSize size;
			pTemplate.GetSizeInPixels( &size );
			m_szPages.cx = max( m_szPages.cx, size.cx );
			m_szPages.cy = max( m_szPages.cy, size.cy );
		}
	}

	CRect rcWindow(
		0,
		0,
		m_szPages.cx + m_nListWidth + m_nListMargin,
		m_szPages.cy + + m_nButtonHeight + 8 + 8 + 2 );
	CalcWindowRect( &rcWindow );
	SetWindowPos( &wndTop, 0, 0, rcWindow.Width(), rcWindow.Height(),
		SWP_NOMOVE|SWP_NOZORDER );

	CRect rcTree(
		0,
		2,
		m_nListWidth,
		2 + m_szPages.cy );
	m_wndTree.MoveWindow( &rcTree );

	CRect rcButton(
		8,
		2 + m_szPages.cy + 8,
		8 + m_nButtonWidth,
		2 + m_szPages.cy + 8 + m_nButtonHeight );
	m_wndOK.MoveWindow( &rcButton );
	rcButton.OffsetRect( rcButton.Width() + 8, 0 );
	m_wndCancel.MoveWindow( &rcButton );
	rcButton.OffsetRect( rcButton.Width() + 8, 0 );
	m_wndApply.MoveWindow( &rcButton );

	CenterWindow();

	SetActivePage( m_pPage ? m_pPage : m_pFirst );

	return CSkinDialog::SkinMe( pszSkin, nIcon, bLanguage );
}
Example #5
0
void CSettingsSheet::Layout()
{
	TEXTMETRIC txtMetric;

	CDC* pDC = GetDC();
	pDC->SelectObject( &CoolInterface.m_fntNormal );
	pDC->GetTextMetrics( &txtMetric );
	ReleaseDC( pDC );

	m_nButtonHeight = ( txtMetric.tmHeight + txtMetric.tmExternalLeading ) + 10;

	m_szPages.cx = m_szPages.cy = 0;

	for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ )
	{
		CSettingsPage* pPage = GetPage( nPage );
		CDialogTemplate pTemplate;

		if ( pPage->GetTemplateName() == NULL )  continue;

		if ( pTemplate.Load( pPage->GetTemplateName() ) )
		{
			CSize size;
			pTemplate.GetSizeInPixels( &size );
			m_szPages.cx = max( m_szPages.cx, size.cx );
			m_szPages.cy = max( m_szPages.cy, size.cy );
		}
	}

	CRect rc( 0, 0, m_szPages.cx, m_szPages.cy );
	rc.right += m_nListWidth + m_nListMargin;
	rc.right += m_nLeftMargin;
	rc.bottom += m_nTopMargin + m_nButtonHeight + 16;

	CalcWindowRect( &rc );
	SetWindowPos( &wndTop, 0, 0, rc.Width(), rc.Height(), SWP_NOMOVE|SWP_NOZORDER );

	rc.SetRect( m_nLeftMargin, m_nTopMargin, 0, 0 );
	rc.right	= rc.left + m_nListWidth;
	rc.bottom	= rc.top  + m_szPages.cy;

	m_wndTree.MoveWindow( &rc );

	rc.SetRect( 8, rc.bottom + 8, 76, m_nButtonHeight );
	rc.right += rc.left;
	rc.bottom += rc.top;

	m_wndOK.MoveWindow( &rc );
	rc.OffsetRect( rc.Width() + 8, 0 );
	m_wndCancel.MoveWindow( &rc );
	rc.OffsetRect( rc.Width() + 8, 0 );
	m_wndApply.MoveWindow( &rc );
}
Example #6
0
LONG CLayoutRuleRelativeControl::Apply(const CDialogTemplate& tmpl, UINT nDirection,
										const CRect& rcLayout) const
{
	CDialogItemTemplate item = tmpl.FindControl( m_nCtrlID );
	ATLASSERT( item.IsValid() );

	switch ( this->m_nDirection )
	{
		case LAYOUT_DIRECTION_LEFT:
			ATLASSERT( nDirection == LAYOUT_DIRECTION_LEFT || nDirection == LAYOUT_DIRECTION_RIGHT );
			return item.GetX() - m_nPadding;
		case LAYOUT_DIRECTION_TOP:
			ATLASSERT( nDirection == LAYOUT_DIRECTION_TOP || nDirection == LAYOUT_DIRECTION_BOTTOM );
			return item.GetY() - m_nPadding;
		case LAYOUT_DIRECTION_RIGHT:
			ATLASSERT( nDirection == LAYOUT_DIRECTION_LEFT || nDirection == LAYOUT_DIRECTION_RIGHT );
			return item.GetX() + item.GetWidth() + m_nPadding;
		case LAYOUT_DIRECTION_BOTTOM:
			ATLASSERT( nDirection == LAYOUT_DIRECTION_TOP || nDirection == LAYOUT_DIRECTION_BOTTOM );
			return item.GetY() + item.GetHeight() + m_nPadding;
		default:
			ATLASSERT(FALSE);
			return 0;
	}

}
Example #7
0
CLayoutControl::CLayoutControl(const CDialogTemplate& rTmpl,
							   const CLayoutContainer& parent,
							   UINT nID, UINT nAnchor)
	: m_nID(nID), m_nAnchor(nAnchor)
{
	CDialogItemTemplate item = rTmpl.FindControl(nID);
	ATLASSERT( item.IsValid() );

	const CRect& rcParent = parent.GetBounds();
	
	m_rcMargins.SetRect( item.GetX() - rcParent.left,
		item.GetY() - rcParent.top,
		rcParent.right - item.GetX() - item.GetWidth(),
        rcParent.bottom - item.GetY() - item.GetHeight() );
	//ATLASSERT( m_rcMargins.left >= 0 && m_rcMargins.top >= 0 );
	rTmpl.MapDialogRect(m_rcMargins);
}
Example #8
0
void CCustomPropSheet::BuildPropPageArray(void)
{
	CDialogTemplate dlgtPageRes;

	__super::BuildPropPageArray();

	// get first page
	CPropertyPage* pPage = GetPage(0);
	ASSERT(pPage != NULL);

	// load the dialog template
	VERIFY(dlgtPageRes.Load(pPage->m_psp.pszTemplate));

	// get the font information

	// defaults
	CString strFaceName(_T("MS Shell Dlg 2"));
	WORD wPointSize = 8;

	if (!GetFontMetrics(strFaceName, wPointSize))
	{
		// obtain from resource template
		VERIFY(dlgtPageRes.GetFont(strFaceName, wPointSize));
	}

	if (m_fontPage.m_hObject != NULL)
	{
		VERIFY(m_fontPage.DeleteObject());
	}

	// create a font using the info from first page
	LOGFONT lf = { 0 };
	HDC hdcScreen = ::GetDC(NULL);
	ASSERT(hdcScreen != NULL);
	lf.lfHeight = ::MulDiv(-wPointSize, ::GetDeviceCaps(hdcScreen, LOGPIXELSY), 72);
	lf.lfWeight = FW_REGULAR;
	lf.lfCharSet = DEFAULT_CHARSET;
	lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
	lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	lf.lfQuality = PROOF_QUALITY;
	lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
	_tcsncpy(lf.lfFaceName, strFaceName, LF_FACESIZE - 1);
	VERIFY(m_fontPage.CreateFontIndirect(&lf));
	::ReleaseDC(NULL, hdcScreen);
}
INT_PTR CWaterAttachment::DoModal()
{
	// TODO: Add your specialized code here and/or call the base class
	CDialogTemplate dlt;
	int nResult;
	// load dialog template
	if (!dlt.Load(MAKEINTRESOURCE(CWaterAttachment::IDD))) return -1;
	// set the font, for example "Arial", 10 pts.
	dlt.SetFont("Arial", 8);
	// get pointer to the modified dialog template
	LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
	// let MFC know that you are using your own template
	m_lpszTemplateName = NULL;
	InitModalIndirect(pdata);
	// display dialog box
	nResult = CDialog::DoModal();
	// unlock memory object
	GlobalUnlock(dlt.m_hTemplate);
	return nResult;
}
Example #10
0
void BaseDialog::SetFont(CDialogTemplate& dlgTemplate)
{
  NONCLIENTMETRICS ncm;
  ::ZeroMemory(&ncm,sizeof ncm);
  ncm.cbSize = sizeof ncm;
  ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof ncm,&ncm,0);

  OSVERSIONINFO osvi;
  osvi.dwOSVersionInfoSize = sizeof osvi;
  ::GetVersionEx(&osvi);
  WORD fontSize = (osvi.dwMajorVersion < 6) ? 8 : 9;

  dlgTemplate.SetFont(ncm.lfMessageFont.lfFaceName,fontSize);
}
Example #11
0
CLayoutContainer::CLayoutContainer(const CDialogTemplate& rTmpl,
								   const CLayoutContainer* pParent,
                                   CLayoutRule* pLeftRule, CLayoutRule* pTopRule,
								   CLayoutRule* pRightRule, CLayoutRule* pBottomRule )
	: m_rTmpl(rTmpl)
{
	if ( pParent == NULL )
	{
		m_rcBounds.SetRect( 0, 0, rTmpl.GetWidth(), rTmpl.GetHeight() );
	}
	else
	{
		ATLASSERT( pLeftRule != NULL );
		m_Rules.Add( CLayoutRulePtr(pLeftRule) );
		if ( pTopRule != NULL )
		{
			m_Rules.Add( CLayoutRulePtr(pTopRule) );
			ATLASSERT( pRightRule != NULL );
			m_Rules.Add( CLayoutRulePtr(pRightRule) );
			ATLASSERT( pBottomRule != NULL );
			m_Rules.Add( CLayoutRulePtr(pBottomRule) );
		}
		else
		{
			pTopRule = pRightRule = pBottomRule = pLeftRule;
		}

		const CRect& rcParent = pParent->GetBounds();

		m_rcBounds.SetRect(
			pLeftRule->Apply(m_rTmpl, LAYOUT_DIRECTION_LEFT, rcParent),
			pTopRule->Apply(m_rTmpl, LAYOUT_DIRECTION_TOP, rcParent),
			pRightRule->Apply(m_rTmpl, LAYOUT_DIRECTION_RIGHT, rcParent),
			pBottomRule->Apply(m_rTmpl, LAYOUT_DIRECTION_BOTTOM, rcParent) );
	}
}
Example #12
0
BOOL COptionSheet::CalcSpacing(CFont &buttonFont)
{
	TEXTMETRIC	txtMetric;
	CRect		rcClient;
	CRect		rcWindow;
	COptionPage *page;
	CRect		rect;
	
	GetClientRect(rcClient);
	GetWindowRect(rcWindow);

	// Get the client area used by the window
	m_XBorder = rcWindow.Width() - rcClient.Width();
	m_YBorder = rcWindow.Height() - rcClient.Height();

	// Get the rect metrics of the font used on the buttons
	CDC *dc = GetDC();
	dc->SelectObject(buttonFont);
	dc->GetTextMetrics(&txtMetric);
	ReleaseDC(dc);

	// Calculate the height of the buttons and the button spacing
	m_ButtonHeight = (txtMetric.tmHeight + txtMetric.tmExternalLeading) + 10;
	m_ButtonYLocOffset = PAGE_SPACING2 + m_ButtonHeight;
	m_ButtonSpacing = m_ButtonHeight + PAGE_SPACING;
	m_ButtonWidth = BUTTON_WIDTH;

	// Adjust the button spacing if in full page wizard mode
	if(m_psh.dwFlags & OSH_WIZARDFULL) {
		m_ButtonSpacing += PAGE_SPACING;
	}

	// Calculate the space needed for the buttons
	m_AllButtonsWidth = 0;

	m_AllButtonsWidth = AddButtons(FALSE);

	// Calculate the sizes of the option pages
	m_MaxChildSize.cx = 0;
	m_MaxChildSize.cy = 0;

	for(int i = 0; i < GetPageCount(); i++) {
		BOOL result;
		CDialogTemplate tmpl;
		SIZE size;

		page = GetPage(i);

		// FIXME
		if(NULL != page->GetTemplateName()) {
			// Create the child dialog and get the rect
			result = tmpl.Load(page->GetTemplateName());
			ASSERT(TRUE == result);

			tmpl.GetSizeInPixels(&size);

			// Calc the size
			if(size.cx > m_MaxChildSize.cx) {
				m_MaxChildSize.cx = size.cx;
			}

			if(size.cy > m_MaxChildSize.cy) {
				m_MaxChildSize.cy = size.cy;
			}
		}
	}

	return TRUE;
}
Example #13
0
INT_PTR CCustomDialog::DoModal(void)
{
	// get the custom font information
	CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
	CString strFaceName = pApp->GetConfigString(SZ_ARG_FONT_FACENAME, SZ_REGK_FONT, SZ_REGV_FONT_FACENAME);
	WORD wFontSize = LOWORD(pApp->GetConfigUInt(SZ_ARG_FONT_POINTSIZE, SZ_REGK_FONT, SZ_REGV_FONT_SIZE, 0));

	if (!strFaceName.IsEmpty() && wFontSize > 0)
	{
		// try to load dialog template
		CDialogTemplate dlgtRes;
		if (!dlgtRes.Load(m_lpszTemplateName))
		{
			return (-1);
		}

		// set specified custom font
		dlgtRes.SetFont(strFaceName, wFontSize);

		// get pointer to the modified dialog template
		DLGTEMPLATE* pTemplate = reinterpret_cast<DLGTEMPLATE*>(::GlobalLock(dlgtRes.m_hTemplate));

		// try to load coresponding DLGINIT resource (if any)
		HGLOBAL hResData = NULL;
		void* pvDlgInit = NULL;
		HINSTANCE hResInst = AfxGetResourceHandle();
		HRSRC hResInfo = ::FindResource(hResInst, m_lpszTemplateName, RT_DLGINIT);
		if (hResInfo != NULL)
		{
			hResData = ::LoadResource(hResInst, hResInfo);
			ASSERT(hResData != NULL);
			pvDlgInit = ::LockResource(hResData);
			ASSERT(pvDlgInit != NULL);
		}

		// let MFC know that we are using our own template
		LPCTSTR pszTemplateName = m_lpszTemplateName;
		m_lpszTemplateName = NULL;
		InitModalIndirect(pTemplate, NULL, pvDlgInit);

		// display dialog box
		INT_PTR nResult = __super::DoModal();

		if (hResData != NULL)
		{
			::UnlockResource(hResData);
			::FreeResource(hResData);
		}

		// unlock memory object
		::GlobalUnlock(dlgtRes.m_hTemplate);

		m_lpszTemplateName = pszTemplateName;
		m_lpDialogTemplate = NULL;

		return (nResult);
	}
	else
	{
		// no custom font is specified
		return (__super::DoModal());
	}
}