This ATL ActiveX framework is suitable for serving as the bearer container for Windows Media Player, Flash, and sliverlight animations. The entire framework is distributed in the windowless folder, with 6 files in total. Architecture:
UseAdobe Flash PlayerAs a child Control
MainCodeAs follows:
Class cmaindlg: Public caxwindowlesshost <cmaindlg>
Lresult cmaindlg: oninitdialog (uint/* umsg */, wparam/* wparam */, lparam/* lparam */, bool &/* bhandled */)
{
// Center the dialog on the screen
Centerwindow ();
// set icons
hicon = (hicon): LoadImage (_ module. getresourceinstance (), makeintresource (idr_mainframe),
image_icon,: getsystemmetrics (sm_cxicon),: getsystemmetrics (sm_cyicon), lr_defaultcolor);
seticon (hicon, true);
hicon hiconsmall = (hicon): LoadImage (_ module. getresourceinstance (), makeintresource (idr_mainframe),
image_icon,: getsystemmetrics (response),: getsystemmetrics (response), lr_defaultcolor);
seticon (hiconsmall, false);
tchar szpath [max_path] = {0};
If (: getmodulefilename (null, szpath, max_path)> 0)
{// positioning .swf file
lptstr pszsep = _ tcsrchr (szpath, tchar ('\');
pszsep ++;
* pszsep = 0;
: stringcchcat (szpath, max_path, _ T ("construction.swf");
}
// initialize Flash Player (shockwave. SWF)
hresult hr;
activexsite * psite;
psite = caxwindowlesshost : getcontrolsite (idc_shockwaveflash ); // obtain the Flash Player sub-Control
If (psite! = NULL)
{< br> ccomqiptr spflash = psite-> activexcontrol ();
hR = spflash-> put_wmode (ccombstr ("Transparent"); // set "Transparent"
hR = spflash-> put_movie (ccombstr (szpath )); // set the video source file
}< br> return true;
}
UseWindows Meida playerAs a child Control
The main code is as follows:
Lresult cmaindlg: oninitdialog (uint/* umsg */, wparam/* wparam */, lparam/* lparam */, bool &/* bhandled */)
{
// Center the dialog on the screen
Centerwindow ();
// Set icons
Hicon = (hicon): LoadImage (_ module. getresourceinstance (), makeintresource (idr_mainframe ),
Image_icon,: getsystemmetrics (sm_cxicon),: getsystemmetrics (sm_cyicon), lr_defaultcolor );
Seticon (hicon, true );
Hicon hiconsmall = (hicon): LoadImage (_ module. getresourceinstance (), makeintresource (idr_mainframe ),
Image_icon,: getsystemmetrics (sm_cxsmicon),: getsystemmetrics (sm_cysmicon), lr_defaultcolor );
Seticon (hiconsmall, false );
// Initialize Windows Media Player
Hresult hr;
Activexsite * psite;
Psite = caxwindowlesshost <cmaindlg>: getcontrolsite (idc_wmp11); // obtain the Meida player sub-control
If (psite! = NULL)
{
Psite-> setallowresize (false); // automatic resizing is not allowed
Ccomqiptr <iwmpcore> WMP = psite-> activexcontrol ();
Ccomqiptr <iwmpplayer4> wmp4 = psite-> activexcontrol ();
// This can be done manually as well
If (wmp4)
{
HR = wmp4-> put_windowlessvideo (variant_true); // No window mode
// HR = wmp4-> put_uimode (ccombstr ("full"); // fill Mode
}
// HR = WMP-> put_url (ccombstr ("C :\\ Temp \ videofile. wmv"); // multimedia file address
}
Return true;
}
Lresult cmaindlg: onbnclickedbtnbrowse (word/* wnotifycode */, word/* WID */, hwnd/* hwndctl */, bool &/* bhandled */)
{// Select a multimedia file
Static lpctstr pszfilter = _ T ("video files (*. avi ;*. MPG ;*. WMV) \ 0 *. avi ;*. MPG ;*. WMV \ 0 \ 0 ");
Cfiledialog fileopen (true, _ T ("Avi"), null,
Ofn_hidereadonly | ofn_overwriteprompt, pszfilter/*, m_hwnd */);
If (idok = fileopen. domodal ())
{
Activexsite * psite;
Psite = caxwindowlesshost <cmaindlg>: getcontrolsite (idc_wmp11 );
Setdlgitemtext (idc_txt_filename, fileopen. m_szfilename );
Ccomqiptr <iwmpplayer4> wmp4 = psite-> activexcontrol ();
Wmp4-> close ();
Wmp4-> put_url (ccombstr (fileopen. m_szfilename ));
}
Return 0;
}
UseSliverlightAs a child Control
The main code is as follows:
Lresult cmaindlg: oninitdialog (uint/* umsg */, wparam/* wparam */, lparam/* lparam */, bool &/* bhandled */)
{
// Center the dialog on the screen
Centerwindow ();
// Set icons
Hicon = (hicon): LoadImage (_ module. getresourceinstance (), makeintresource (idr_mainframe ),
Image_icon,: getsystemmetrics (sm_cxicon),: getsystemmetrics (sm_cyicon), lr_defaultcolor );
Seticon (hicon, true );
Hicon hiconsmall = (hicon): LoadImage (_ module. getresourceinstance (), makeintresource (idr_mainframe ),
Image_icon,: getsystemmetrics (sm_cxsmicon),: getsystemmetrics (sm_cysmicon), lr_defaultcolor );
Seticon (hiconsmall, false );
// Initialize Silverlight control (this is not windowless but cool anyway)
Hresult hr;
Activexsite * psite;
Psite = caxwindowlesshost <cmaindlg>: getcontrolsite (idc_agcontrol1); // obtain the sliverlight subcontrol
If (psite! = NULL)
{
// Disable right-click!
Psite-> setallowrclick (false); // right-click Disabled
// Load from URL
// Ccombstr bstrurl ("file: // C: \ temp \ sortthefootbars. xap ");
Ccombstr bstrurl ("http://www.andybeaulieu.com/silverlight/2.0/sortthefoobars/ClientBin/SortTheFoobars.xap ");
Psite-> seturl (bstrurl); // sets the multimedia source file
Ccomqiptr <ixcpcontrol2> slight = psite-> activexcontrol ();
HR = slight-> put_source (bstrurl );
}
Return true;
}