In the app class header file, after the app class definition, add the folowing line:
extern CMyApp theApp;
Add these declarations to your app class:
private:
CMainFrame* m_pMainFrame;
public:
CMainFrame* GetMainFramePtr() { return m_pMainFrame);
In the OnInitInstance function of your app class, do this AFTER the main window is created:
m_pMainFrame = pMainFrame;
In the CMainFrame class, put a function that accepts a CComboBox* like so:
int CMainFrame::FillComboBox(CComboBox* pCombo)
{
// fill the combo box
// and return the number of things you put in it
return pCombo->GetCount();
}
From within the OnInitDialog() function in the dialog box class, call your function like so:
theApp.GetMainFrame()->FillComboBox(&m\_ctrlComboBox);
I'm assuming that your dialog box class already has #include "MyApp.h" in it. :)