Click here to Skip to main content
15,896,557 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: help to solve this bug Pin
Cedric Moonen26-Jun-07 3:15
Cedric Moonen26-Jun-07 3:15 
AnswerRe: help to solve this bug Pin
Iain Clarke, Warrior Programmer26-Jun-07 3:23
Iain Clarke, Warrior Programmer26-Jun-07 3:23 
GeneralRe: help to solve this bug Pin
James_Programmer26-Jun-07 3:48
James_Programmer26-Jun-07 3:48 
GeneralRe: help to solve this bug Pin
James_Programmer26-Jun-07 3:56
James_Programmer26-Jun-07 3:56 
GeneralRe: help to solve this bug Pin
Iain Clarke, Warrior Programmer26-Jun-07 4:33
Iain Clarke, Warrior Programmer26-Jun-07 4:33 
GeneralRe: help to solve this bug Pin
James_Programmer26-Jun-07 5:00
James_Programmer26-Jun-07 5:00 
GeneralRe: help to solve this bug Pin
James_Programmer26-Jun-07 5:14
James_Programmer26-Jun-07 5:14 
GeneralRe: help to solve this bug Pin
Iain Clarke, Warrior Programmer26-Jun-07 5:47
Iain Clarke, Warrior Programmer26-Jun-07 5:47 
Um, CString doesn't have a SetFont method. Or a SetWindowText method. So your above code not only has a memory leak, it wouldn't compile. CString is just a handy holder for a bunch of characters all in a row.
I'm going to make a leap in the dark, and say you're confusing it with a Label in VB...


As for the other question...
You need to keep a copy of the font around.

class CMyDialog : public CDialog
{
public:
    CDialog (.....)
    {
        m_fMyFont.CreateSomehow ();
        .....
    }

    ....
    BOOL OnInitDialog ()
    {
        SetFont (&m_fMyFont);
        ....
        return CDialog::OnInitDialog ();
    }

    

protected:
    CFont m_fMyFont;
};


Obviously, I've removed a lot of boilerplate code. I'm assuming you have a dialog, or such. Create the font, and SetFont with a pointer to it. In the above example, the window will be destroyed, then the destructor of CMyDialog. At the end of that, the destructor for CFont will be called, tidying up the font.

Not all solutions involve pointers!


Iain.



GeneralRe: help to solve this bug Pin
James_Programmer26-Jun-07 6:01
James_Programmer26-Jun-07 6:01 
GeneralRe: help to solve this bug Pin
Mark Salsbery26-Jun-07 7:47
Mark Salsbery26-Jun-07 7:47 
Questionbrowse ... Pin
tasumisra26-Jun-07 2:33
tasumisra26-Jun-07 2:33 
AnswerRe: browse ... Pin
ahmad_ali26-Jun-07 6:45
ahmad_ali26-Jun-07 6:45 
GeneralRe: browse ... Pin
tasumisra26-Jun-07 20:52
tasumisra26-Jun-07 20:52 
GeneralRe: browse ... Pin
ahmad_ali26-Jun-07 22:55
ahmad_ali26-Jun-07 22:55 
QuestionData Types Pin
tasumisra26-Jun-07 1:34
tasumisra26-Jun-07 1:34 
AnswerRe: Data Types Pin
aatul26-Jun-07 1:41
aatul26-Jun-07 1:41 
AnswerRe: Data Types Pin
KarstenK26-Jun-07 3:27
mveKarstenK26-Jun-07 3:27 
QuestionEncode using DirectShow Pin
Maynka26-Jun-07 0:58
Maynka26-Jun-07 0:58 
AnswerRe: Encode using DirectShow Pin
Mark Salsbery26-Jun-07 6:22
Mark Salsbery26-Jun-07 6:22 
QuestionHow to use exported classes from DLL without using header. Pin
aatul26-Jun-07 0:48
aatul26-Jun-07 0:48 
AnswerRe: How to use exported classes from DLL without using header. Pin
Cedric Moonen26-Jun-07 0:51
Cedric Moonen26-Jun-07 0:51 
AnswerRe: How to use exported classes from DLL without using header. Pin
Iain Clarke, Warrior Programmer26-Jun-07 1:19
Iain Clarke, Warrior Programmer26-Jun-07 1:19 
AnswerRe: How to use exported classes from DLL without using header. Pin
aatul26-Jun-07 1:24
aatul26-Jun-07 1:24 
GeneralRe: How to use exported classes from DLL without using header. Pin
Cedric Moonen26-Jun-07 1:29
Cedric Moonen26-Jun-07 1:29 
AnswerRe: How to use exported classes from DLL without using header. Pin
Rajkumar R26-Jun-07 2:24
Rajkumar R26-Jun-07 2:24 

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.