Doc / View - getting info from dialog

I have a project that is using the MFC Doc / View archetechture.  From the
main menue, on File | New I've added code that starts a dialog:

void CMainFrame::OnFileNew()
{
 m_gridDlg.DoModal();
}

The dialog sets two values, m_GridSizeX and m_GridSizeY in the CGridDlg
class.

I need to use these values in the MyprojView class.  How can I retreive the
values?

I have tried this statement in the MyprojView.cpp file:

 GridSizeX = CGridDlg::m_GridSizeX;

This results in the compile error:  "illegal reference to data member
'CGridDlg::m_GridSizeX' in a static member function"

I have made this function in the CGridDlg.cpp file:

int CGridDlg::GetGridSizeX()
{
 return m_GridSizeX;
}

When I call it from the MyprojView.cpp file like this:

 GridSizeX = CGridDlg::GetGridSizeX();

I get the compile error:  illegal call of non-static member function

Some direction is welcome.
Thanks,
Marge




0
4/22/2004 11:03:36 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
813 Views

Similar Articles

[PageSpeed] 15

"Marge Inoferror" <inevercheckthis2002@yahoo.com> wrote in message
news:cENhc.10717$aW1.8183@newssvr31.news.prodigy.com...
> I have a project that is using the MFC Doc / View archetechture.  From the
> main menue, on File | New I've added code that starts a dialog:
>
>
>  GridSizeX = CGridDlg::m_GridSizeX;
>
> This results in the compile error:  "illegal reference to data member
> 'CGridDlg::m_GridSizeX' in a static member function"
>
> I have made this function in the CGridDlg.cpp file:
>
> int CGridDlg::GetGridSizeX()
> {
>  return m_GridSizeX;
> }
>
> When I call it from the MyprojView.cpp file like this:
>
>  GridSizeX = CGridDlg::GetGridSizeX();
>

You want to call

GridSizeX = CGridDlg.GetGridSizeX();


Using :: does something completely different. Using period '.' calls the
class instance's methods and members, whereelse '::' is base class calls
(and some others).

A


0
4/22/2004 12:06:45 PM
Marge Inoferror wrote:

> I have a project that is using the MFC Doc / View archetechture.  From the
> main menue, on File | New I've added code that starts a dialog:
> 
> void CMainFrame::OnFileNew()
> {
>  m_gridDlg.DoModal();
> }
> 
> The dialog sets two values, m_GridSizeX and m_GridSizeY in the CGridDlg
> class.
> 
> I need to use these values in the MyprojView class.  How can I retreive the
> values?

The error messages mean that you have not learned the difference between 
a class and an object.  Study some C++ :)

You must retrieve the values when DoModal returns.  (Because they are 
destroyed shortly thereafter, when OnFileNew returns.)

if (gridDlg.DoModal() == IDOK)
{  m_GridSizeX = gridDlg.m_GridSizeX;
    m_GridSizeY = gridDlg.m_GridSizeY;
}

If you move the code into the view then you will have the data in the 
view, as desired.  If the code must be in the CMainFrame you can call 
GetActiveView to get a pointer to the view object.  Then copy the dialog 
variables to view variables:

   CMyprojView* pView = (CMyprojView*)GetActiveView();
   pView->m_GridSizeX = gridDlg.m_GridSizeX;

-- 
Scott McPhillips [VC++ MVP]

0
scottmcp8856 (490)
4/22/2004 1:32:08 PM
"Scott McPhillips [MVP]" <scottmcp@mvps.org.nothere> wrote in message
news:uVnZjXGKEHA.892@TK2MSFTNGP09.phx.gbl...
> Marge Inoferror wrote:
>
> > I have a project that is using the MFC Doc / View archetechture.  From
the
> > main menue, on File | New I've added code that starts a dialog:
> >
> > void CMainFrame::OnFileNew()
> > {
> >  m_gridDlg.DoModal();
> > }
> >
> > The dialog sets two values, m_GridSizeX and m_GridSizeY in the CGridDlg
> > class.
> >
> > I need to use these values in the MyprojView class.  How can I retreive
the
> > values?
>
> The error messages mean that you have not learned the difference between
> a class and an object.  Study some C++ :)
>
> You must retrieve the values when DoModal returns.  (Because they are
> destroyed shortly thereafter, when OnFileNew returns.)
>
> if (gridDlg.DoModal() == IDOK)
> {  m_GridSizeX = gridDlg.m_GridSizeX;
>     m_GridSizeY = gridDlg.m_GridSizeY;
> }
>
> If you move the code into the view then you will have the data in the
> view, as desired.  If the code must be in the CMainFrame you can call
> GetActiveView to get a pointer to the view object.  Then copy the dialog
> variables to view variables:
>
>    CMyprojView* pView = (CMyprojView*)GetActiveView();
>    pView->m_GridSizeX = gridDlg.m_GridSizeX;
>
> -- 
> Scott McPhillips [VC++ MVP]
>

Thank you very much, Scott.  Yes, I am trying hard to understand C++, you
are correct in what the error messages mean. :)

If I may post a follow up...

I did not realize that I could move the code into the view module.  I was
able to get rid of the compile errors by doing so.  Thanks for pointing that
out to me.

I have added the code as you describe (as follows) in the View module.

 if (m_gridDlg.DoModal() == IDOK)
 {
   m_GridSizeX = m_gridDlg.m_GridSizeX;
   m_GridSizeY = m_gridDlg.m_GridSizeY;
 }

The dialog uses radio buttons that, when selected, set the values of
m_GridSizeX and m_GridSizeY.  When I debug and step trhough the dialog code,
it is
setting the values correctly, for example, m_GridSizeX = 6, m_GridSizeY = 4.

However, when I step through the lines of the code in the View module, the
wrong values are there, for example, m_GridSizeX = 8, m_GridSizeY = 4.

I'm looking for problems and trying to debug, but I thought I would also
defer to the expertise here and ask for any direction that someone might be
willing to impart.

Thanks,
Marge






0
4/22/2004 5:56:12 PM
"Marge Inoferror" <inevercheckthis2002@yahoo.com> wrote in message
news:0HThc.739$Pk3.178@newssvr15.news.prodigy.com...
>
> "Scott McPhillips [MVP]" <scottmcp@mvps.org.nothere> wrote in message
> news:uVnZjXGKEHA.892@TK2MSFTNGP09.phx.gbl...
> > Marge Inoferror wrote:
> >
> > > I have a project that is using the MFC Doc / View archetechture.  From
> the
> > > main menue, on File | New I've added code that starts a dialog:
> > >
> > > void CMainFrame::OnFileNew()
> > > {
> > >  m_gridDlg.DoModal();
> > > }
> > >
> > > The dialog sets two values, m_GridSizeX and m_GridSizeY in the
CGridDlg
> > > class.
> > >
> > > I need to use these values in the MyprojView class.  How can I
retreive
> the
> > > values?
> >
> > The error messages mean that you have not learned the difference between
> > a class and an object.  Study some C++ :)
> >
> > You must retrieve the values when DoModal returns.  (Because they are
> > destroyed shortly thereafter, when OnFileNew returns.)
> >
> > if (gridDlg.DoModal() == IDOK)
> > {  m_GridSizeX = gridDlg.m_GridSizeX;
> >     m_GridSizeY = gridDlg.m_GridSizeY;
> > }
> >
> > If you move the code into the view then you will have the data in the
> > view, as desired.  If the code must be in the CMainFrame you can call
> > GetActiveView to get a pointer to the view object.  Then copy the dialog
> > variables to view variables:
> >
> >    CMyprojView* pView = (CMyprojView*)GetActiveView();
> >    pView->m_GridSizeX = gridDlg.m_GridSizeX;
> >
> > -- 
> > Scott McPhillips [VC++ MVP]
> >
>
> Thank you very much, Scott.  Yes, I am trying hard to understand C++, you
> are correct in what the error messages mean. :)
>
> If I may post a follow up...
>
> I did not realize that I could move the code into the view module.  I was
> able to get rid of the compile errors by doing so.  Thanks for pointing
that
> out to me.
>
> I have added the code as you describe (as follows) in the View module.
>
>  if (m_gridDlg.DoModal() == IDOK)
>  {
>    m_GridSizeX = m_gridDlg.m_GridSizeX;
>    m_GridSizeY = m_gridDlg.m_GridSizeY;
>  }
>
> The dialog uses radio buttons that, when selected, set the values of
> m_GridSizeX and m_GridSizeY.  When I debug and step trhough the dialog
code,
> it is
> setting the values correctly, for example, m_GridSizeX = 6, m_GridSizeY =
4.
>
> However, when I step through the lines of the code in the View module, the
> wrong values are there, for example, m_GridSizeX = 8, m_GridSizeY = 4.
>
> I'm looking for problems and trying to debug, but I thought I would also
> defer to the expertise here and ask for any direction that someone might
be
> willing to impart.
>
> Thanks,
> Marge
>
>

I found the problem.

It was that I had associated one of the variables with one of the radio
buttons in Class Wizard.  It wasn't clear to me where in the header file to
put the member variables.  I created the first variable in Class Wizard, I
guess that is problematic.

 Thanks for listening.

Marge




0
4/22/2004 6:18:56 PM
Marge Inoferror wrote:
> I found the problem.
> ...
> ...
>  Thanks for listening.
> 
> Marge

:)

-- 
Scott McPhillips [VC++ MVP]

0
scottmcp8856 (490)
4/23/2004 12:08:11 AM
Reply:

Similar Artilces:

Link to a doc
I want to be able to have a document link to a contact. Every contact has an excel file that is saved on another server that contains there marks and I want to be able to attach the document. This would eliminate a step for my users. I also need to be able to open the document, post a mark and then be able to save and overwrite the original. Is this possible..... ...

Outlook views #7
Dear All, Sorry if this is a repeat...I can't find my message. If I am viewing email in all messages view. I selected one in which I was interested and then changed to conversation view in the hope that the selected email and associated emails would be highlighted. Alas no. Is there a way of doing this or of searching the conversations? I know I can search using find or advanced find but this does not group the results by conversation. Thanks, Danny ...

continious page nos while inserting pages from 2nd doc to 1st doc
i have 3 pages template in 2nd page from macro i am inserting file doc2 where bookmarks are there for i=0 to 2 Selection.GoTo What:=wdGoToSection, Which:=wdGoToLast Selection.MoveUp Unit:=wdLine, Count:=1 Selection.InsertBreak Type:=wdSectionBreakContinuous Selection.InsertFile Filename:=mstrTemplatePath, Range:="mtaLoop", ConfirmConversions:=False, Link:=False, Attachment:=False For Each frmfld In ActiveDocument.FormFields Select Case frmfld.Name Case "mta070" ...

Viewing different worksheets at the same time?
I was just wondering if it's at all possible to view different worksheets from one workbook at the same time. I got to thinking about this because you can split the view so that you can view different parts of one worksheet at the same time (dragging that little bar at the end of the scroll-bars). I'm currently having to create a load of links between two sheets withing a workbook and it would be so much easier if you could have both sheets on display at once. So, is this possible? Cheers, Rob -- Rob_T ------------------------------------------------------------------------ Rob_...

html docs to publisher docs
I have managed to delete the publisher file, but have the index and index_files. Is there a way I can reverse engineer these html files to the original publisher file? At the end of this article you will find a way to reconstruct your Publisher file from your web files: Common Sense Computing 101 aka "Why in the world would you lose your publisher file?" : http://msmvps.com/blogs/dbartosik/archive/2006/01/19/81461.aspx In the future, please post your web related questions in the web group and we will try to help you there: microsoft.public.publisher.webdesign DavidF "w...

problems with hyperlinks to Xcel docs
I've gad sp2 installed recently and discovered that since: 1 - Hyperlinks to other Excel workbooks do not work, 2 - links to other office docs do work. I tried different method: Shift-Click or Ctrl-CLick but not luck so far. Any idea? Many TIA Joseph ...

Exported PST issues
I have been trying to import an 'exported pst' using the export function (not copying the pst as I did not know that should be the way to back them up). I have been getting the 'not personal folders file' message regardless of all the help I have been getting from this newsgroup (thank you all). This includes the repair tool, using file open, using file import pst, etc... All into either Outlook 2002 and 2003. I went back through my years of exported .pst's and found that my oldest version (the client was probably Office 2002 (XP) or earlier), which is not muc...

doc size limitations
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: Power PC why are doc sizes limited to printer settings? i like to do floor plans and can never do an entire floor, just room by room. if i shrink things to 1/4 of the original dimensions, zooming in just makes things less sharp. is there any way to enlarge my doc size that i'm not seeing and save it as a custom setting? <br><br>e.g., i want to do six rooms, including bath, in a 32'X28' area. i can work with these dimensions with in a 1:12 ratio, but i can't customize the paper size to, say, 35...

viewing page spreads
Creating a newsletter. Currently I can only view pages in two page spreads. Is there any way to view a full spread of multiple page newsletters? Rachel After managing to set up OE-QuoteFix on his new PC, Ed reads a message from Rachel <anonymous@discussions.microsoft.com>... > Creating a newsletter. Currently I can only view pages > in two page spreads. Is there any way to view a full > spread of multiple page newsletters? In Publisher 2002 and 2003 you can use the Print Preview to accompish this. -- Ed Bennett - MVP Microsoft Publisher http://www.mvps.org/the_nerd/ B...

Making a clean view
I just wrote a simple program and I would like to make it look clean an simple by removing all of the unecessary items from the menu. And b limiting the viewing area. There is a plug-in called Mortgage Genie o a website called moneycops.com. The program is free and it's a perfec example of what I want mine to look like. Can anyone help me out here -- Jua ----------------------------------------------------------------------- Juan's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=688 View this thread: http://www.excelforum.com/showthread.php?threadid=26353 ...

insert pub doc into pub doc- how?
Person sent me publisher document with page 3 & 4 blank. Then sent me pages 3 & 4 publisher document. I want to put pages 3 & 4 into the first publisher document. I have tried copy and paste but the copy does not copy whole page--maybe I have to do Group? Just got one box. File import said something about Word document-did not help! Thanks for suggestions! Susan Try Edit|Select All and then copy and paste. -- JoAnn Paules MVP Microsoft [Publisher] "Susan" <dsnsacree@msn.com> wrote in message news:OkfdhzK3EHA.4092@TK2MSFTNGP14.phx.gbl... > Person ...

Excel 200 viewing option
I have win NT and office 2000. When I open multiple WORD documents, I get multiple buttons on my task bar for easier editing. But when I open multiple excel files, I get only one. How can I set it up like word? Thanks Tools / Options / View / Windows in Taskbar -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL2K & XLXP ---------------------------------------------------------------------------- Attitude - A little thing that makes a BIG difference --------------------------------------------------------------...

Doc/View question
I have reached a point where I need input on the following: For some time I have used MFC created apps with Doc/View and made my base view class as CFormView. It was convenient and quick, but I was putting all of my data variables in the ViewClass since that was where the class wizard put all my control variables and it seemed convenient in my ignorance. If I had to access files I used ofstream from within my view class. So now it has become apparent that I have things backwards (so it appears from what I read ) in that I should have been creating data variables in the CDocument...

Newbie Question
Is there a way to create an Excel database to input information and then pull info into a form? We need to have 3 diferent forms that info could be pulled from a database so that the forms don't need to be handwritten or typed each time. I'm willing to do the research needed to do this if it is possible. Info would change, and not all fields would be pulled into each form. I hope this makes some sense. Thanks. Set up your database in columnar format so's you can use VLOOKUP formulas in your 3 forms to pull data based upon criteria. Good place to start for info is ...

Not in Recent Docs #2
W2K Why dont my Visio 2000 docs appear in Recent Docs? ...

data type for a photograph in design view
I want to add a photograph of items to my table in design view. I do not know what to enter as the data type to be able to add photos. Where do I begin? And what are the next steps? ...

View by Sender #2
Hello, Hope anyone can help me on this. At one of my corporate email client's outlook (2000) I set the inbox view by sender. Everything was work fine, means I can view the messages by sender. But oneday, exactly last 23rd December, the messages from some people (or most of the people from the organization)shown under "NONE" in the from field!. A lot of messages sorted under this none tree while before I was received these peoples' mails under their own names in the 'by sender' view. I tried a lot but I cant sort these mails under their own name. I checked th...

How do I keep the EULA from popping up every time I open a doc?
A box saying I must Accept or Decline the Microsoft End User License Agreement (EULA) pops up every time I open a Microsoft document. I ACCEPT it every time, I've printed it, but it STILL keeps popping up. It's annoying as heck. Is there some way to make it go away for good? I understand the terms already! Sheesh! "License Agreement Popup Question" <License Agreement Popup Question@discussions.microsoft.com> wrote in message news:58CF6A60-6010-471B-A2CC-A9730A9D6E31@microsoft.com... > A box saying I must Accept or Decline the Microsoft End Use...

XL2000 "Custon Views" "Column width" Problem
Although the help file states that custom views will change colum widths, it does not. I have seen a few postings stating the sam problem but no solutions. Does anyone know if there is a fix for this? If not, is it possible to use Autofit just for a range in a column not for the whole column? De -- De ----------------------------------------------------------------------- Des's Profile: http://www.msusenet.com/member.php?userid=69 View this thread: http://www.msusenet.com/t-187096409 Instead of using custom views, could you just record some macros that set the columnwidths the way yo...

Creating modal/modeless dialog from other thread
Hi, I read a lot about the problem creating dialogs out of different threads but until today I can't find a solution by myself. Within my application there are two threads running. One thread is responsible for the main-window, the second for the application logic (I need both). Now I try to open a dialog out of the second thread (a confirmation dialog with edit-possibility). If I create a modal dialog my software crashes by calling dialog.DoModal if I create a modeless dialog the dialog is not visible. What can I do?? Does anybody had the same problem?? Thanks a lot, Terrie After you ...

cannot view objects
Since 01/07/2005 I can't view objects in MS Publisher 2003. I could prior to that. I haven't done any OS updates. Help! Have you tried View, pictures, detailed display... -- Mary Sauer MS MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Jay in Colorado" <Jay in Colorado@discussions.microsoft.com> wrote in message news:30D92C79-48ED-4CF3-8FF6-51AC155C86ED@microsoft.com... > Since 01/07/2005 I can't view objects in MS Publisher 2003. I could prior to > that. I haven't done any OS updates. Help! Yes, thanks but it...

Click on Excel Doc Starts Excel but Excel does not Open the Doc.
Hi When I click on an Excel doc., Excel starts up but does not open the doc. When I rgiht click an .xls and then choose Excel to open it it says that Excel cannot find the document on the indicated path. The path shown is indeed the path to the doc and the doc is there. When I drag an .xls into a runing Excel it opens correctly. Other apps. such as Word open the docs correctly but cannot open docs with links to Excel sheets. Any ideas? Regards, Marc Try looking at this: Tools | Options | General Uncheck "Ignore other applications" HTH hi. try this. Tools>options>g...

print view & print, in excel, different size cells
When I print (or view preview print) sometimes information that is in a cell is cut off, or extended. While I am working on the page I formate the cell how I want it, like say I have the word "Coummunity" in the First cell and have it formated to center or wrap or shrink to fit..... I stretch the cell so the whole word will fit, but when I print it, it might have Coummuni on one line and ty wrapped. Or if I have two or three words in a cell that is formated to wrap and while I am looking at it all three words are stacked, the way I want them, say on three lines, but when it...

How to re-enable the "source path mapping" dialog
I am using VS2005 + CE 6.0 R2. When I use KITL to debug a program, a pop-up dialog show up, wants me to give the "source path mapping". But once the check the "don't show up" option on that pop-up dialog, it never shows that dialog when I run a program. How to re-enable the auto pop-up dialog when VS2005 CE 6 find no proper source path ? Thanks C Hecko Check out in the following 'Options' dialog box of VS2005 Tools--> Options-->Platform Builder for CE-->System Debugger -- Regards, Prabu http://prabukumar.wordpress.com/ ...

Microsoft Outlook 2000 Not sending .doc files to some people
I can send .doc files only to some people, this just happened today out of the blue. Some people get the files fine and others do not. I am NOT running MS exchange, we are directly connected to the Internet. We are running Windows 2000 sp4 etc. We are running AVG virus program, shouldn't have any interference with E-mail issues, Any Ideas? Thanks, Steve ...