How to call functions between 2 classes in the same header file.


  • Hi,

    I know this sounds easy. But I am not sure of what to do. I am using MFC C++
    I have 2 classes in one header file:

    class Class1 : public CEdit
      void OnMouseEvent(MouseEvent mouseEvent, CPoint point);
    class Class2: public CDialog
       void SetMinMax();

    I wanted to call SetMinMax() from OnMouseEvent(...), where Class 2 is the base class
    How do I go about calling it?

    Thank you for replying

    • แก้ไขโดย Lofty88 7 มีนาคม 2555 3:33
    7 มีนาคม 2555 2:37


  • In your first post you showed Class1 derived from CEdit. If your class is derived from CEdit (and the edit control is part of the dialog) then you would have an inherited GetParent member function.

    If your class is not a CEdit then put a Class2* m_p2 variable in it. Initialize that pointer when you create the Class1 object, or sometime before it needs to call the dialog function.

    If you don't understand how, explain and show where and how you create the Class1 object.


    • ทำเครื่องหมายเป็นคำตอบโดย Lofty88 7 มีนาคม 2555 7:06
    7 มีนาคม 2555 5:42