Subclassing a modeless CDialog inside a CFormView 
Author Message
 Subclassing a modeless CDialog inside a CFormView

Hi

I want to embedd a modeless Dialog inside a FormView

Is there anyone that can help me with that?`

My thought was to use the AppStudio CustomContol
and then have the modeless Dialog a member of
the Formview. Then I would subclass the Dialog by using
SubclassDlgItem.

I would be happy for any suggestion!

Thanks
/roland



Mon, 14 Aug 2000 03:00:00 GMT  
 Subclassing a modeless CDialog inside a CFormView

I am not sure what exactly you want to achieve. But, You can set the dialog
styles to be WS_CHILD and DS_CONTROL so that it will be created as a
control. Then, you can use Create () of CDialog to create it and
SetWindowPos to move it to the right position. Just know that these work on
win32 only since DS_CONTROL is not present in 16 bit.

--
Girish Bharadwaj [VC++/MVP]

Quote:

>Hi

>I want to embedd a modeless Dialog inside a FormView

>Is there anyone that can help me with that?`

>My thought was to use the AppStudio CustomContol
>and then have the modeless Dialog a member of
>the Formview. Then I would subclass the Dialog by using
>SubclassDlgItem.

>I would be happy for any suggestion!

>Thanks
>/roland




Mon, 14 Aug 2000 03:00:00 GMT  
 Subclassing a modeless CDialog inside a CFormView

Thank's for the tip. The reason why I want to do that
is following.

I have a screen with som groups of edit-controls, combo-boxes
and so on. Each group describes different status on a machinery.
I thought it would be nice to have a couple of modeless dialogs where
each group of machinery status is descbried, and the just puzzle them
together on a form. That way I can change things on each group without
having to bother about the other groups or the formview itself. To the
user,  the formview will look a if there is just a formview with controls,
and
not a bunch of dialogs. The reason for the whole approach is just for
me, to make it easy to make changes.

Perhaps is there a better touch to solve this, than subclassing dialogs
on a formview, but that was what I first came up with.

Quote:

>I am not sure what exactly you want to achieve. But, You can set the dialog
>styles to be WS_CHILD and DS_CONTROL so that it will be created as a
>control. Then, you can use Create () of CDialog to create it and
>SetWindowPos to move it to the right position. Just know that these work on
>win32 only since DS_CONTROL is not present in 16 bit.

>--
>Girish Bharadwaj [VC++/MVP]


>>Hi

>>I want to embedd a modeless Dialog inside a FormView

>>Is there anyone that can help me with that?`

>>My thought was to use the AppStudio CustomContol
>>and then have the modeless Dialog a member of
>>the Formview. Then I would subclass the Dialog by using
>>SubclassDlgItem.

>>I would be happy for any suggestion!

>>Thanks
>>/roland




Mon, 14 Aug 2000 03:00:00 GMT  
 Subclassing a modeless CDialog inside a CFormView

Not quite sure what you want here from your description.  One
interpretation I can make is that you would like a CFormView to launch
a modeless dialog.  As far as I know there is no problem with this.
As to "subclassing" the modeless dialog, this is what is usually done
with any dialg; you create a new class for your dialog, such as
CMyDialog, using ClassWizard.  You might, for example, declare a
variable in your CFormView-derived class:
        CMyDialog * modeless;

and create the modeless dialog from this.  There are some techniques
you might want to deal with here to make the modeless dialog more
"cooperative".  One problem with a modeless dialog is that you have no
way to detect, really, when it has gone away.  Alas, this has some
serious implications; if you tried
        modeless->SetFocus()
if your invoke-my-modeless-dialog button was clicked on the CFormView,
and the user had closed the modeless dialog, the natural action of the
CWnd::PostNcDestroy is "delete this", which means your "modeless"
pointer is now pointing to hyperspace.  Oops.  You can't even ask
        ::IsWindow(modeless->m_hWnd)
because the pointer is still trash.  I've usually handled this by
having a notification message, a registered window message with a name
such as UWM_MODELESS_TERMINATED, in which I put the HWND of the
window in the WPARAM (probably a holdover from Win16 programming since
WPARAM has always been big enough to hold a handle).  When the parent
of the dialog receives this message, usually send in the OnDestroy
handler, it figures out which modeless dialog is being shut down and
sets its CWnd * pointer to NULL.

Another thing you might want to do is cause your modeless dialog to
disappear if the window is not the active window.  Use the OnActivate
message and ShowWindow to handle this.  Use SW_SHOW for activation and
SW_HIDE for deactivation, something like (off the top of my head)

void OnActivate(UINT state, CWnd * other, BOOL minimized)
{
 if(minimized)
    return;
 if(modeless == NULL)
     return;
  switch(state)
      { /* state */
       case WA_ACTIVE:
       case WA_CLICKACTIVE:
        modeless->ShowWindow(SW_SHOW);
        break;
       case WA_INACTIVE:
        modeless->ShowWIndow(SW_HIDE);
        break;
      } /* state */

Quote:
}

A similar handling of WM_SIZE may be necessary to hide the window when
the CFormView is minimized.

Note that these may have to go in the CFormView's frame class...it has
been a while since I've done this particular trick, so I forget if the
messages make their way into the CFormView or not.
                                joe

On Thu, 26 Feb 1998 00:13:11 +0100, "Roland Str?lberg"

Quote:

>Hi

>I want to embedd a modeless Dialog inside a FormView

>Is there anyone that can help me with that?`

>My thought was to use the AppStudio CustomContol
>and then have the modeless Dialog a member of
>the Formview. Then I would subclass the Dialog by using
>SubclassDlgItem.

>I would be happy for any suggestion!

>Thanks
>/roland


Joseph M. Newcomer

http://www3.pgh.net/~newcomer


Tue, 15 Aug 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. CDialog inside CDialog

2. Problems with CFormView inside CFormView (mnemonic keys)

3. subclassing a CFormView control

4. subclassing controls in CFormView

5. Subclassing CDialog with SetWindowLong(...)

6. Subclassing doesn't work for CFormView

7. Subclassing the header control inside list control

8. Subclassing DateTime control in CFormView

9. Subclassing CDialog with ClassWizard

10. Subclassing doesn't work for CFormView

11. CDialog: Service calling a MFC-linked DLL instanciating a modeless dialog box

12. CFormView / CDialog Bar and tabs !!

 

 
Powered by phpBB® Forum Software