Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:49:26+00:00 2026-06-13T17:49:26+00:00

in my application, i currently have 2 document types. The one i will be

  • 0

in my application, i currently have 2 document types. The one i will be focusing on, will be the second. My application is a 3d engine editor, which is build in MFC MDI. The first document is the render window, which works perfect, because it’s simple to extract the hwnd of it, and then send it to my graphics class. But my second window, which is scripting, is supposed (for now) just to have a rich edit. But for some reason, it doesn’t render(actually it does, but only once :/).

CEditorScriptView.h

#pragma once

#include "CEditorDoc.h"
class CCEditorCntrItem;

class CCEditorScriptView : public CView
{
public: // create from serialization only
    CCEditorScriptView();
    DECLARE_DYNCREATE(CCEditorScriptView)

// Attributes
public:
    CCEditorDoc* GetDocument() const;
    static CCEditorScriptView * GetView();
    // m_pSelection holds the selection to the current CCEditorCntrItem.
    // For many applications, such a member variable isn't adequate to
    //  represent a selection, such as a multiple selection or a selection
    //  of objects that are not CCEditorCntrItem objects.  This selection
    //  mechanism is provided just to help you get started

    // TODO: replace this selection mechanism with one appropriate to your app
    CCEditorCntrItem* m_pSelection;
    CRichEditCtrl* m_rEdit;

    int  TYPE;

// Operations
public:

// Overrides
public:
    virtual void OnDraw(CDC* pDC);  // overridden to draw this view
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
    virtual void OnInitialUpdate(); // called first time after construct
    virtual BOOL IsSelected(const CObject* pDocItem) const;// Container support

// Implementation
public:
    virtual ~CCEditorScriptView();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
    afx_msg void OnDestroy();
    afx_msg void OnSetFocus(CWnd* pOldWnd);
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnInsertObject();
    afx_msg void OnCancelEditCntr();
    afx_msg void OnFilePrint();
    afx_msg void OnFilePrintPreview();
    afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
    DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in CEditorView.cpp
inline CCEditorDoc* CCEditorScriptView::GetDocument() const
   { return reinterpret_cast<CCEditorDoc*>(m_pDocument); }
#endif

CEditorScriptView.cpp:

#include "stdafx.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "CEditor.h"
#endif

#include "CEditorDoc.h"
#include "CntrItem.h"
#include "resource.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CCEditorView

#pragma region CCEditorScriptView

IMPLEMENT_DYNCREATE(CCEditorScriptView, CView)

BEGIN_MESSAGE_MAP(CCEditorScriptView, CView)
    ON_WM_DESTROY()
    ON_WM_SETFOCUS()
    ON_WM_SIZE()
    ON_COMMAND(ID_OLE_INSERT_NEW, &CCEditorScriptView::OnInsertObject)
    ON_COMMAND(ID_CANCEL_EDIT_CNTR, &CCEditorScriptView::OnCancelEditCntr)
    ON_COMMAND(ID_FILE_PRINT, &CCEditorScriptView::OnFilePrint)
    ON_WM_CONTEXTMENU()
    ON_WM_RBUTTONUP()
END_MESSAGE_MAP()

// CCEditorView construction/destruction

CCEditorScriptView::CCEditorScriptView()
{
    EnableActiveAccessibility();
    m_pSelection = NULL;
    // TODO: add construction code here

    m_rEdit->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE,
                    CRect(10,10,500,500), this, 1);

    //m_rEdit->SetFocus();

    TYPE = ID_CEDITOR_VIEW_SCRIPT;
}

CCEditorScriptView::~CCEditorScriptView()
{
}

BOOL CCEditorScriptView::PreCreateWindow(CREATESTRUCT& cs)
{
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs

    return CView::PreCreateWindow(cs);
}

// CCEditorView drawing

void CCEditorScriptView::OnDraw(CDC* pDC)
{
    if (!pDC)
        return;

    CCEditorDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
        return;

    // TODO: add draw code for native data here
    // TODO: also draw all OLE items in the document

    // Draw the selection at an arbitrary position.  This code should be
    //  removed once your real drawing code is implemented.  This position
    //  corresponds exactly to the rectangle returned by CCEditorCntrItem,
    //  to give the effect of in-place editing.

    // TODO: remove this code when final draw code is complete.

    m_rEdit->UpdateWindow();

    if (m_pSelection != NULL)
    {
        CSize size;
        CRect rect(10, 10, 210, 210);

        if (m_pSelection->GetExtent(&size, m_pSelection->m_nDrawAspect))
        {
            pDC->HIMETRICtoLP(&size);
            rect.right = size.cx + 10;
            rect.bottom = size.cy + 10;
        }
        m_pSelection->Draw(pDC, rect);
    }
}

// MDI view implementation file
CCEditorScriptView * CCEditorScriptView::GetView()
{
    CMDIChildWnd * pChild =
        ((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();

    if ( !pChild )
        return NULL;

    CView * pView = pChild->GetActiveView();

    if ( !pView )
        return NULL;

    // Fail if view is of wrong kind
    /*if ( ! pView->IsKindOf( RUNTIME_CLASS(CCEditorRenderView) ) )
        return NULL;*/

    return (CCEditorScriptView *) pView;
}

void CCEditorScriptView::OnInitialUpdate()
{
    CView::OnInitialUpdate();

    // TODO: remove this code when final selection model code is written
    m_pSelection = NULL;    // initialize selection
}

void CCEditorScriptView::OnDestroy()
{
    // Deactivate the item on destruction; this is important
    // when a splitter view is being used
   COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
   if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
   {
      pActiveItem->Deactivate();
      ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
   }
   CView::OnDestroy();
}

// OLE Client support and commands

BOOL CCEditorScriptView::IsSelected(const CObject* pDocItem) const
{
    // The implementation below is adequate if your selection consists of
    //  only CCEditorCntrItem objects.  To handle different selection
    //  mechanisms, the implementation here should be replaced

    // TODO: implement this function that tests for a selected OLE client item

    return pDocItem == m_pSelection;
}

void CCEditorScriptView::OnInsertObject()
{
    // Invoke the standard Insert Object dialog box to obtain information
    //  for new CCEditorCntrItem object
    COleInsertDialog dlg;
    if (dlg.DoModal() != IDOK)
        return;

    BeginWaitCursor();

    CCEditorCntrItem* pItem = NULL;
    TRY
    {
        // Create new item connected to this document
        CCEditorDoc* pDoc = GetDocument();
        ASSERT_VALID(pDoc);
        pItem = new CCEditorCntrItem(pDoc);
        ASSERT_VALID(pItem);

        // Initialize the item from the dialog data
        if (!dlg.CreateItem(pItem))
            AfxThrowMemoryException();  // any exception will do
        ASSERT_VALID(pItem);

        if (dlg.GetSelectionType() == COleInsertDialog::createNewItem)
            pItem->DoVerb(OLEIVERB_SHOW, this);

        ASSERT_VALID(pItem);
        // As an arbitrary user interface design, this sets the selection
        //  to the last item inserted

        // TODO: reimplement selection as appropriate for your application
        m_pSelection = pItem;   // set selection to last inserted item
        pDoc->UpdateAllViews(NULL);
    }
    CATCH(CException, e)
    {
        if (pItem != NULL)
        {
            ASSERT_VALID(pItem);
            pItem->Delete();
        }
        AfxMessageBox(IDP_FAILED_TO_CREATE);
    }
    END_CATCH

    EndWaitCursor();
}

// The following command handler provides the standard keyboard
//  user interface to cancel an in-place editing session.  Here,
//  the container (not the server) causes the deactivation
void CCEditorScriptView::OnCancelEditCntr()
{
    // Close any in-place active item on this view.
    COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
    if (pActiveItem != NULL)
    {
        pActiveItem->Close();
    }
    ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
}

// Special handling of OnSetFocus and OnSize are required for a container
//  when an object is being edited in-place
void CCEditorScriptView::OnSetFocus(CWnd* pOldWnd)
{
    COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
    if (pActiveItem != NULL &&
        pActiveItem->GetItemState() == COleClientItem::activeUIState)
    {
        // need to set focus to this item if it is in the same view
        CWnd* pWnd = pActiveItem->GetInPlaceWindow();
        if (pWnd != NULL)
        {
            pWnd->SetFocus();   // don't call the base class
            return;
        }
    }

    CView::OnSetFocus(pOldWnd);
}

void CCEditorScriptView::OnSize(UINT nType, int cx, int cy)
{
    CView::OnSize(nType, cx, cy);
    COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
    if (pActiveItem != NULL)
        pActiveItem->SetItemRects();
}

void CCEditorScriptView::OnFilePrint()
{
    //By default, we ask the Active document to print itself
    //using IOleCommandTarget. If you don't want this behavior
    //remove the call to COleDocObjectItem::DoDefaultPrinting.
    //If the call fails for some reason, we will try printing
    //the docobject using the IPrint interface.
    CPrintInfo printInfo;
    ASSERT(printInfo.m_pPD != NULL); 
    if (S_OK == COleDocObjectItem::DoDefaultPrinting(this, &printInfo))
        return;

    CView::OnFilePrint();

}


void CCEditorScriptView::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
    ClientToScreen(&point);
    OnContextMenu(this, point);
}

void CCEditorScriptView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
    theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}

// CCEditorView diagnostics

#ifdef _DEBUG
void CCEditorScriptView::AssertValid() const
{
    CView::AssertValid();
}

void CCEditorScriptView::Dump(CDumpContext& dc) const
{
    CView::Dump(dc);
}

CCEditorDoc* CCEditorScriptView::GetDocument() const // non-debug version is inline
{
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCEditorDoc)));
    return (CCEditorDoc*)m_pDocument;
}
#pragma endregion
#endif //_DEBUG


// CCEditorView message handlers

And this is currently what it outputs:

enter image description here

Now is seems ok, but it only renders it once, meaning if I would click on it(richEdit) nothing would happen, or if I tried to type in the richEdit, nothing would happen as well. So I’m wondering, why? Why doesn’t it continue rendering, or updating the view?

Thank You

PS. If you wan’t me to post anything, like code, please comment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:49:27+00:00Added an answer on June 13, 2026 at 5:49 pm

    So, it seems that I’ve solved my problem, here’s the solution:

    I looked at the console and noticed that the window had failed to create. And i came to the solution that the m_rEdit was the fault(by testing). So i figured out that i had to initialize the pointer in the constructor, and use the m_rEdit->Create in the OnInitialUpdate(). And that fixed it.

    Anyways, thank you for anyone who tried to solve this mystery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a 32-bit .Net application (on x86 Windows) which require lots of
I am creating one application with jquery.mobile-1.0a4.1 release. I have a page which is
I am working on splitting out an existing, working application that I currently have
I currently have an application I'm writing in c# (using .NET) that requires me
We currently have an application that depends largely on stored procedures. There is a
I currently have an application in the play store for both tablets and smartphone
I currently have an application that uses a browserfield to access an internet page
I currently have a mobile application that can record speech as either a WAV
I currently have a UINavigationController based application that works just fine. I'd like to
I currently have an iPhone application with a tabbar and multiple viewcontrollers. All the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.