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

x
?
Solved

Updating controls on a CFormView

Posted on 2000-03-23
12
Medium Priority
?
251 Views
Last Modified: 2013-11-20
I have an app that is based on Doc/View, and also several other classes namely, CBugsWorld, CBug and CGrid.  I also have two views, the main view (CView) created by MFC and another view CInfoView (VformView). In the document header I have a public variable  CBugsWorld Bugworld.

In CView OnTimer I call a method of the CBugsWorld class through the document  ie.

CDocument* pDoc = GetDocument();
pDC->Bugworld.method(blah blah);

When some variables in the CBugsWorld class or any class it includes change, I would like to update some labels in the CInfoView view.

When I tried to add member variables for the labels to CInfoView throuogh ClassWizard, it does not list the Labels in the Member variables pane.

I know this can be done manually and it is not the main concern.  The main concern is that I don't know how the Doc/View interacts.

I would like someone to give instructions of the steps I need to perform in order to update controls (of whathever kind) in the CInfoView as well some dialogs I have.  I simply don't understand the theory of the Doc/View and seems complex.

I can handle dialogs, classes etc except the doc/view paradigm

Thanks.
0
Comment
Question by:gbzhhu
[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
  • 3
  • 2
  • +3
12 Comments
 
LVL 5

Expert Comment

by:vachooho
ID: 2651571
call UpdateAllViews() from inside document to update all attached views

or use directly
YourViewClass->Invalidate();
YourViewClass->UPdateWindow();
0
 
LVL 5

Expert Comment

by:vachooho
ID: 2651576
doc/view archuitecture is very simple
documnet contains all data you need and handle its serialization.

View responsible for data viewing.
It contains member function GetDocument() which return attached to view document's pointer.
View must get data from document and show it in the window.
0
 
LVL 30

Expert Comment

by:Axter
ID: 2652008
What types of controls are you trying to update?
When you say it does not list the labels in the Members variable pane, do you mean it doesn't list the "Control ID's" or do you mean it doesn't list a variable member associated with the Control ID's?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Author Comment

by:gbzhhu
ID: 2652430
Axter

It does not list the Cotrol ID's so I cannot associate a member variable with them.

As for vachooho,

>>call UpdateAllViews() from inside document to update all attached views

when does the document know that its data is has changed.  Do I use SetModifiedFlags fucntion everytime a variable changes value.  My classes cannot do that since they do not know about the document.

What should I do?

Thanks
0
 
LVL 12

Expert Comment

by:migel
ID: 2652715
Hi!
You can use this;
CDocument* pDoc = GetDocument();
pDC->Bugworld.method(blah blah);
pDoc->UpdateAllViews(this);
0
 
LVL 3

Expert Comment

by:ghimireniraj
ID: 2653631
gbzhhu ,

Did you try migel idea?
It should work.
If it doesn't that means your CInfoView
doesnot yet correspond to your Document
Class.

Add to your CInfoView class header

#include " you docfile.h"

public:
CTesttestDoc* GetDocument();


IN your CInfoView implementation cpp

add method

CTesttestDoc* CInfoView::GetDocument() //
{
      ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CYourDoc)));
      return (CYourDoc*)m_pDocument;
}

Then, wher ever you use

CDocument* pDoc = GetDocument();
pDC->Bugworld.method(blah blah);

Your doc data is changed
-------------------------
 then call

pDoc->UpdateAllViews(this);

must work

niraj










0
 
LVL 4

Expert Comment

by:pagladasu
ID: 2653989
>It does not list the Cotrol ID's so I cannot associate a member variable with them.
I think you are using Static controls as referred by you as labels. Change the Control IDs of each from the default IDC_STATIC to something like IDC_STATIC1 and IDC_STATIC2. That would make them visible to ClassWizard.
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 2655860
No, I am not using static controls.  My controls have proper names.  class wizrad cannot still see them somehow!!

I have now implemented the control updating problem and that is half my problem fixed.  The points (100) for this will go to vachooho (first to point me to the right direction).  Since I have partly solved the problem (manually inserting everything without classwizard) I will ask an easy (I hope for you) for the rest of the points (100)

Ok.  When my app starts, it starts with an initial doc.  I don't know if this window is the child frame or the main frame.  But I would like to (the intial doc and all docs afterwards) to open as maximised so they fill the MDI client area.

Thanks
0
 
LVL 3

Expert Comment

by:ghimireniraj
ID: 2656786
Override the create  function for the CMDChildFrame derived class.

set the style   dwstyle====>as you like
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 2657208
ghimireniraj,

I tried your suggestion and it does not work for me.  I also tried to override PreCreate function and change dwstyle and that does  not work for me.
0
 
LVL 5

Accepted Solution

by:
vachooho earned 800 total points
ID: 2657291
MDIMaximize(MDIGetActive());
 on CMainWnd;
0
 
LVL 12

Expert Comment

by:migel
ID: 2657809
Hi!
Override the create  function for the CMDChildFrame derived class.
set the
cs.style |= WS_VISIBLE|WS_MAXIMIZE;
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

618 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