Click here to Skip to main content
15,915,093 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCRichEditCtrl printng... What's wrong with my code? Pin
Nasty_p7-Nov-02 5:04
Nasty_p7-Nov-02 5:04 
AnswerRe: CRichEditCtrl printng... What's wrong with my code? Pin
dabs7-Nov-02 5:38
dabs7-Nov-02 5:38 
GeneralRe: CRichEditCtrl printng... What's wrong with my code? Pin
Nasty_p7-Nov-02 5:44
Nasty_p7-Nov-02 5:44 
GeneralRe: CRichEditCtrl printng... What's wrong with my code? Pin
Nasty_p12-Nov-02 14:20
Nasty_p12-Nov-02 14:20 
GeneralNeed example of forward declare Pin
bhutt7-Nov-02 5:09
bhutt7-Nov-02 5:09 
GeneralRe: Need example of forward declare Pin
Marc Clifton7-Nov-02 5:42
mvaMarc Clifton7-Nov-02 5:42 
GeneralRe: Need example of forward declare Pin
Anonymous8-Nov-02 2:24
Anonymous8-Nov-02 2:24 
GeneralRe: Need example of forward declare Pin
dabs7-Nov-02 5:57
dabs7-Nov-02 5:57 
I suspect you have the classical pointer problem - you have a pointer that does not point to a valid object. Assuming we have two classes A and B and both must know of each other. Assume also that class A will own an instance of class B and class B will hold a reference (a pointer) to A then this would work:

//File A.h:

#include <B.h>

class A
{
public:

    A( );

    void DoStuff( );

private:

    B m_B;
};


//File B.h:

//Forward declare class A
class A;

class B
{
public:

    B( A* pA );

    void DoOtherStuff( );

private:

    A*  m_pA;
};

//File B.cpp:
#include <B.h>
#include <A.h>

B::B( A* pA )
    : m_pA( pA )
{

}

void B::DoOtherStuff( )
{
    //Here we can use m_pA because it points to a valid object
}

//File A.cpp:

#include <A.h>

A::A( )
    : m_B( this )
    //will probably generate a compiler warning
    //but we can safely ignore that.  Just remember
    //that B cannot use the pointer it gets in the 
    //constructor because A hasn't been fully 
    //constructed yet!
{

}

void A::DoStuff( )
{
    m_B.DoOtherStuff( );
}


Of course this might not be the design that you want - you might have a design where two otherwise unrelated objects (i.e. class A does not own an instance of class B) have to be able to communicate to each other. As always you must think more in terms of instances of classes rather than classes themselves. I.e. it is technically not the class A that wants to talk to B but rather an instance of class A that wants to talk to a specific instance of class B.

Hope this helps somewhat.





Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
GeneralStyle fro CHeaderCtrl Pin
Telefonen7-Nov-02 5:01
Telefonen7-Nov-02 5:01 
GeneralRe: Style fro CHeaderCtrl Pin
Daniel Ferguson7-Nov-02 6:47
Daniel Ferguson7-Nov-02 6:47 
GeneralResizing the desktop area Pin
MiamiCoder7-Nov-02 4:46
MiamiCoder7-Nov-02 4:46 
GeneralRe: Resizing the desktop area Pin
Chris Richardson7-Nov-02 7:08
Chris Richardson7-Nov-02 7:08 
GeneralRe: Resizing the desktop area Pin
Anonymous7-Nov-02 10:20
Anonymous7-Nov-02 10:20 
Generaldll Pin
7-Nov-02 3:59
suss7-Nov-02 3:59 
GeneralRe: dll Pin
Anonymous7-Nov-02 4:38
Anonymous7-Nov-02 4:38 
GeneralRe: dll Pin
Stephane Rodriguez.7-Nov-02 4:57
Stephane Rodriguez.7-Nov-02 4:57 
Generalget default printer name Pin
vgkotha7-Nov-02 3:25
vgkotha7-Nov-02 3:25 
GeneralRe: get default printer name Pin
Navin7-Nov-02 3:51
Navin7-Nov-02 3:51 
GeneralRe: get default printer name Pin
Chad Koehler7-Nov-02 5:32
Chad Koehler7-Nov-02 5:32 
QuestionHow can I avoid a window get the focus ? Pin
Cris7-Nov-02 2:43
Cris7-Nov-02 2:43 
AnswerRe: How can I avoid a window get the focus ? Pin
includeh107-Nov-02 2:53
includeh107-Nov-02 2:53 
GeneralRe: How can I avoid a window get the focus ? Pin
Cris7-Nov-02 7:30
Cris7-Nov-02 7:30 
GeneralRe: How can I avoid a window get the focus ? Pin
includeh107-Nov-02 8:30
includeh107-Nov-02 8:30 
GeneralRe: How can I avoid a window get the focus ? Pin
Cris8-Nov-02 0:17
Cris8-Nov-02 0:17 
GeneralRe: How can I avoid a window get the focus ? Pin
includeh108-Nov-02 1:25
includeh108-Nov-02 1:25 

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.