Click here to Skip to main content
16,005,149 members
Home / Discussions / COM
   

COM

 
GeneralRe: COM security and access Pin
Anonymous4-May-04 13:26
Anonymous4-May-04 13:26 
GeneralMSHTML Pin
JDasari3-May-04 10:35
JDasari3-May-04 10:35 
GeneralRe: MSHTML Pin
Andrew Quinn AUS17-May-04 22:39
Andrew Quinn AUS17-May-04 22:39 
GeneralRe: MSHTML Pin
JDasari18-May-04 7:09
JDasari18-May-04 7:09 
GeneralRe: MSHTML Pin
JDasari18-May-04 13:06
JDasari18-May-04 13:06 
GeneralRe: MSHTML Pin
JDasari18-May-04 13:09
JDasari18-May-04 13:09 
GeneralRe: MSHTML Pin
JDasari18-May-04 13:12
JDasari18-May-04 13:12 
GeneralRe: MSHTML Pin
Andrew Quinn AUS18-May-04 23:42
Andrew Quinn AUS18-May-04 23:42 
Hi again,

Right, I have a solution - now I don't profess to being anything but an amateur when it comes to Flash so there may be a better way. But this works so here goes:

Firstly, I created a button in my test flash movie and entered this for the onclick handler:

on (click) {
	// param#1 = command, param#2 = args
	fscommand("button1","");
}


See the help files for more info on the fscommand() script command

Now, in the HTML page we need the following:

1. Include a hidden INPUT field, e.g.

<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ID="mc" WIDTH=300 HEIGHT=300 CODEBASE="http://active.macromedia.com/flash2/cabs/swflash.cab#version=2,0,0,11">
 < PARAM NAME="Movie" VALUE="try1.swf">
 <EMBED NAME="mc" SRC="try1.swf" WIDTH=100 HEIGHT=100 PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</OBJECT>
<input type='hidden' id='idClickFlashEvent' value=''>


2. Add Script handlers in the page - NOTE!!!!!!! the id/name of the OBJECT and EMBED must be the same as the prefix to the _FSCommand !!!!!!:

<SCRIPT LANGUAGE="JavaScript">
<!-- 
//  Handle all the FSCommand messages in a Flash movie  
function mc_DoFSCommand(command, args) { 
  var oFS = document.getElementById("mc");
  if (oFS) {
    //  Evaluate the command string and decide what to do 
    var oHidden = document.getElementById("idClickFlashEvent");
    if (oHidden) { 
       oHidden.value = command; 
       oHidden.fireEvent("onclick");
    }
  }
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
<!-- 
//  Map VB script events to the JavaScript method - Netscape will ignore this... 
//  Since FSCommand fires a VB event under ActiveX, we respond here 
Sub mc_FSCommand(ByVal command, ByVal args)
  call mc_DoFSCommand(command, args)
end sub
-->
</SCRIPT>


So when you click in the Flash Player, it runs the ActionScript which then calls out to FSCommand externally, the external object (the web page) has to implement this by creating a function in VBScript (for IE at least) which MUST be named ID of object_FSCommand.

I've then called into the mc_DoFSCommand in JScript (my preferred scripting language) which looks for the hidden input field. Once we've got the object, I do two things:

1. Set the value of it to one of the params passed through (in this case it was just the word "button1"). I've done this as I presume you want to do more than just know a click was performed - so this gives the option to pass through what was clicked.

2. We fire an OnClick event.

Now the INPUT element doesn't have a onclick event as such, but the DOM fires this event through the active element (which in this case is the OBJECT element) - Hey presto the code I gave previously in this thread will now handle that onclick event Smile | :)

If you want to gain access to the value we set above, they you can use the following code in your onclick event handler in C++:

void CWebTest1Dlg::OnHTMLClick()
{
	MSHTML::IHTMLDocument2Ptr spDoc(m_ctlWeb1.GetDocument());
	if (spDoc)
	{
		MSHTML::IHTMLElementPtr spElem = spDoc->activeElement;
		if (spElem)
		{
			CString strTag = (LPCTSTR)spElem->tagName;
			if (strTag == _T("OBJECT"))
			{
				// do we have an 'idClickFlashEvent' element?
				MSHTML::IHTMLDocument3Ptr spDoc3 = spDoc;
				if (spDoc3)
				{
					MSHTML::IHTMLElementPtr spElem2 = spDoc3->getElementById(_bstr_t("idClickFlashEvent"));
					if (spElem2)
					{
						// you can check if the tagName is correct here
						// for this example though lets just use it...
						MSHTML::IHTMLInputElementPtr spElemHidden = spElem2;
						if (spElemHidden)
						{
							// get the value...
							AfxMessageBox(spElemHidden->value);
						}
					}
				}
				
			}
		}
	}
}


So there we have it. If you need any help or have more questions, I'll be happy to help Smile | :)

BTW, it does not have to be a HIDDEN input field, you could do it with say a BUTTON input field but then you'd have to have the display style attribute set to none to stop it being displayed, it would also influence your C++ onclick handler because now when the JScript fireEvent method is called, it will no longer be the OBJECT that fires the onclick, but the button has this DOES have a valid onclick event (phew). So I thought it easier to use the HIDDEN input element Smile | :)

Cheers,
Andy
Generalclass not registered Pin
pringle m30-Apr-04 4:40
pringle m30-Apr-04 4:40 
GeneralInvalidCastException Pin
..Hubert..29-Apr-04 22:01
..Hubert..29-Apr-04 22:01 
GeneralRe: InvalidCastException Pin
Jörgen Sigvardsson2-May-04 6:44
Jörgen Sigvardsson2-May-04 6:44 
GeneralRe: InvalidCastException Pin
..Hubert..3-May-04 0:29
..Hubert..3-May-04 0:29 
GeneralWTL 7.1 from Microsoft here Pin
TW26-Apr-04 22:35
TW26-Apr-04 22:35 
GeneralRe: WTL 7.1 from Microsoft here Pin
Jörgen Sigvardsson2-May-04 6:35
Jörgen Sigvardsson2-May-04 6:35 
GeneralHelp with _variant_t Pin
benwestgarth26-Apr-04 14:11
benwestgarth26-Apr-04 14:11 
GeneralRe: Help with _variant_t Pin
f6426-Apr-04 18:20
f6426-Apr-04 18:20 
GeneralRe: Help with _variant_t Pin
benwestgarth26-Apr-04 18:29
benwestgarth26-Apr-04 18:29 
GeneralRe: Help with _variant_t Pin
Rory Solley26-Apr-04 21:56
Rory Solley26-Apr-04 21:56 
GeneralRe: Help with _variant_t Pin
f6427-Apr-04 5:44
f6427-Apr-04 5:44 
GeneralRe: Help with _variant_t Pin
benwestgarth27-Apr-04 12:41
benwestgarth27-Apr-04 12:41 
GeneralRe: Help with _variant_t Pin
Milton Karimbekallil26-Apr-04 23:09
Milton Karimbekallil26-Apr-04 23:09 
GeneralIdentifying an unknown error Pin
Kaleb Pederson26-Apr-04 8:52
Kaleb Pederson26-Apr-04 8:52 
GeneralRe: Identifying an unknown error Pin
Mike Dimmick26-Apr-04 23:26
Mike Dimmick26-Apr-04 23:26 
GeneralRe: Identifying an unknown error Pin
Kaleb Pederson27-Apr-04 9:36
Kaleb Pederson27-Apr-04 9:36 
QuestionEasily find IID, CLSID, ProgID? Pin
Kaleb Pederson26-Apr-04 7:09
Kaleb Pederson26-Apr-04 7:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.