Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MFC and SDI with TREEVIEW and FORMVIEW

Posted on 1998-05-17
3
Medium Priority
?
1,383 Views
Last Modified: 2013-11-20
I am using an SDI with a two pane splitter.  The left pane is a treeview and the right pane is a form view.  I have a CRecordset derived class to populate the tree and the form.  Currently, I am populating the tree in the application's view class using OnInitialUpdate function.  

How can I populate and synchronize the data in the formview (or should it be recordview?) with the selected tree item?
Should I be using a global pointer for the Recordset and if so how and where should I implement it?

I am using ODBC on a remote UNIX database.

TIA

Pat...
0
Comment
Question by:patrickm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 300 total points
ID: 1311698
You would probably want the treeview to send a message to the CFormView to tell it that a new selection has taken place. The method I will be describing is for the more generic case.

Define the structure for the memory that will be shared between the view (in this case, it can be a simple as an HTREEITEM or the data pointed to by HTREEITEM (such as the text) or both).

  struct XferData
  {
    HTREEITEM m_TreeItem;
    TCHAR m_Buffer[2048];
  };

Create a global variable of this type.

  XferData g_XferData;

In your tree's selected item member function, populate the g_Xferdata and use

  GetDocument()->UpdateAllViews(this, hint_XferData, (CObject*)&g_XferData);

to send the hint_XferData message to all the views. Not all of the views care about this message, so modify the CFormView's OnUpdate to know about this message:

  void CMyFormView::OnUpdate(CView* sender, LPARAM hint, CObject* obj)
  {
    if (hint == hint_XferData)
    {
      XferData* xferData = (XferData*)obj;
      // use xferData to display the correct record
    }
    else
      CFormView::OnUpdate(sender, hint, obj);
  }

hint_XferData is a number that you defined that is larger than 100 and must be unique to your document/view hint ids.
0
 

Expert Comment

by:cmliu
ID: 1311699
Check the MFC samples DaoView, use document to store data and synchronize the two views. (it needn't be recordview). Use CDocument 's UpdateAllViews to update all views, use invalidate to only update one view. It is better to store the right view pointer to access it more easily.
0
 

Author Comment

by:patrickm
ID: 1311700
Thank you Thui, but I am weak on MSVC and its Appwizard gen'd classes.  Where is the appropriate place to put these globals and what about a globally defined recordset pointer.  I have pointers to the two view classes defined in the document class (m_pTreeView, m_pFormView). It appeared that they might be useful, but how do I use them?

BTW could you explain 'hint' a little further.

TIA
Pat...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

609 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