Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update listbox from child

Status
Not open for further replies.

suntanme

Programmer
Jul 20, 2002
16
US
Pushing the limits for the beginner... I have a tab control on a dialog box that updates records. After the records are updated, they are displayed in a listbox on the parent. Can anyone suggest how to signal the parent to update this listbox from the child.
 
Hi,

If I have understood, you have a main win with a listbox,

and pressing something, you execute a myDialog.DoModal().

When the control returns in the main win (after DoModal)

you can test the return value of it or a variable of
that class (known by Class of mydialog and the caller )

If the variable is IDOK ( of TRUE ) recall the routine,
in the calling class, you used to fill 1st time the listbox.

The easier mode is to rebuild all listbox; more sophisticated may be the substitution of just modified line.

b y e .
 
My stumbling block is that the dialog is modeless. So after I enter the information and save it to the database, I need to focus on the parent and run the list function.
 
Hi,

reading beginner, I thinked... ,now it is clear !

You have to define a USER message :

#define WM_MYMESSAGE WM_MESSAGE+1

In the class of DialogBox add a pointer to caller view
m_pView, and load it by "this" before launch dialog box.

In the function CMyDialog::OnOK, call

if( m_pView != NULL )
m_pView->PostMessage( WM_MYMESSAGE, IDOK ) ;

Then in the calling message loop add

after BEGIN_MESSAGE_MAP and
before AFX_MSG_MAP

ON_MESSAGE( WM_MYMESSAGE, OnMyRefresh )

define

LRESULT CMyView::OnMyRefresh( WPARAM wParam, LPARAM lParam)
{
...
Reload Listbox

}

In header file of calling View add

afx_msg LRESULT OnMyRefresh(WPARAM,LPARAM)

(before DECLARE_MASSAGE_MAP()
after //}}AFX_MSG
 
Thank you victorv for the direction to go in. I can call the message from within CMyView and it pulls the OnMyRefresh. However, I think I am missing something obvious about the pointer to call it in CMyDialog.

Could you elaborate on this?

In the class of DialogBox add a pointer to caller view
m_pView, and load it by "this" before launch dialog box.

Again, thank you ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top