My YUV player MFC small Note: Non-modal dialog box creation and inter-window transfer value

Source: Internet
Author: User

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




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.