Click here to Skip to main content
15,911,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Closing all open handles to a disk device Pin
David Crow27-Nov-05 11:19
David Crow27-Nov-05 11:19 
AnswerRe: Closing all open handles to a disk device Pin
hrepa27-Nov-05 11:46
hrepa27-Nov-05 11:46 
Questionreading a script file Pin
islheg26-Nov-05 6:59
islheg26-Nov-05 6:59 
QuestionSetFont and GetFont Pin
Nishad S25-Nov-05 23:42
Nishad S25-Nov-05 23:42 
AnswerRe: SetFont and GetFont Pin
Mircea Puiu27-Nov-05 2:54
Mircea Puiu27-Nov-05 2:54 
GeneralRe: SetFont and GetFont Pin
Nishad S27-Nov-05 16:56
Nishad S27-Nov-05 16:56 
GeneralRe: SetFont and GetFont Pin
Mircea Puiu27-Nov-05 18:46
Mircea Puiu27-Nov-05 18:46 
GeneralRe: SetFont and GetFont Pin
Nishad S27-Nov-05 19:15
Nishad S27-Nov-05 19:15 
Yes, sure...

class header is:
class CTextExtCtrl : public CWnd, public CColorMgr
{
...
...
};

In CPP:
bool CTextExtCtrl::Create( CWnd* pWndParent,
                            LPCTSTR lpctszMsg )
{
    ...
    // some code to store the lpctszMsg and assertions
    ...

    // Register the class
    CString csClass( AfxRegisterWndClass( CS_VREDRAW |
     CS_HREDRAW | CS_PARENTDC, LoadCursor( 0, IDC_ARROW )));

     // Creates the window
    CWnd::Create( csClass, _T( "" ), WS_CHILD |
     WS_VISIBLE, CRect( 0, 0, 0, 0 ), pWndParent, 0 ))

    ...
    // some codes to init tooltip, scrollbar, etc.
    ...
}


In main wnd class, Called from OnInitDialog:
// Set the font to the buttons
// loop
    m_arBtn[nIdx].SetFont( &m_fontDlg );
// end of loop

// Create the message control
if( !m_textctrl.Create( this, ptcErrMessage ))
{
   // Failed to create the control
   return false;
}

// Set the font
m_textctrl.SetFont( &m_fontDlg );

The font is valid and the buttons' text are changed with assigned font type.
The last line of code was replaced by me as following, to debug the result:
CFont* pFont = &m_fontDlg;
m_textctrl.SetFont( pFont );
pFont = m_textctrl.GetFont();


On debugging the values of pFont and pFont->m_hObject are valid. But after the last line (GetFont) it become null.

I use the the assigned font to draw the text in the control.
void CTextExtCtrl::OnPaint()
{
    ...
    ...
    // Select the font to the dc
    CFont* pOldFont = dcMem.SelectObject( GetFont());
    // Draw the text
    dcMem.DrawText( m_csMsg, &rect, DT_WORDBREAK );
    // Some BitBlt functions...
    ...


- NS -
General[Message Deleted] Pin
Mircea Puiu27-Nov-05 21:32
Mircea Puiu27-Nov-05 21:32 
GeneralRe: SetFont and GetFont Pin
Mircea Puiu27-Nov-05 21:32
Mircea Puiu27-Nov-05 21:32 
GeneralRe: SetFont and GetFont Pin
Nishad S27-Nov-05 21:50
Nishad S27-Nov-05 21:50 
GeneralRe: SetFont and GetFont Pin
Mircea Puiu27-Nov-05 22:05
Mircea Puiu27-Nov-05 22:05 
GeneralRe: SetFont and GetFont Pin
Nishad S27-Nov-05 22:18
Nishad S27-Nov-05 22:18 
Questionunicast to multicast a file Pin
cancerion25-Nov-05 23:21
cancerion25-Nov-05 23:21 
Questiongraphically connecting two list controls Pin
bensabat25-Nov-05 22:53
bensabat25-Nov-05 22:53 
AnswerRe: graphically connecting two list controls Pin
Jacky Tsee26-Nov-05 6:05
Jacky Tsee26-Nov-05 6:05 
AnswerRe: graphically connecting two list controls Pin
Mircea Puiu27-Nov-05 2:59
Mircea Puiu27-Nov-05 2:59 
QuestionHow to lock the computer after booting? Pin
luyongxing25-Nov-05 22:06
luyongxing25-Nov-05 22:06 
AnswerRe: How to lock the computer after booting? Pin
sunit525-Nov-05 22:29
sunit525-Nov-05 22:29 
GeneralRe: How to lock the computer after booting? Pin
luyongxing25-Nov-05 22:51
luyongxing25-Nov-05 22:51 
GeneralRe: How to lock the computer after booting? Pin
sunit525-Nov-05 23:21
sunit525-Nov-05 23:21 
GeneralRe: How to lock the computer after booting? Pin
ThatsAlok28-Nov-05 2:38
ThatsAlok28-Nov-05 2:38 
Questionhow to know if CFtpConnection is disconnected? Pin
includeh1025-Nov-05 21:15
includeh1025-Nov-05 21:15 
AnswerRe: how to know if CFtpConnection is disconnected? Pin
Mircea Puiu27-Nov-05 3:17
Mircea Puiu27-Nov-05 3:17 
QuestionQuery: Parameters of DoCmd.OpenTable & DOCmd.Printout methods Pin
Ankush Mehta25-Nov-05 20:32
Ankush Mehta25-Nov-05 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.