YUV player, display Interface (main window) and set interface separation, all parameters are in the Setting sub-window settings, it is necessary to implement parameter transfer in the main window and sub-window. Here's how.
1.
To define a child window variable in the main window Cyuvplayerdlg class:
csettingdlg* M_psettingdlg;
and set it to null at initialization time:
M_psettingdlg = NULL;
It is simpler to display a child window, primarily to request a resource, call the CREATE function, and specify the window ID. The code is as follows:
void Cyuvplayerdlg::showsettingwindow ()
{
//Non-modal dialog box
if (M_psettingdlg = = NULL)
{
M_psettingdlg = New Csettingdlg ();
M_psettingdlg->create (idd_dialog_setting, this);
}
M_psettingdlg->showwindow (sw_show);
}
Exit or destructor to free resources:
if (M_psettingdlg! = NULL)
{
delete m_psettingdlg;
M_psettingdlg = NULL;
}
The following implements the parameter passing.
Define the main window variable and assign a value in the Csettingdlg class:
Cyuvplayerdlg *m_pparentwnd; Window parameter passing
void Setparentwnd (cyuvplayerdlg* pWnd) {m_pparentwnd = pWnd;}
Use M_pparentwnd to access the main window function when the child window needs to proactively pass parameters to the main window. Such as:
void cyuvplayerdlg::setparentparameters (int width, int height, int fps, int fmt, BOOL loop)
{
m_nwidth = Width;
m_nheight = height;
M_nfps = fps;
M_nyuvformat = FMT;
M_floop = loop;
Restore the original state
if (! IsOpen ()) return;
Showopenedframe ();
}
The value of the child window is then uploaded to the main window. A similar approach is used when the main window needs to take the subwindow data. The following are the functions of the child window:
void Setparameterstoparentwnd (int& width, int& height, int& fps, int& fmt, bool& Loop)
{
width = m_nwidth;
Height = m_nheight;
fps = M_nfps;
FMT = M_nyuvformat;
loop = M_floop;
}
When the main window needs a subwindow parameter, such as initializing the setting window during the initialization of the main window, get the playback parameters, the code is as follows:
Initialize the Settings dialog box
if (M_psettingdlg = = NULL)
{
M_psettingdlg = new Csettingdlg ();
M_psettingdlg->create (idd_dialog_setting, this);
M_psettingdlg->setparentwnd (this);
Pass the value of the child window to this window
M_psettingdlg->setparameterstoparentwnd (m_nwidth, M_nheight, M_nfps, M_nyuvformat, M_fLoop);
}
Li Yu 2015.8.15