A Seperate frame, and a view in it.
wayne.dengel@octel.com Monday, October 07, 1996 Environment: VC++ 4.0, NT 4.0, WIn95 Hello, I am doing the following. I have an app. This App creates a seperate frame window. I am trying to put a CView into this frame. I DONOT want a DOCUMENT, just a frame with a view. How do I do this. I tried to, in my frame, in OnCreateClient, in pContext, do this pContext->m_pNewViewClass=RUNTIME_CLASS(CMyView); It does not work. It always crashes. Any ideas on how to do this. Thank you for your time. Wayne
Sumit Chawla -- schawla@csci.csc.com Monday, October 07, 1996 [Mini-digest: 5 responses] Environment: VC++ 4.0, NT 4.0, WIn95 > > Hello, > > I am doing the following. I have an app. This App creates a seperate > frame window. I am trying to put a CView into this frame. I DONOT > want a DOCUMENT, just a frame with a view. How do I do this. > > I tried to, in my frame, in OnCreateClient, in pContext, do this > pContext->m_pNewViewClass=RUNTIME_CLASS(CMyView); > > It does not work. It always crashes. > > Any ideas on how to do this. > > Thank you for your time. > > Wayne > Hi! I had the same problem. I got around it by using a CCreateContext object on the stack. Like this: BOOL MyFrameWindow::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*pContext) { CCreateContext context; context.m_pCurrentFrame = 0; context.m_pNewViewClass = RUNTIME_CLASS(MyView); return CFrameWnd::OnCreateClient(lpcs,&context); } -Sumit. schawla@csci.csc.com -----From: Steve MarkHi Wayne, You can use the doc-template architecture to create a view without a document, as follows: CMultiDocTemplate mdt(IDR_APPTYPE, NULL, RUNTIME_CLASS(NChildFrame), RUNTIME_CLASS(NAppView)); CFrameWnd* pfrm = mdt.CreateNewFrame(NULL, NULL); mdt.InitialUpdateFrame(pfrm, NULL, TRUE); Steve -----From: Roger Onslow/Newcastle/Computer Systems Australia/AU Just curious -- what is the problem with a document? Many MFC samples have a bare minimum (default) document class an all the real work in the app. It seems that the overheads involved in getting the app to work without a document are a darn sight more than just letting it a simple bare document class. In any case, perhaps you are confusing a document with an external file. A "document" in doc/view architecture is simply the place where you keep the data, and the "view" the place where you display/interact with it. The only reason why you would have view without a document would be when there is no data -- so what would your view show? Even in that case, you can have a document with no data in it so the model still works. So what I'm saying is, rather than going out of your way to work around the doc/view architecture, why not work with it and make use of all the benefits that MFC gives you (like apps that don't crash :-) Roger Onslow -----From: NIELS ULL JACOBSEN As far as I know, you don't. Documents and views are intimately connected. Either have a dummy document or create a frame window with a plain CWnd in it. Just create it in OnCreateClient, ignoring the pContext. -----From: Simon Salter What I do is to have the view as a child of the frame. So in OnCreate() of the frame I put (error handling omitted) m_pView = new CMyView; Crect crInit(0,0,0,0); m_ pView ->Create(NULL,_T(""),dwWndStyle,crInit,this,nID,NULL); Then you'll need some house keeping, in particular in the frames OnSize() you will probably want to size your view and so on. Simon
Dave_Rabbers@Quinton-Eng.CCMAIL.CompuServe.COM Wednesday, October 09, 1996 Use a DocTemplate with a NULL pointer to a document runtime class. This has been covered in much detail recently. Look in the list archives for more specifics. ______________________________ Reply Separator _________________________________ Subject: A Seperate frame, and a view in it. Author: INTERNET:wayne.dengel@octel.com at CSERVE Date: 10/7/96 3:11 PM Sender: owner-mfc-l@majordomo.netcom.com Received: from majordomo.netcom.com (listless.netcom.com [206.217.29.105]) by dub-img-3.compuserve.com (8.6.10/5.950515) id MAA19868; Mon, 7 Oct 1996 12:57:19 -0400 Received: by majordomo.netcom.com (8.7.5/8.7.3/(NETCOM MLS v1.01)) id JAA01107; Mon, 7 Oct 1996 09:07:26 -0700 (PDT) From: wayne.dengel@octel.com Mime-Version: 1.0 Date: Mon, 7 Oct 1996 08:41:30 -0700 Message-Id: <258FBDE0.1240@corp.octel.com> Subject: A Seperate frame, and a view in it. To: mfc-l@netcom.com Content-Type: text/plain; charset=US-ASCII
| Вернуться в корень Архива |