Как добавить CEdit на вьюшку
От: cupuyc.  
Дата: 28.06.13 10:33
Оценка:
Че то я туплю. Подскажите плиз как добавить контрол ввода инфы на отображение?

вот h\cpp вьюшки если что:


class CTest_2View : public CView
{
private:
    CRect m_VectorRect;
    bool exitFlag;
    bool buttonFlag;

protected: // create from serialization only
    CTest_2View();
    DECLARE_DYNCREATE(CTest_2View)

public:
    CTest_2Doc* GetDocument() const;

public:
    virtual void OnDraw(CDC* pDC);  // overridden to draw this view
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

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

protected:
    afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
    afx_msg void OnShowVectors();

    DECLARE_MESSAGE_MAP()
};

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

#include "stdafx.h"
#include "Test_2.h"
#include "Test_2Doc.h"
#include "Test_2View.h"
#include "СInParamsDlg.h"
#include "VectorMap.h"
#include <time.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNCREATE(CTest_2View, CView)

BEGIN_MESSAGE_MAP(CTest_2View, CView)
    ON_WM_SHOWWINDOW()
    ON_COMMAND(ID_SHOW_VECTORS,OnShowVectors)
END_MESSAGE_MAP()

CTest_2View::CTest_2View()
{
    m_VectorRect.SetRect(50, -100, 250, -200); 
    m_VectorRect.NormalizeRect(); 

    exitFlag = false;
    buttonFlag = false;
}

CTest_2View::~CTest_2View()
{
}

BOOL CTest_2View::PreCreateWindow(CREATESTRUCT& cs)
{
    return CView::PreCreateWindow(cs);
}

void CTest_2View::OnDraw(CDC* pDC)
{
    CTest_2Doc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
        return;

    pDC->SetMapMode(MM_LOENGLISH);    
    CPen RectPen(PS_SOLID,1,RGB(0,0,255));
    pDC->SelectObject(RectPen);
    pDC->Rectangle(m_VectorRect);

    CPen LinesPen(PS_SOLID,2,RGB(0,255,0));    
     pDC->SelectObject(LinesPen);
    pDC->MoveTo(20,-240);
    pDC->LineTo(20,-50);
    pDC->MoveTo(20,-240);
    pDC->LineTo(290,-240);

    if(buttonFlag)
    {
        int lengh = GetDocument()->GetVectMap()->GetVectorMap().size();

        for(int i = 0; i < lengh; ++i)
        {
            COneVector vect;
            vect = GetDocument()->GetVectMap()->GetVectorMap()[i];
        
            CPen VectsPen(PS_SOLID,0,RGB(255,0,0));    
            pDC->SelectObject(VectsPen);
            pDC->MoveTo(vect.x1,vect.y1);
            pDC->LineTo(vect.x2,vect.y2);
        }
    }
}

#ifdef _DEBUG
CTest_2Doc* CTest_2View::GetDocument() const // non-debug version is inline
{
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTest_2Doc)));
    return (CTest_2Doc*)m_pDocument;
}
#endif //_DEBUG
void CTest_2View::OnShowWindow(BOOL bShow, UINT nStatus)
{
    CView::OnShowWindow(bShow,nStatus);

    if(!exitFlag)
    {
        СInParamsDlg dlg;
        dlg.DoModal();
        
        GetDocument()->CreateVectMap(dlg.GetVectNum());

        exitFlag = true;
    }    
}
void CTest_2View::OnShowVectors()
{
    buttonFlag = true;
    Invalidate();
}
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.