Click here to Skip to main content
15,949,686 members
Home / Discussions / COM
   

COM

 
GeneralCOM+ Queued Components not working Pin
cfoley3-Jun-03 0:16
cfoley3-Jun-03 0:16 
GeneralIDataObject with delayed rendering Pin
jiang-lei2-Jun-03 22:44
jiang-lei2-Jun-03 22:44 
QuestionBuilding COM object for folder protection?? Pin
Lalit S. Rana2-Jun-03 19:49
Lalit S. Rana2-Jun-03 19:49 
AnswerRe: Building COM object for folder protection?? Pin
Anonymous3-Jun-03 10:16
Anonymous3-Jun-03 10:16 
GeneralRe: Building COM object for folder protection?? Pin
Anonymous3-Jun-03 18:24
Anonymous3-Jun-03 18:24 
Generalasp 0177 Pin
jeff daniels2-Jun-03 19:49
jeff daniels2-Jun-03 19:49 
GeneralShell Programming ICopyHook Pin
Lalit S. Rana2-Jun-03 19:47
Lalit S. Rana2-Jun-03 19:47 
GeneralJavascript problem with calling get_External method Pin
RAM_MR2-Jun-03 8:02
RAM_MR2-Jun-03 8:02 
I am new to COM. I have been trying to incorporate the WebBrowser control into an MFC program. I have been using as an example and article from MSDN -http://www.microsoft.com/mind/0798/webbrowser.asp.
In this example VBScript is used. I have been trying to use JavaScript instead. I am unable to change a value with a COM method when I pass a value from Javascript;

IN VBSCRIPT:
sub get_property_value_onclick()
i=window.external.get_propert(property_name.value, value)
if i<>0 then
property_value.value=value
MsgBox property_name.value & " = " & value, 0, "Successfully retrieved property"
else
MsgBox "Cound not find value for property '" & property_name.value & "'", 0 , ""
end if
end sub

In Javascript:
function get_property_value_onclick(namevalue,value)
{
var value = "test";
var i = window.external.get_property(property_name.value,value)
if (i != 0)
{
property_value.value=value;
var strMsg;
strMsg = "Successfully retrieved property:" + property_name.value + " = " + value ;
alert( strMsg);
}
else
{
var strMsg;
strMsg = "Could not retrieve" + property_name.value + " = " + value ;
alert( strMsg);
}

}

The COM Method:
HRESULT my_application::get_property(LCID lcid,
WORD wFlags,
DISPPARAMS* pdispparams,
VARIANT* pvarResult,
EXCEPINFO* pexcepinfo,
UINT* puArgErr)
{
if (wFlags & DISPATCH_METHOD)
{
if (pdispparams->cArgs!=2)
{
return DISP_E_BADPARAMCOUNT;
}

// force to string
VARIANT arg1;
VariantInit(&arg1);
HRESULT hr=VariantChangeType(&arg1,
&pdispparams->rgvarg[1],
0,
VT_BSTR);
if (FAILED(hr))
{
*puArgErr=1;
return hr;
}

string str;
com_util::bstr2string(arg1.bstrVal,str);

// try to find element
string2variant_map::iterator it=propertymap.find(str);
if (it==propertymap.end())
{
if (pvarResult)
{
V_VT(pvarResult) =VT_BOOL;
V_BOOL(pvarResult)=FALSE;
return S_OK;
}

if (!pexcepinfo)
{
return E_INVALIDARG;
}

// raise exception
memset(pexcepinfo,0,sizeof(EXCEPINFO));
pexcepinfo->wCode =1001;
pexcepinfo->bstrSource =SysAllocString(L"WebBrowser Demo");
pexcepinfo->bstrDescription =SysAllocString(L"No entry for the key");

return DISP_E_EXCEPTION;
}



hr = VariantCopy(pdispparams->rgvarg[0].pvarVal,&(*it).second);


if (pvarResult)
{
V_VT(pvarResult) =VT_BOOL;
V_BOOL(pvarResult)=TRUE;
}

return S_OK;
}

return DISP_E_MEMBERNOTFOUND;
}


The function VariantCopy(pdispparams->rgvarg[0].pvarVal,&(*it).second);
returns a bad varibale HRESULT. Bu tit works OK in VBSCRIPT. Any idea on how to solve this?

thanks,
RAM_MR
GeneralMFC application with ATL object Pin
Brian van der Beek2-Jun-03 0:54
Brian van der Beek2-Jun-03 0:54 
GeneralRe: MFC application with ATL object Pin
Brian van der Beek2-Jun-03 1:30
Brian van der Beek2-Jun-03 1:30 
GeneralSub classing a Activex Control Pin
Mayank Goyal1-Jun-03 23:39
Mayank Goyal1-Jun-03 23:39 
QuestionShielding COM objects? Pin
Brian van der Beek1-Jun-03 22:06
Brian van der Beek1-Jun-03 22:06 
AnswerRe: Shielding COM objects? Pin
valikac2-Jun-03 6:49
valikac2-Jun-03 6:49 
GeneralRe: Shielding COM objects? Pin
Brian van der Beek2-Jun-03 21:00
Brian van der Beek2-Jun-03 21:00 
GeneralRe: Shielding COM objects? Pin
valikac3-Jun-03 8:06
valikac3-Jun-03 8:06 
AnswerRe: Shielding COM objects? Pin
Vi23-Jun-03 2:45
Vi23-Jun-03 2:45 
GeneralRe: Shielding COM objects? Pin
Brian van der Beek3-Jun-03 21:33
Brian van der Beek3-Jun-03 21:33 
GeneralEXCEL and MFC Pin
Daniela12329-May-03 10:08
Daniela12329-May-03 10:08 
GeneralRe: EXCEL and MFC Pin
Daniela1233-Jun-03 10:58
Daniela1233-Jun-03 10:58 
GeneralRe: EXCEL and MFC Pin
Mardigin18-Jul-03 10:11
Mardigin18-Jul-03 10:11 
Generalhelp resolve access violation in ole32.lib Pin
safee ullah28-May-03 23:19
safee ullah28-May-03 23:19 
GeneralRe: help resolve access violation in ole32.lib Pin
safee ullah4-Jun-03 1:35
safee ullah4-Jun-03 1:35 
GeneralCOM+ error in evt log. 0x80070008, error comsvcs.cpp line 289... Pin
Anonymous27-May-03 22:29
Anonymous27-May-03 22:29 
Generalcreate a activex control from a VC++ project Pin
A.Satish Kumar27-May-03 6:00
A.Satish Kumar27-May-03 6:00 
GeneralDCOM Server - Problem with Parameters Pin
Anand Vinod27-May-03 3:59
Anand Vinod27-May-03 3:59 

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.