how to put a window on dialog in MFC

From: Marcin (mati776_at_wp.pl)
Date: 08/10/04


Date: Tue, 10 Aug 2004 15:34:38 +0200

I have to write a small program in Visual C++ using MFC. Problem is that I
have no idea how to create and show windows i MFC when the parent is a
dialog window. At the beginning I decided to choose "dialog based project"
becouse it seemed to be simmillar to progrmming in C++ Builder but it was
only the illussion.
What I want to do:
    I want to put a window (not a control fom toolbox but regular blank
window) on my dialog to do some drawing on it.
What I don't know:
    How to Create the window?
    Where to create the window? In what class, module ?

I tried to write like this (I placed this code into dialog constructor )....

(...)
CmapaDlg::CmapaDlg(CWnd* pParent /*=NULL*/)
: CDialog(CmapaDlg::IDD, pParent)
{
     CString classname = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);
    CWnd okno;
    okno.Create((LPCTSTR)classname, "moje_okno", WS_CHILD | WS_VISIBLE |
WS_BORDER, CRect(1,1,20,20), this, NULL, NULL);
    okno.ShowWindow(SW_SHOW);
}

... and it doesn't work



Relevant Pages

  • Re: trouble with CDC
    ... far fewer calls with the 1 msec delay than with the 50 msec delay. ... window in the upper left corner of the screen. ... Before MFC, these objects were referenced by handles. ... The pointer can be used immediately unless there is some race condition ...
    (microsoft.public.vc.mfc)
  • Re: FromHandle purpose with DCs and GDI objects
    ... >>object in the handle map overwriting the existing one if there is one. ... I'm not sure what difference is between Attach CWnd, ... one of the standard MFC collection classes. ... MFC keeps the temporary and permanent window handle map in thread local ...
    (microsoft.public.vc.mfc)
  • Re: MFC/.NET afxwin.h
    ... You are confusing MFC and base window objects. ... If you are not finding afxwin.h, you have probably failed to install the MFC source code. ...
    (microsoft.public.vc.mfc)
  • Re: Confused on syntax
    ... Yes, code like this *would* be found under the hood of MFC, because it has to handle all ... You cannot connect to a window without an HWND. ... you would not declare it. ...
    (microsoft.public.vc.mfc)
  • =?windows-1252?Q?Re=3A_Why_we_have_seperate_Create=28=85=29_in_MFC?=
    ... function in MFC?< ... different from creating the actual window in the windows kernel. ...   It is far from object oriented ... some of us like "thick" constructors where an object, once created, ...
    (microsoft.public.vc.mfc)