Cview class calling Function in Dlg.

Posted on 2000-04-20
Medium Priority
Last Modified: 2013-11-20
in my CScrollView i need to display back the old values to the dialog box. so if the g_bTestFeed is checked, it will call a function in the dialog class. however, problem aries as the m_WithLoad is pointed to null as i step through the program.

void CHpisView::PreviewCancel()
    CCancelBtn dlg;
    if (pTempCancel->g_bTestFeed)
//if the above 2 lines are commented no problem aries
    if (dlg.DoModal() == IDOK)


void CCancelBtn::OnTestFeed()
bTestFlag = !bTestFlag;
m_WithLoad.EnableWindow(bTestFlag); //m_WithLoad pointed to NULL

i discovered that if the function is not called, no problem aries, m_WithLoad is not pointed to null . so what should be the correct method or function to be included to solve this problem.
Question by:nasty101

Expert Comment

ID: 2733860
What is m_WithLoad? How do you initialize it?
LVL 31

Accepted Solution

Zoppo earned 120 total points
ID: 2733932
Hi nasty101,

you cannot use control attached members of a dialog like this before the dialog is create (which is done by DoModal()), because the control which is represantated by m_WithLoad simply isn't created yet. You'll have to implement a flag as member of the dialog, set this to TRUE of FALSE in PreviewCancel() before DoModal() and call the m_WithLoad.EnableWindow() with this flag in CCancelBtn::OnInitDialog().

hope that helps,


Author Comment

ID: 2742598
thx. your solution is greatly appreciated.

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.

624 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