Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
3.40/5 (2 votes)
Hi friends,

I am stuck at a small problem. I am creating a font dialog using domodal method. But after creation this dialog is popup at the backside of other side. Can anybody tell me how to popup that dialog in front of other one. My code is as below:
C++
CFontDialog			 m_OTheFontDialog;	
FontFamily*		pOFontFamily = NULL;
		
	m_OTheFontDialog.m_cf.Flags |= CF_TTONLY;

	if(m_OTheFontDialog.DoModal() == IDOK)
	{	
             m_OTheFontDialog.GetCurrentFont(&m_SFontInformation);
		m_SFontInformation.lfQuality = ANTIALIASED_QUALITY;
		m_crTextColor = m_OTheFontDialog.GetColor();

		if(m_OTheFontDialog.IsBold())
			iFontStyle = iFontStyle | FontStyleBold;

		if(m_OTheFontDialog.IsItalic())
			iFontStyle = iFontStyle | FontStyleItalic;

		if(m_OTheFontDialog.IsStrikeOut())
			iFontStyle = iFontStyle | FontStyleStrikeout;

		if(m_OTheFontDialog.IsUnderline())
			iFontStyle = iFontStyle | FontStyleUnderline;

		if(!wcscmp(m_SFontInformation.lfFaceName, _T("")))
			return false;

		pOFontFamily = new FontFamily(m_SFontInformation.lfFaceName);
                
                m_pOBrush = new SolidBrush(Color(255, GetRValue(m_crTextColor), GetGValue(m_crTextColor), GetBValue(m_crTextColor)));
		m_pOTheFont = new Font(pOFontFamily, (float)ulFontHeight, iFontStyle, UnitPixel);
        }

Please help me resolve this issue.
Thanks
Posted

You can use CWnd::SetWindowPos I would say, take a look: CWnd::SetWindowPos[^] :

C++
m_pMainWnd->SetWindowPos(&CWnd:: wndTopMost, 0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
 
Share this answer
 
v2
Comments
Vaibhav_J_Jaiswal 8-Aug-13 9:19am    
It is not work in the case of domodal(). The object of dialog is created after calling domodal. So before domodal the exe is crashed because of null dialog object and after the domodal the dialog is already popup. So no any chance to call the above method. Any other way for this?
Try setting the parent of the dialog to the other window, the way you have created m_OTheFontDialog the parent is NULL which is the desktop window.

I suspect that is why it appears behind at the moment because you have m_OtheFontDialog.pParentWnd = NULL effectively
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900