Solved

Multiple views in one child frame

Posted on 2001-07-19
17
388 Views
Last Modified: 2013-11-20
I'm just starting this project and I'm trying to figure out how to approach it.  I want an MDI, doc/view app with multiple edit views (or textboxes) within the child frame.  In other words, it will work like MSWord but instead of one text field to work with I want the user to have a few different boxes to type into that stretch horizontally across the screen.  Then he or she can add or delete boxes or drag and drop to reorder the boxes of text.  I have the basic app built with the main frame and child frame, etc.  The view within the child frame is a single ceditview.  How can I create an app where there are several ceditviews within that one child frame (with different text, ie not different views of the same document)?  Any help/direction will be greatly appreciated.  Thanks.
0
Comment
Question by:jjjkkklll
  • 7
  • 6
  • 4
17 Comments
 
LVL 30

Expert Comment

by:Zoppo
ID: 6301657
Hi jjjkkklll,

That may be a difficult problem. First some questions:
1. If you say the editboxes should contain different texts where/how do you want to manage/hold
these texts? In the document or in the view. What behavior do you need if multiple views are opened
for a document? Should they show exactly the same (texts and editboxes) or different?
2. Do you want the textboxes to appear like (a) splitter panes or (b) more like windows as i.e. one can
see the tables in MS Access?

Maybe a) can be done using encapsulated splitters, b) could be done in generic CView and windows
with caption and edit box as childs of the view.

ZOPPO
0
 

Author Comment

by:jjjkkklll
ID: 6302557
Zoppo, thanks for your response.

The text could be managed by the view or even remain in the edit controls until it's time to save them.  In which case, I'll grab the contents and throw them to the document to save.  And each box would hold different text.  Basically, think of a screen full of index cards.  The user can put different text on each one and move them around by dragging and dropping.  If I use edit controls as children of the view, I'm not sure how to encapulate the controls to make them draggable and droppable.  Maybe edit controls isn't the best way to go.  I'm still designing and want to know the best way to approach such a program.  Thanks.
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6303045
Hi jjjkkklll,

dragging arounf child window's of a view is no problem ... if I had time I could do it right now, but I'm
already 1.5 hours to late for going home and won't be here before monday.

But, as told, moveing windows around within a view (as i.e. in MS Access) is not difficult.

You can try it yourself somehow like this (that's how I would start the attempt):

- create a new MDI project without changing anything in AppWizard from defaults
- create a dialog resource with WS_OVERLAPPED and WS_CAPTION containing the edit-control
- derive a class from CDialog for the resource, i.e. CTestDlg
- add OnInitialUpdate for the view class with ClassWizard and implement it like this:
#include "TestDlg.h"

void CTViewView::OnInitialUpdate()
{
 CView::OnInitialUpdate();

 CTestDlg* pWnd;

 for ( int i = 0; i < 3; i++ )
 {
  pWnd = new CTestDlg( this );
  pWnd->Create( CTestDlg::IDD, this );
  pWnd->ShowWindow( SW_SHOW );
  pWnd->SetParent( this );
 }
}

you'll get 3 overlapping dialogs which you can move within the view and are moved with the chile- and mainframe.

Only problem I found til now is if you minimize the app I can't restore it from task bar, but I'll see
to find solution for this monday...

ZOPPO
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6303047
PS: to use WS_CAPTION and WS_OVERLAPPED first select type 'Popup' in dialog's properties, then check
'Caption' and then switch type to 'Overlapped'...
0
 

Author Comment

by:jjjkkklll
ID: 6303108
Thanks Zoppo.  I'll give it a try and I look forward to communicating with you Monday.
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 6306495
Hi jjjkkklll

Sounds preety interesting problem. I do have few simple questions, First, is there a reason to insist on single child frame
particularly when you are creating mdi app. Although you can always create splitters (static or dynamic) but I somehow
feel that is not what you have in mind. Keeping data separate for each view is easier than it is sounds. Just Ensure that
you create separate CDocument derived objects. for each view.
 i.e. follow "1 view object corresponds to 1 document object " model. Note that most of the coding needed is beyond
reigns of class wizard.

0
 

Author Comment

by:jjjkkklll
ID: 6306975
SamratAshok,
I've been playing around with Zoppo's idea of using dialog boxes within the child frame and it works okay.  They don't quite have the behavior I'm looking for, however.  What I'm looking for can be thought of as "strips of paper" down the screen.  Each contains different text as the user types it in.  I'd like to be able to drag and drop each "slip" to change the order but have them snap so they don't overlap each other.  Almost like in Word if you had several words down the page and you drag and drop a word to change the order, the one you dropped it on would shift lower on the list.  

Also, I'd like the box to expand as the user types in the text.  In other words, it starts as one empty line, but if they type more than that, the box gets bigger (as opposed to a scroll bar).  I'm not sure how to get this effect.  

Seems I have to contain the edit control within something like a dialog box, but the dialog box theory is somewhat limiting (like how do I get the expanding box instead of scroll bars and how do I drag and drop without the big, ugly title bar on top of each box?).  

Regarding multiple document instances, it seems to me, if I use edit controls, I can just keep using one document if I tie different variables to each box of text - the text would be held in the control or at least in the view until I need to save it.  I'm more concerned right now with getting the behavior out of the "slips of paper" on the screen.  Thanks for your help.
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 6308339

Hmmmm Jjjkkklll

Take a look if you can at Microsoft Outlook "Notes" Page. They have designed it as a computer
version of Yellow sticky notes. Although they don't stack it up as a cascading windows, instead
they choose to leave it minimized over the main frame window and it does not have concept
of order of notes.

What I think you need is a combination class of "CDialog and CEditView , CFrameWnd and
derived from CWnd.  Each of this window in turn should become MDI child of your Main frame.
Handle all events in it and can easily support drag drop. In other words, you write custom
View architecture. Also where is data coming from? Does it get saved in one file or separate files?

Does application contain any other views requirements?

Growing the Window  with text is easy but slightly tricky. To have flicker free performance, I think
you will need to figure out  number of lines you can accomodate at any time and grow only when
text exceeds the main. Eventually, each of this window will contain either a embedded edit box
or if you prefer, you can implement edit handling yourself as well.

Take a look at OLD SDK way of creating MDI applications. If you have not worked on raw SDK
before, Welcome to Jurassic Park!

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:jjjkkklll
ID: 6309396
That's two experts suggesting I use CDialog with an edit control placed on it.  I'm working on getting the behavior I want by handling the behaviors of the dialog boxes.  Something down deep tells me there's got to be another way, possibly by creating and managing rectangles or even tables within CEditView -- a little like Excel where you can have different text within each cell and drag and drop each cell to change the order.  I'm already working on the dialog theory but I'd love some input regarding the tables/cell theory.
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 6309501
Actually I don't recommend CDialog per se.

What I meant to says is that some of the features you need  a cross of few MFC classes including
CDialog.

I think your idea of excel spread sheet has merit if place where you store and/or retrieve data is
single or atleast limited to few and maybe how big data in each window can actually grow.

If you start with CEditView, you options are preety much diminished,
instead you can start with CView or CScrollView and then deal with directly drawing to DC.

0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6311728
Hi jjjkkklll,

I just suggested to use dialogs coz I think you need to have an area in which the user can click to
draw the edit-control ... therefor I thought dialogs are good coz they have a caption and you don't
have to do any work for moving them around.

Of course I think you can use edit controls without a dialog directly as childs of the view and
use a CRectTracker to draw a frame around the active edit control which can be used to
move/resize it. It's just a little bit more work to do.

ZOPPO
0
 

Author Comment

by:jjjkkklll
ID: 6315600
Zoppo,

Yeah, the CRectTracker idea may be the way to go.  I'm not sure I'll need the OLE container if I'm just dealing with text and I'm not concerned with being able to drag and drop that text into other apps (I'm only concerned with moving the rectangles).  I've abandoned the dialog theory for this rectangle idea.  Specifically how to handle the rectangles will be subjects of other questions.  But I just want to make sure this is still the best option before moving on, if any other experts wants to chime in.  Thanks.
0
 
LVL 30

Accepted Solution

by:
Zoppo earned 100 total points
ID: 6316228
Well, the other possibility I see may be to not use windows at all (except for entering text into active
text area) ... just create some new class which has a rect-member to store position/size and a string
member to store the text and create an array or a list of these objects in the view class. Whenever you
click in the view check if mouse click occured in one of these object's rectangle, and if so create a edit
control at runtime at the position of the object and put a CRectTracker around it to give ability to
move/re-size it (just as i.e. is done in a list control with editable items).

With this maybe you save a lot of work implementing printing and you don't have a lot of additional work,
but you'll have to do the drawing of the text-areas yourself in view's OnDraw and to manage the active-state
object with all aspects of capture, (frame- and view-) activation and focus (which even isn't too hard).

That CRectTracker stuff isn't very difficult ... even that drag&drop to/from other apps isn't to hard (you don't
need OLE server/container stuff, just need to derive classes from COleDropSource and COleDropTarget
and override their implementation of OnDragEnter, OnDragLeave, OnDrop a.s.o).

ZOPPO
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6316232
sorry, forgot to mention COleDataSource with drag&drop...
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 6317304
Hi !

I think CRectTracker are good for focussing purposes and to communicate with user, but I think
you should store regular CRect in memory to keep track of "which cell is where".

Best  way I can think of would be to retain2 synchronous arrays  (can use CArray template)
Each cell of first array will hold text that you want to draw in memory. Index of array
determines its sequence of text on the window.

Second array would keep track of rectangles in which you are to draw each text.  

When you drag and drop elements, say you dropped element from 1st to 5th. you simply
swap corresponding array pointers. All it would takes is swap of 2 pointers.

By separating rectangle to data. you rarely need to change the rectangle postion.

This may probably also turn out to be good example where you can optimize drawing to small
section of window instead of the entire client area.


0
 

Author Comment

by:jjjkkklll
ID: 6325530
Hey, thanks Zoppo and SamratAshok.  I've been sidetracked on another project, but the suggestions were great.  I'm giving the point to Zoppo because the CRectTracker suggestion was the angle I was looking for.  I'm sure I'll have a million more questions when I turn my attention back in a week or so.  Thanks.
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6325778
you're welcome...

have a nice day,

regards,

ZOPPO
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
VBA "SendKeys" Syntax for Multiple Keystrokes 7 98
has22 challenge 11 72
has77  challenge 9 68
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

12 Experts available now in Live!

Get 1:1 Help Now