Solved

Dialog box inside scrolling view

Posted on 1998-10-05
10
236 Views
Last Modified: 2013-11-20
Dear Experts,

This is about placing a dialog box inside a scrolling view but in a specific way.

At the moment i have a normal scrolling view and a dialogue box

-------------------------------             ==========
|                             |                  /        /
-------------------------------                  /       /
|                           |^|            /        /
|                           | |             ==========
|                           | |
|                           | |
|                           | |
|                           | |
|                           | |
|                           |v|
-------------------------------

i want to place the dialog box modlessly (currently is modal) into the view yet still
maintain scrolling ability. so that it looks like this:

-------------------------------
|                             |
--------------------===========
|                |^|/         /
|                | |/         /
|                | |/         /
|                | |/         /
|                | |/         /
|                | |/         /
|                | |/         /
|                |v|/         /
--------------------===========

Hopefully the whole thing will be able to be resized and maintain its look.  the new button still only clears the viewing area.

Is this possible and if so may i have a very detailed explination.

Thanks in advance me.

0
Comment
Question by:ramsay
  • 6
  • 4
10 Comments
 
LVL 1

Author Comment

by:ramsay
ID: 1322937
my diagrams are screwed...

ignore below (experiment)

|      |      |      |
\       \       \       \
\.......\.......\.......\
0
 
LVL 1

Author Comment

by:ramsay
ID: 1322938
damn thing.. EVER HEARD OF COURIER!

try and decipher the diagrams as best u can
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1322939
Have you considered using CDialogBar?  Since you want to dock the dialog inside of the view, you pretty much have to go that direction anyway.  Once the dialog bar is docked, then the scroll bars will work per normal.

Really take a close look at Stingray's Objective Toolkit.  I know it's a decent chunk of money, but the advantages that you will get are astronomical.  Your dialog bars will have the look and feel of the coolbars, plus you'll get quite a few enhancements throughout the MFC environment.

Phillip
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1322940
p.s.  Your diagrams are fine.  All we have to do is cut and paste into notepad and we can see what you want.

Phillip
0
 
LVL 1

Author Comment

by:ramsay
ID: 1322941
Ok i placed a member variable in the visual test view so that when i double click on the screen it should create the window.
However when i try it nothing happens unless i resize the window.
Even after I resize it ant the box is displayed the box's initialisation is not carried out.
I used the code:

void CSCVisTestView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
   
      m_bar.Create(GetParent(),IDD_TREE,CBRS_LEFT,NULL);
          CScrollView::OnLButtonDblClk(nFlags, point);


}


I am not sure what it means by nID. (that is the parameter i placed NULL in)

THe dialog box i am using is IDD_TREE.

it has two controls in it
IDC_TREE - Tree Control
and
IDC_CHECK1 - check box

I have assigned them variables in the Class wisard

m_tree
m_check1 respectivly.

The first problem is how do i display the box without resising the window? The second is how
do i manipulate the controls within the box? The third is why does it not carry out its initialisation?

Thankx again Mr Ramsay

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 7

Expert Comment

by:psdavis
ID: 1322942
Ramsay,

> The first problem is how do i display the box without resising the window?

The frame should always be the parent of the dialog box, not the view.  You should ALWAYS have the dialog bar created in the frame, then you can hide the dialog when you want to.  Once tied to the frame, then the resizing will automatically take place.

The nID number is a little tricky.  The best thing to do is create yourself an entry in the resource.h file and add a variable somewhere between E800 and E900.  The first few E800-E804 are taken by the CPrintPreviewBar and such, as well as a few from E820-E826.  Add it something like

#define AFX_IDD_TREE E806

Then in your view menu option, you can turn off and on the bar as required.  You'll really will want to find a sample program if you're new to dialog bars.  They have a few 'personality' traits that you'll want to get used to.

> The second is how do i manipulate the controls within the box?
> The third is why does it not carry out its initialisation?

You might want to look out at www.codeguru.com and look for an article that adds DDX and OnInitDialog support to the CDialogBar.  It is invaluable!

I'll be out of town until Friday, I wish you good luck and godspeed with your project.

Phillip

0
 
LVL 1

Author Comment

by:ramsay
ID: 1322943
Ok I got this very effective piece of code from codeguru.com that allows a dockable cdialogbar
but I cannot for the life of me get the dialog to communicate with the view.
The code I used is below:

///THE VIEW
void CSCVisTestView::OnViewTest1() {

    CTestDialog* dlg;
    dlg->test2();
}

This calls
//THE DIALOG

void CTestDialog::test2()
{
    CSCVisTestView* pView;
    pView->ViewTest2();
}

Which calls
//THE VIEW AGAIN
void CSCVisTestView::OnViewTest2() {

      CSCVisTestDoc* pDoc = GetDocument();

}


The code i got from codeguru is in the page a docking_window/devstudio_like_CControlbar_2 it comes with a downloadable
 project file so you can see exactly what i mean.

 The communication screws up because I try to call getdocument() from within the viewtest()
Is there any way around this?


0
 
LVL 1

Author Comment

by:ramsay
ID: 1322944
I need an answer pretty soon
0
 
LVL 7

Accepted Solution

by:
psdavis earned 200 total points
ID: 1322945
// Ahh, good to be back from Florida!  No wait, what am I saying!!!

void CSCVisTestView::OnViewTest1() {

    CTestDialog* dlg;
    dlg->test2();
}

Oops! dlg isn't initialized.  It shouldn't be a null pointer that you're using!

To call the dialog box from the view, try something like...

void CSCVisTestView::OnViewTest1()
{
   CMyChildFrame* pFrame = (CMyChildFrame*) GetParentFrame( );

   if( pFrame->m_wndMyDialogBar )
      pFrame->m_wndMyDialogBar->ViewTest2( );
}

Where CMyChildFrame is the class that you created the dialog bar in.

Now, you can't get the dialog to communicate with the view?  Probably because you're not SUPPOSED to!  I know this might sound strange, but in the doc/view architecture, the view should never be talked to!  Strange concept ain't it?  

The only one who should send messages to the view is the document and that is through the hint mechanism.  It is because there can be many views for the document and many documents to the frame.  The dialog bar should tell the document that data has changed. The document should receive the change and UpdateAllViews with the new information.  Then the views will acknowledge and update their views.

Good luck!
0
 
LVL 1

Author Comment

by:ramsay
ID: 1322946
got it working!
thanx for your time!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sum13 challenge 24 77
lucky13 challenge 11 112
Not needed 13 57
Problem to open Excel file 15 43
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now