problems with a CWnd subclass in a dialog box

problems with a CWnd subclass in a dialog box

Post by Damien Jon » Tue, 25 Oct 1994 23:14:02



If anyone has nay info on this I'd be much obliged:

Using MSVC 1.5 and MFC.

We wrote a little grid class based on a CWnd class.  Things like
Ctrl-C and SHIFT-Insert work fine as long as the grid is instantiated
in a CFormview class.

As soon as the grid is put in a CDialog the Ctrl-C etc. combinations
no longer work.  (when a cell in the grid has been activated, implemented,
as a CEdit subclass, the Ctrl-C stuff works for the cell).

It looks like the CFormView gets messaged before the grid, but that the
grid gets messages before the CDialog.

Thanks in advance for any help.

 
 
 

problems with a CWnd subclass in a dialog box

Post by David Conn » Wed, 26 Oct 1994 03:33:58



>Path:
>fievel!ncrhub2!nntpa!att-out!pacbell.com!ames!hookup!swrinde!howland.reston.ans.
>net!news.sprintlink.net!sunserver.insinc.net!nemesis.merak.com!usenet

>Newsgroups: comp.os.ms-windows.programmer.misc
>Subject: problems with a CWnd subclass in a dialog box
>Date: 24 Oct 1994 14:14:02 GMT
>Organization: Merak Projects Ltd.
>Lines: 17

>NNTP-Posting-Host: kali.merak.com
>X-Newsreader: WinVN 0.92.1
>If anyone has nay info on this I'd be much obliged:
>Using MSVC 1.5 and MFC.
>We wrote a little grid class based on a CWnd class.  Things like
>Ctrl-C and SHIFT-Insert work fine as long as the grid is instantiated
>in a CFormview class.
>As soon as the grid is put in a CDialog the Ctrl-C etc. combinations
>no longer work.  (when a cell in the grid has been activated, implemented,
>as a CEdit subclass, the Ctrl-C stuff works for the cell).
>It looks like the CFormView gets messaged before the grid, but that the
>grid gets messages before the CDialog.
>Thanks in advance for any help.

If you're using the CWnd SubclassDlgItem, that call _must_ be done before
calling OnInitDialog.  (Found out about that the hard way.  A colleague
actually found it.)

Dave Connet

 
 
 

1. Subclassing CWnd Objects within dialogs - text.txt [01/01]

BEGIN -- Cut Here -- cut here

I am currently trying to develop a way to display a Gantt chart in a dialog box.  The Gantt chart would enable the user to drag and drop CRect objects with information into it, as well as changing the the CRect (length) object in the chart. Basically, we need a method of adding a CWnd to a dialog box so that I can get a CDC* to it and then draw in the window as well as have user input that I believe a CStatic control won't let me do.

Now I could do this using the view-document architecture, but I'm trying to keep it simple and I would like to know how to do this anyway.

The way I have tried to implement this is by sub-classing a CWnd Object in the Dialog Box using something like the following:

        //I have tried doing this before and after CDialog::OnInitDialog();

        GetClientRect(  rect );   //of the dlg

        rect->right = rect->right/2;
        rect->bottom = rect->bottom /2;
        rect->top = rect->top + (rect->bottom/4 );
        rect->left = rect->left + rect->right/4 ;      //adjust so that we fit in the dlg.

        const CRect rect1 = *rect;

        CGantWnd pGant;

        BOOL bSuccess = pGant.CreateEx( NULL, "hello",
                       WS_BORDER | WS_VISIBLE | WS_POPUP,
                                   rect1,
                                   this,
                                   0, NULL );

        ASSERT( bSuccess ) ; // ok here but after we leave OnInitDlg we get an untraceable Gpf.

Anyone know how to create a window within a dlg? Any help would be greatly appreciated.

Maybe there is some code out there that already does this???

Now I am currently using VC++ 2.2  but would like to make this compatable with a 16 bit application.  IS this possible???

Thanks in Advance.

Marc Zabudsky

END -- Cut Here -- cut here

2. *** PC RESARTS WHEN ASKED TO SHUTDOWN ***

3. CWnd in a Dialog box?

4. Amiga Parts

5. How to get CWnd* or Hwnd of a dialog box ?

6. Keeping my Phone Number With no Phone Line?

7. Subclassing FONT Commond Dialog Box

8. PSION Series 3/3a palmtop FAQ part 1/6

9. Need help on subclassing a button in a dialog box

10. Question: Subclassing a dialog box item

11. My mistake, a derived class of CWnd, not subclass

12. Dialog box from a Dialog Box