1 Writing the ActiveX control
\r
2 ===========================
\r
4 Start a new MFC ActiveX C++ project.
\r
5 Use all the default settings except in Control Settings, change the control to be based on STATIC.
\r
6 Add a dialog resource...
\r
7 Get rid of the existing widgets on the dialog.
\r
8 Set the following properties...
\r
14 Leave the ID as IDD_DIALOG1
\r
16 Create a new MFC class... call it CControlDialog
\r
17 Set the base class to CDialog
\r
18 Set the Dialog ID to IDD_DIALOG1
\r
21 Right click the ctrl class...
\r
25 Variable type = CControlDialog
\r
26 Variable name = mDialog
\r
30 Click on the ctrl class
\r
32 Click on messages icon
\r
33 In the WM_CREATE message section add the text "OnCreate"
\r
34 A new OnCreate function has been produced.
\r
36 At minimum add the following code after the autogenerated code...
\r
37 mDialog.Create(IDD_DIALOG1, this);
\r
38 mDialog.ShowWindow(TRUE);
\r
41 Adding a play button
\r
42 ====================
\r
43 Go back to resource view.. open the dialog.
\r
46 Change the caption to play.
\r
47 Double click the button... a new method should be generated.
\r
48 Check the message map to ensure the following has been added.
\r
49 ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
\r
50 If it hasn't add it manually, ensuring you use the correct IDC and function name.
\r
53 Grabbing a browser instance...
\r
54 ============================
\r
57 Manually add the following public function prototype
\r
58 void setBrowser(IWebBrowser2* inBrowser);
\r
60 Manually add the following protected variable.
\r
61 IWebBrowser2* mBrowser;
\r
62 In the constructor... initialise to NULL.
\r
64 Manually implement a function for setBrowser in ControlDialog.cpp, which assingsg inBrowser to mBrowser.
\r
66 Add the following code into the ctrl classes OnCreate method to grab the browser interface and send it to the
\r
69 IServiceProvider* locISP = NULL;
\r
70 IWebBrowser2* locBrowser = NULL;
\r
72 HRESULT locHR = GetClientSite()->QueryInterface(IID_IServiceProvider, (void **)&locISP);
\r
73 if (locHR == S_OK) {
\r
74 locHR = locISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (void **)&locBrowser);
\r
75 if (locHR == S_OK) {
\r
76 mDialog.setBrowser(locBrowser);
\r
84 Put the following code in the destructor for the dialog class.
\r
86 if (mBrowser != NULL) {
\r
87 mBrowser->Release();
\r
90 Repeat procedure for adding play button to add pause and stop button.
\r
92 Add a generic class class called DSPlayer... steal all the internal code from DSPlay (the .NET player library for DNPlay)
\r
93 Change all the managed code parts back to unmanaged equivalents.
\r
96 Create an unmanaged interface for media event notifications.
\r
99 Code to embed windows in the control... (This is in DSPLayer now)
\r
101 //CHANGES HERE FOR EMBEDDED WINDOW
\r
102 IVideoWindow* locVW = NULL;
\r
103 locHR = locGraphBuilder->QueryInterface(IID_IVideoWindow, (void **)&locVW);
\r
105 if (locHR == S_OK) {
\r
107 locVW->put_MessageDrain((OAHWND)inWindow);
\r
110 locVW->put_Owner((OAHWND)inWindow);
\r
112 locVW->SetWindowPosition(inLeft, inTop, inWidth, inHeight);
\r
119 Read this for registering an activeX control as the player for an extension in IE
\r
120 http://msdn.microsoft.com/workshop/components/activex/registration.asp