Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create a CWnd or CView in a MFC SDI application

291 views
Skip to first unread message

frank kuhn

unread,
Sep 15, 2004, 12:18:51 PM9/15/04
to
Hi everybody,

i made a MFC SDI programm with many dialogs, but now i want to make a
new window to show my data like in ms project. I use the CView from
the SDI only as a gray background. Now i tryed to make a new window
with CWnd or CView window, but both are not working.

If i use CView, i need a MDI application, but i have a SDI. If i
create my own window with CWnd in CMainFrame::OnCreate(), this CWnd
get's no messages from t he mouse and seems to be inactive.

What should i do?

This is what i done in CMainFrame::OnCreate()

CWnd *pc_wnd = new CWnd;
RECT rect = { 0,0,100,100};
pc_wnd->Create( lpClassName, L"Storyboard Time Diagramm",
WS_CAPTION | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
rect, this, NULL, NULL );

Scott McPhillips [MVP]

unread,
Sep 15, 2004, 7:58:27 PM9/15/04
to
frank kuhn wrote:

The problem with the code is that you are creating a CWnd, not a
CWnd-derived class. You can't add message handers to CWnd. You can add
message handlers to a class you derive from CWnd.

If you want to show some data in the view then creating a CWnd is not
the correct approach. You can either add drawing code to the CView that
you already have, or you can derive a new view class (from CScrollView
probably) and add code that switches views in your SDI application.
Search MSDN for "view swap" and "switch view" for a few examples.

--
Scott McPhillips [VC++ MVP]

0 new messages