Click to See Complete Forum and Search --> : From View to Frame


Sophie
April 29th, 1999, 02:19 PM
If I have a function in the view and what I'm coding requires me to go and get the frame. How do I do that?

CMainFrame *pMainFrame= (CMainFrame *)m_pMainWnd;
pMainFrame->

I'm trying to get the multimedia control I've created in the CMainFrame::Oncreate

How do I do that?

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_filtertab.Create(this,IDD_Filtertab,CBRS_TOP,1111);


if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}

// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_filtertab.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
DockControlBar(&m_filtertab);
///Added code


#define SNAP_WIDTH 389 //the width of the Multimedia
//set up the Multimedia control as a snap mode select box //
//First get the index of the placeholder's position in the toolbar
int index = 0;
CRect rect;
while(m_wndToolBar.GetItemID(index)!=IDP_PLACEHOLDER2) index++;
//next convert that button to a seperator and get its position
m_wndToolBar.SetButtonInfo(index, IDP_PLACEHOLDER2, TBBS_SEPARATOR, SNAP_WIDTH);
m_wndToolBar.GetItemRect(index, &rect);

// then .Create the multimedia control and show it

if (!m_wndToolBar.m_wndSnap.Create(NULL,WS_CHILD|WS_VISIBLE,rect, &m_wndToolBar, IDP_PLACEHOLDER2))
{
TRACE0("Failed to create Multimedia Control\n");
return FALSE;
}
m_wndToolBar.m_wndSnap.ShowWindow(SW_SHOW);
m_wndToolBar.m_wndSnap.SetEjectVisible(FALSE);
m_wndToolBar.m_wndSnap.SetRecordVisible(FALSE);
m_wndToolBar.m_wndSnap.SetPrevVisible(FALSE);
m_wndToolBar.m_wndSnap.SetNextVisible(FALSE);
m_wndToolBar.m_wndSnap.SetEnabled(TRUE);
m_wndToolBar.m_wndSnap.SetAutoEnable(TRUE);
//m_wndToolBar.m_wndSnap.SetCanPlay(TRUE);
//m_wndToolBar.m_wndSnap.SetNotify(TRUE);
//m_wndToolBar.m_wndSnap.SetWait(TRUE);
//m_wndToolBar.m_wndSnap.SetShareable(FALSE);
m_wndToolBar.m_wndSnap.SetCommand("close");
// m_wndToolBar.m_wndSnap.SetDeviceType("WaveAudio");
// CString fileToPlay( "C:\\Lavac\\record.sav\\Judy\\1999.04.15(Thursday)\\21h 48m 30s (German)\\r0000002.wav");
// ASSERT( Path( ToString( fileToPlay)).IsFile());
// m_wndToolBar.m_wndSnap.SetFileName(fileToPlay);
// m_wndToolBar.m_wndSnap.SetCommand("open");



return 0;
}

LALeonard
April 29th, 1999, 04:13 PM
I'm not sure I follow what the code is trying to say, but try this:

dynamic_cast<CMainFrame*> (GetParentFrame())->
m_wndToolBar.m_wndSnap.SetAutoEnable(TRUE);


LA Leonard - http://www.DefinitiveSolutions.com