mfc >> Non-modal dialog in CSplitterWindow???

by Stuart Redmann » Thu, 16 Mar 2006 00:46:25 GMT

Hello newsgroup,

is it possible to show a non-modal dialog in a pane of a
CSplitterWindow? The documentation says that CSplitterWindow may contain
windows that are not views, but I have some doubts. Since
CSplitterWindow's CreateView method assumes that the window _IS_ a view
(it calls Wnd::Create, which is utterly inappropriate if I want to
create a modeless dialog), I don't see how I can use CSplitterWindow.

Is there any alternative to CSplitterWindow?


Some words about my project:
My app should display image data. This done via the common doc-view
approach. There must be a dialog that allows the user to change the
camera settings. This dialog must be visible the whole time. It should
not be a view (else clicking on this window would disable the toolbar
buttons, none of the buttons make sense for this window).

Thanks,
Stuart


mfc >> Non-modal dialog in CSplitterWindow???

by Tom Serface » Thu, 16 Mar 2006 01:04:27 GMT


You could just use RUNTIME_CLASS() on the dialog class to put it in a view,
but I'm not sure this would solve your problem.

You might want to put your toolbar code into the mainframe class or use
OnCmdMsg() to route the messages to all of the views. Then you could just
us a CFormView for your dialog.

Tom








mfc >> Non-modal dialog in CSplitterWindow???

by Scott McPhillips [MVP] » Thu, 16 Mar 2006 05:28:15 GMT




If you really want a splitter, you probably should put a CFormView into
the splitter pane instead of a dialog. A CFormView is a view that
displays a dialog template. Using a CFormView will not disable the
toolbar buttons if you put the OnUpdate... handlers in CMainFrame.

From your description it sounds like you might not really want a
splitter. You can simply create a modeless dialog independent of the
views (it would float above the view), or you can put the user controls
on a CDialogBar (a strip along some edge of the view), or you could put
them on a control pallette. The MFC samples contains examples of all of
these approaches.

--
Scott McPhillips [VC++ MVP]



Non-modal dialog in CSplitterWindow???

by Stuart Redmann » Thu, 16 Mar 2006 16:44:52 GMT




This is quite an ugly workaround. Enabling and disabling toolbar command
is the responsibility of a view, the mainframe should not be burdened
with such tasks. Putting my dialog into a view won't do no good: I would
get back the problems that I got before I tried to make the view to a
dialog.




See above about putting the handlers in the main frame.


I want a dialog that does not float, but sits on the left side of the
frame window. One should be able to make it thinner (resize it
horizontally), so a splitter bar would be perfect. The dialog should be
able to scroll vertically, though.

Here is my (ugly) workaround: I use a CScrollView instead of the dialog.
This view has empty OnUpdate-handlers, so it won't mess with the tool
bar. Any OnCommands from the tool bar are routed by hand to the view.

I believe that this is quite unsophisticated. There should be a better
way to do this in MFC. I will have a look at the CDialogBar class. Is it
possible to create a dialog bar with any dialog template? Even
containing edits and such? Can I make a CDialogBar scrollable?

Thanks,
Stuart


Non-modal dialog in CSplitterWindow???

by KMA » Thu, 16 Mar 2006 18:44:35 GMT







The dialogbar does seem like a good candidate for you. You can use any
controls on it, edit, labels etc. This is the whole point: it's like a
button toolbar with more than just buttons. The problem is scrolling. You
might be able to put a "scrollable" container on the dialog bar then put
your contained controls in it.





Non-modal dialog in CSplitterWindow???

by Scott McPhillips [MVP] » Thu, 16 Mar 2006 19:47:33 GMT

>>I want a dialog that does not float, but sits on the left side of the

Wanting the dialog resizable and scrollable are two strong reasons to
prefer CFormView in a splitter pane. (Note that CFormView inherits from
CScrollView: The scrolling will be automatic.)

For the toolbar OnUpdate issue you have your choice between the
recommended ugly workaround and your own ugly workaround :(

The toolbar is a child of the mainframe and is created/resized by it, so
I don't think that solution is ugly at all. :)

--
Scott McPhillips [VC++ MVP]



Non-modal dialog in CSplitterWindow???

by Stuart Redmann » Thu, 16 Mar 2006 23:15:49 GMT

Thanks to both of you,

Stuart


Non-modal dialog in CSplitterWindow???

by Tom Serface » Fri, 17 Mar 2006 00:05:10 GMT

OK, that's fair, but it does work.

If I need to do more than one view in a frame (like an Explorer type
application) I tend to use the OnCmdMsg() routing idea. The only caveat is
that you wouldn't want the same Alt Keys, or toolbars used by multiple views
since it could confuse them.

This article might be interesting to you:

http://www.codeproject.com/docview/splitcmdroute.asp

Tom







Similar Threads

1. problems when a non modal dialog closes, and has an open Modal Dialog

2. Make a modal dialog non-modal

I know this sounds strange, but I have a good reason to do it:

I want to open a modal dialog, but in the OnShow event I want to
make the dialog non-modal. Can this be done and if so, how?

(The reason that I want to do this is that I am using a third 
party library that provides various GUI controls. If the user
double-clicks on this particular control, I open the dialog in
question. However, if I open the dialog in a non-modal format,
the dialog box ends up behind the original form, not in front
of it as it should be. I found that if I open the dialog in
a modal format, it is in front).

3. display of modal dialog behind modal dialog

4. labels in non modal dialog boxes

Hello,

from inside a button handler, I am launching a dialog box that contains
lables and text boxes.
The dialog box is launched using dlg.Show(). In this situation the contents
of the text boxes are
visible but not the contents of the label. They become visible only after
the button handler returns.

If the dialog box is launched as dlg.ShowDialog() than everything is visible
but further execution of
the button handler stops (obviously) till the dialog returns.

Is there a solution to using dlg.Show() and yet have all the labels display
correctly?

all help appreciated.
thanks
LK


5. Updating a TextBox in a Non Modal Windows Form Dialog - CSharp/C#

6. Updating non-modal child dialogs

Dennis,

Unless you are dealing with a simple invalidating/redrawing of the dialog
(which you would accomplish with Invalidate()/Refresh()/Update()), you would
have to define your own accessor methods for the parent window to use.

It really depends what exactly you want the dialog to update.

Alex

"Dennis C. Drumm" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
> Alex:
>
> What does the child dialog expose that the parent can use to update it? I
> think that is what I'm looking for.
>
> Thanks,
>
> Dennis
>
>
> "Alex Bendig" < XXXX@XXXXX.COM > wrote in message
> news:besf9c$lke$ XXXX@XXXXX.COM ...
> > Dennis,
> >
> > Well, I suppose there are at least two methods:
> >
> > 1. The child dialog exposes accessor methods that the parent window can
> use
> > to cause the updating.
> > 2. The parent window lets the child dialog know, when a change occured
> > (through an event) and the child dialog can perform the updating.
> >
> > Hm, I am not entirely sure if this is helpful at all, since I cannot be
> > entirely sure, if you defined the problem the way you meant to define
it.
> > ;-)
> >
> > Alex
> >
> > "Dennis C. Drumm" < XXXX@XXXXX.COM > wrote in message
> > news:eYAf% XXXX@XXXXX.COM ...
> > > I have a situation where a windows form application has a non modal
> child
> > > dialog. Because it is non modal, the user can make changes at the
parent
> > > that require changes to the child. Is there a way (using events?) to
> cause
> > > the child to update?
> > >
> > > I hope I have explained the situation, I guess I'm not sure exactly
how
> to
> > > even define the problem.
> > >
> > > Thanks for your comments,
> > >
> > > Dennis
> > >
> > >
> >
> >
>
>


7. Closing a Non-Modal Dialog - CSharp/C#

8. Problem: Non-modality of modal dialogs

Hi All,

I have a dialog-based application in MFC (main window is 
CDialog1).  I have a separate thread (class derived from 
CWinThread) in the application.  The main window 
(m_pmainWnd) of the thread is a hidden modeless dialog 
(this is CDialog2).  I have created the thread in 
InitInstance() of my application class using AfxBeginThread
().  

I PostMessage() to the "hidden modeless dialog" on a 
button-click of the application dialog.  The PostMessage() 
handler displays a modal dialog (this is CDialog3).  
Button-click on 'Dialog3' displays another modal dialog 
(this is CDialog4).

Now, in ideal case the user should be able to access 
only 'Dialog4' because it is displayed using DoModal().  
But, I can switch between 'Dialog3' and 'Dialog4' as if 
both were modeless dialogs!!!  Please suggest a solution 
to this problem.  

I found the explanation for current behavior by 
debugging.  PreModal() returns handle to the 'Dialog2' as 
parent for both 'Dialog3' and 'Dialog4'!!!  So, there is 
no relation established between these.  That is why 
switching is possible.  

If I use all the same code (Display the dialog hierarcy on 
application thread) without creating a separate thread the 
dialogs hierarchy works as expected.  

Regards,
Yadnesh Phadke,
Software Engineer,
Pune, India