Dialog box to child control switching example: see attachment map: The original interface is embedded in the dialog box in the dialog box to jump out of the main window keyword: setParent, WS_POPUP, WS_CHILD background: ready to make a player, underlying interface Ok, just get into a window handle, you can play the media on the window. Originally wanted to place a Static control on a dialog, it is good to pass the Static control handler to the underlying interface. Ordinary play is no problem, the movie is on Static. But it is required to play full-screen, which is hard to wait. Because Static can't full screen. Purpose: You can full screen a window, but you can embed the window in another window. Scenario: (1) Dynamically change the style of the Static control, and more null of its parent window handle, see if the control can be jumped out of the dialog. This program has been implemented, successful. The Static control jumps out the dialog and becomes a separate window. But the window can't control it, you can't go back. This program seems to have problems. Due to the time relationship, there is no in-depth study, and it is estimated that it can be drums. (2) make a main window, put a Static to adjust the size to a suitable location. A dialog is made, override the window over Static, dynamically change the dialog, which is the two dialogs before and after, it seems to be the control in the main window. Executed, success. But the problem is complicated to control, and it is necessary to calculate it. The title of the main window behind also loves gray, and you will know that it is two windows. Not. (3) It is also two windows, but uses it in the dialog in playing a movie to embed it into the main window, when you need full screen, turn its properties into a window, then you jump out of the main window And full screen. Since it is a window, it can control it. When you need to recover, it is embedded in the main window and it is a child control. This solution is discussed herein. Steps: 1. Create a project based on dialog. Add a Static: IDC_FullScreen in the dialog box, pull out the appropriate size shape. To accommodate another window. 2, insert a dialog resource. Remove all the default controls above. You must modify the dialog The following properties: a) Visible True B) Model CHILD modifies the title bar as needed. Can look at the effect yourself. If there is a title bar, you can move the window in STATIC. 3, generate a new class CMYDLG a) to overload the following two functions to this class to prevent the user to turn the window to turn the window. Void onok () {return;} void oncancel () {return;} b) Since it is necessary to communicate with the main window (that is, its parent window), after the dialog jumps out of the parent window, it is necessary to embed it again in the parent window. So add an instance pointer of a parent window class. CWnd * m_pparent; c) In the CMYDLG constructor, save the parent window pointer to use: cMydlg :: cmydlg (CWND * pParent / * = null * /): cdialog (CMYDLG :: IDD, PParent), m_pparent (pParent) {} 4, after the above window, we cannot drag to the dialog as a normal control, so you need to define a pointer member variable in the main window class to save the play window and dynamically created.
CMYDLG * PDLG; and assigns it to NULL in the constructor of the dialog class. DELETE PDLG in the sect. 5. Initialize CMYDLG in the OnInitDialog function of the dialog; as follows: // Todo: Add additional initialization code CWnd * ps = (cwnd *) getdlgitem (idc_fullscreen); if (ps == null) {AFXMESSAGEBOX ("Error "); return false;} if (pdlg == null) {pdlg = new cmydlg (pdlg-> create (cmydlg :: IDD, PS); PDLG-> showwindow (sw_normal);} When creating CMYDLG, Point its parent window to the Static window. 6, can run the program at this time. Of course, you need to add trivial things like some header files when you compile, you can get it. We can find that the play window appears in the Static control of the main window. If there is a title bar, you can move. If the border of the play window has Resizing properties, you can change the size. After playing enough, the program is completed, continue. 7, now add to the action of jump out the play window out of the main window. It is mainly used that the setWindowlong function modifies its existing properties. Processing in a button pressed, the main function is to add a subset property (WS_CHILD) to add a pop-up attribute (WS_POPUP), then set its parent window to null. After recovering the code released in the code, the full screen is achieved. Void cfullscreendlg :: OnbnclickedButton2 () {// Todo: Add control notification handler code IF (PDLG == null) return; hwnd hwnd = PDLG-> getsafehwnd (); if (hwnd == null) return; :: Setwindowlong (hwnd, gwl_style, (:: getwindowl ") & (~ ws_child) & (~ ws_disable) | ws_popup); PDLG-> setParent (null); // if (! :: setwindowpos (hwnd, hwnd_topmost) , 0, 0, getSystem, GetSystemMeen, 0) // {// afxMessageBox ("no"); //}} 8, now run the program, then after the button, we discove the play window true Jumping out. Press the ESC key to exit the program. Let's add the feature that is restored to the Embedded main window. 9. For the sake of simplicity, we are directly implemented in the CMYDLG class. Add a message processing function to CMYDLG: The left mouse button bounces, in the message processing, nothing more than modifying the window properties.