프로그래밍

다이얼로그에 뷰 삽입하기

Valentyne 2018. 6. 6. 20:39

CCreateContext pContext;

CTestView* m_pTestView;


다이얼로그에 멤버 변수로 컨텍스트와 뷰를 만든다.


다어얼로그의 OnInitDialog()에서

pContext.m_pNewViewClass = RUNTIME_CLASS(CTestView);

m_pTestView = (CTestView *)((CFrameWnd*)this)->CreateView(&pContext);


RECT r = { 0, 0, 300, 300 };
m_pTestView->MoveWindow(&r);

동적으로 클래스를 만들고 MoveWindow( )로 위치를 정해준다.

m_pTestView->OnInitialUpdate();

m_pTestView->ShowWindow(SW_NORMAL); 

를 추가적으로 해줄 수도 있다.


int CTextureView1::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)

{

// TODO: Add your message handler code here and/or call default


return CDialog::OnMouseActivate(pDesktopWnd, nHitTest, message);

}


반드시 OnMouseActivate 메세지 처리를 재정의해서
CWnd::를 CDialog로 바꿔준다. 안하면 창 내 클릭시 터짐.