Click to See Complete Forum and Search --> : PLEASE HELP ! How to: Passing info from modal dialog to parent COM object?


August 30th, 1999, 07:49 AM
I have a number of interfaces defined in the following classs. One of the interfaces launches a modal dialog. From within the modal dialog I wish to inform the CSubFacility object in order to fire an event.

class ATL_NO_VTABLE CSubFacility :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CSubFacility, &CLSID_SubFacility>,
public IConnectionPointContainerImpl<CSubFacility>,
public IDispatchImpl<ISubFacility, &IID_ISubFacility, &LIBID_FINDLib>,
public CProxy_ISubFacilityEvents< CSubFacility >,

What is the best way to notify the CSubFacility object from within the modal dialog that something has occured. I have tried using the 'this' pointer as an argument in the creation of the modal dialog. The problem I am having with this method is during compilation I get errors associated with the CProxy_ for my connection point objects due to the reference of COM object's include file from within the MyDlg source file.

#ifndef __SubFacilityDlg_H_
#define __SubFacilityDlg_H_

#include "resource.h" // main symbols
#include <atlhost.h>
#include "SubFacility.h" <---- CAUSES COMPILE ERRORS IN THIS MODULE
#include "dbSubFacility.h"

using namespace ATLControls;


typedef unsigned (WINAPI *PBEGINTHREADEX_THREADFUNC)(LPVOID lpThreadParameter);
typedef unsigned *PBEGINTHREADEX_THREADID;


// Registered Window Messages for notifying when threads are done.
static UINT g_msgDbSubFacilityDone = RegisterWindowMessage("DbSubFacilityThreadDone");

/////////////////////////////////////////////////////////////////////////////
// CSubFacilityDlg
class CSubFacilityDlg :
public CDialogImpl<CSubFacilityDlg>
{
private:
void* m_pParent ;
CDBSubFacility& m_dbSubFacility ;
double m_selectedSubFacility ;
RWCString m_strQuery ;


RWCString getLikeCriteria () ;
RWCString getAndClause(RWCString column, CEdit edt, CComboBox cb) ;
void loadListCtrl() ;

protected:
HANDLE m_hThread ;
DWORD m_ThreadId;

DWORD findThreadMember () ;
void find (RWCString strQuery) ;

public:
static DWORD WINAPI findThread (LPVOID param) ;
double getSelectedSubFacility() { return m_selectedSubFacility; }

CSubFacilityDlg(void* pParent, CDBSubFacility& sfac) : m_pParent(pParent) ,
m_dbSubFacility(sfac)
{
m_selectedSubFacility = 0 ;
}
......

// code from within a message handler that is suppose to inform the main
// COM object to Fire and event.

((CSubFacility*)m_pParent)->Fire_id_clicked(100) ;
.....




thanks in advance
Gary