On 1 Aug 2006 07:34:24 -0700, PloutzMR@Npt.NUWC.Navy.Mil wrote:
I am a new poster here, so I hope this is the correct group to put this
in...
I am a beginner to VC++, and I'm trying to accomplish something that
seems like it should be simple. I have a main frame that I've added a
child dialog to, called TabCtrlHolder, which acts as a holder for the
various pages in my tab control.
I then have 6 pages that I can switch through with tab control. On one
of these pages, I have a listbox that I need to add data to every time
an event occurs. But I can't seem to access the listbox! I've tried
the following:
classWithListBox cwlb;
mainFrm: mainFrm()
{
}
void mainFrm::OnClientStatus(DWORD status)
{
CString msg;
msg.Format("{%02d:%02d:%02d} Connection
Established",theTime.GetHour(),
theTime.GetMinute(),theTime.GetSecond());
// add the string to the listbox
vc.m_clientLB.AddString(msg);
}
and I get an assertion error:
ASSERT(::IsWindow(m_hWnd));
I assume that the problem I'm having is that cwlb is not actually
assigned to any real object yet...which may make this more of a
fundamental C++ question than an MFC question. But how would I get the
main frame to recognize that I am trying to access the members of my
tab control, of which there are no references within the actual main
frame class?
I appreciate the help and apologize for my ignorance.
-Matt
Joseph M. Newcomer wrote:
The simplest method is to SendMessageToDescedants using a user-defined message and have
your dialog page that has the control respond to it by adding the value to the listbox.
You should not be accessing members of other classes from the frame class.
If you have the CWnd/CWnd* reference to the page of the tab control, you can SendMessage
to the window itself.
Since you haven't said when and where you call these, you can't call them until the page
is created. So you have to make sure the dialog with the tab control eactually exists.
joe
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
frame class, which takes place after creation. I performed an
TabCtrlHolder.