How to create a view in SDI MFC application.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

I am removing my view in OnFileNew (at the startup) . There is not
requirement of the view.. instead I put a dialog OnFIleNew which open
after checking a flag if its a startup or in the middle processing of
the application..

void CMymfcApp::OnFileNew()
{
CFrameWnd *pWnd = (CFrameWnd *)m_pMainWnd;
ASSERT_KINDOF(CFrameWnd, pWnd);
CMymfcView *pView=(CMymfcView *)pWnd->SendMessage(WM_CREATE);
ASSERT_KINDOF(CMymfcView,pView);
pView->UpdateWindow();
pView->DestroyWindow();
}

I put grey color in view just to have proper display for the view
(which just appears for the fraction of a second)

void CMymfcView::OnDraw(CDC* pDC)
{
CMymfcDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here

CRect rc;
GetClientRect(&rc);
HGDIOBJ hOldBrush =
pDC->SelectObject(GetSysColorBrush(COLOR_3DSHADOW));
pDC->PatBlt(rc.left, rc.top, rc.Width(), rc.Height(), PATCOPY);
pDC->SelectObject(hOldBrush);
}

Now there is no view.

Now when I bring windows explorer or some other window in front of my
frame, and I again switch back to my application, the grey color is
gone and the display is not proper so I want to create a view when
application (frame) gets focus, so its ondraw event gets fired and grey
color comes back.

But I dotn know how to create a view in SDI mfc application from the
function
void CMainFrame::OnSetFocus(CWnd* pOldWnd)

ANybody please suggest.

Thanks,
Cric.

.



Relevant Pages

  • Re: How to create a view in SDI MFC application.
    ... You could try to do this in OnEraseBkgndinstead of OnDraw() ... I am removing my view in OnFileNew (at the startup). ... I put grey color in view just to have proper display for the view ...
    (microsoft.public.vc.mfc)
  • Re: ksyms vs System.map
    ... int startup(){ ... void cleanup ... 000001fe t startup ... cat /boot/System.map-2.4.26 | grep printk ...
    (comp.os.linux.development.system)
  • Re: freestanding enviroment !
    ... The most popular ... void main; ... since there are no startup parameters and freestanding programs normally ... and folks here will do the same. ...
    (comp.lang.c)