MFC and OpenGL: CStatic and CView - Programmer

This is a discussion on MFC and OpenGL: CStatic and CView - Programmer ; Dear all, I'm gonna derive a class from CView to add support for OpenGL rendering (e.g. CGLView). This point is OK. But if I'd like to insert this "view" into a dialog-based MFC app, how can I do it? 1. ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: MFC and OpenGL: CStatic and CView

  1. MFC and OpenGL: CStatic and CView

    Dear all,

    I'm gonna derive a class from CView to add support for OpenGL rendering
    (e.g. CGLView).
    This point is OK.

    But if I'd like to insert this "view" into a dialog-based MFC app, how
    can I do it?

    1. For my little knowledge of MFC, I think that - to do OpenGL rendering
    in a dialog-box - I should derive a class from CStatic (e.g. CGLStatic)
    and add OpenGL support to it.
    Then I'd use resource editor and add static control into dialog-box, and
    I modify source code, replacing "CStatic" with my "CGLStatic".
    Is this point correct?

    2. But if I'd like to "recycle" the OpenGL-enabled-view code (CGLView),
    and not "reinvent the wheel" writing a CGLStatic, is there any way to
    insert a CView-derived class into an MFC dialog?

    Thanks in advance,
    Dan


  2. Re: MFC and OpenGL: CStatic and CView

    Danguard wrote:

    > Dear all,
    >
    > I'm gonna derive a class from CView to add support for OpenGL rendering
    > (e.g. CGLView).
    > This point is OK.
    >
    > But if I'd like to insert this "view" into a dialog-based MFC app, how
    > can I do it?
    >
    > 1. For my little knowledge of MFC, I think that - to do OpenGL rendering
    > in a dialog-box - I should derive a class from CStatic (e.g. CGLStatic)
    > and add OpenGL support to it.
    > Then I'd use resource editor and add static control into dialog-box, and
    > I modify source code, replacing "CStatic" with my "CGLStatic".
    > Is this point correct?
    >
    > 2. But if I'd like to "recycle" the OpenGL-enabled-view code (CGLView),
    > and not "reinvent the wheel" writing a CGLStatic, is there any way to
    > insert a CView-derived class into an MFC dialog?
    >
    > Thanks in advance,
    > Dan
    >


    Yes, the normal way would be to draw on a subclassed CStatic in the dialog.

    It is possible to put a CView on a dialog. The important steps you have
    to supply yourself are to initialize it by sending WM_INITIALUPDATE and
    to properly set its m_pDocument member variable. For a code example see
    CSplitterWnd::CreateView in the MFC source code.

    Also look out for the CDocument m_bAutoDelete variable. When your
    dialog is destroyed the document will delete itself if no other views
    are attached to it.

    --
    Scott McPhillips [VC++ MVP]


+ Reply to Thread