Click here to Skip to main content
15,908,437 members
Home / Discussions / C#
   

C#

 
AnswerRe: [WPF] ICommand woes.... Pin
Super Lloyd26-Jun-07 19:33
Super Lloyd26-Jun-07 19:33 
QuestionHow to change the color & size of the text in a textbox Pin
Bahaa Hany26-Jun-07 18:15
Bahaa Hany26-Jun-07 18:15 
AnswerRe: How to change the color & size of the text in a textbox Pin
Sathesh Sakthivel26-Jun-07 18:18
Sathesh Sakthivel26-Jun-07 18:18 
GeneralRe: How to change the color & size of the text in a textbox Pin
Bahaa Hany26-Jun-07 18:28
Bahaa Hany26-Jun-07 18:28 
GeneralRe: How to change the color & size of the text in a textbox Pin
Sathesh Sakthivel26-Jun-07 18:36
Sathesh Sakthivel26-Jun-07 18:36 
GeneralRe: How to change the color & size of the text in a textbox Pin
Christian Graus26-Jun-07 18:59
protectorChristian Graus26-Jun-07 18:59 
GeneralRe: How to change the color & size of the text in a textbox Pin
Blumen26-Jun-07 19:15
Blumen26-Jun-07 19:15 
GeneralRe: How to change the color & size of the text in a textbox Pin
Christian Graus26-Jun-07 20:11
protectorChristian Graus26-Jun-07 20:11 
AnswerRe: How to change the color & size of the text in a textbox Pin
I.explore.code26-Jun-07 18:50
I.explore.code26-Jun-07 18:50 
GeneralRe: How to change the color & size of the text in a textbox Pin
Bahaa Hany26-Jun-07 18:59
Bahaa Hany26-Jun-07 18:59 
QuestionHow to load and run non .net exe in memory? Pin
Rationalise26-Jun-07 16:06
Rationalise26-Jun-07 16:06 
AnswerRe: How to load and run non .net exe in memory? Pin
Christian Graus26-Jun-07 16:21
protectorChristian Graus26-Jun-07 16:21 
QuestionHow can I access the App's tab in the task Manager Pin
jeguzmanv26-Jun-07 14:59
jeguzmanv26-Jun-07 14:59 
AnswerRe: How can I access the App's tab in the task Manager Pin
Christian Graus26-Jun-07 15:45
protectorChristian Graus26-Jun-07 15:45 
GeneralRe: How can I access the App's tab in the task Manager Pin
jeguzmanv27-Jun-07 5:03
jeguzmanv27-Jun-07 5:03 
GeneralRe: How can I access the App's tab in the task Manager Pin
jeguzmanv27-Jun-07 5:52
jeguzmanv27-Jun-07 5:52 
QuestionProblem I can't get past. Pin
Cory Borrow26-Jun-07 13:54
Cory Borrow26-Jun-07 13:54 
AnswerRe: Problem I can't get past. Pin
Ed.Poore26-Jun-07 13:59
Ed.Poore26-Jun-07 13:59 
GeneralRe: Problem I can't get past. Pin
Cory Borrow26-Jun-07 14:49
Cory Borrow26-Jun-07 14:49 
AnswerRe: Problem I can't get past. Pin
Christian Graus26-Jun-07 15:02
protectorChristian Graus26-Jun-07 15:02 
GeneralRe: Problem I can't get past. Pin
Cory Borrow26-Jun-07 15:54
Cory Borrow26-Jun-07 15:54 
GeneralRe: Problem I can't get past. Pin
Christian Graus26-Jun-07 16:22
protectorChristian Graus26-Jun-07 16:22 
QuestionC#, IE, C++ & BHO's... getting a C# Explorer Toolbar to talk to a C++ BHO Pin
BenAnderson26-Jun-07 11:03
BenAnderson26-Jun-07 11:03 
Hello,
I'm a bit new at in-depth IE programming, and am having a bit of trouble with a couple of IE browser extensions (getting them to talk to each other).

The first one is a C++ Browser Helper Object (BHO).

I have a class (MyClass) that has a method called "ReferenceMe" that calls the browser's "PutProperty" method to save a reference to the BHO instance in IE.

Theoretically other COM object should be able to call IE's "GetProperty" method to retrieve this reference and use it to invoke methods in the BHO.

I also have another method in the BHO called "toggleActiveState" that just sets a boolean flag. That's the method I want to invoke from outside of the BHO.

Then I have a C# Explorer Toolbar object. I'm trying to call the BHO's "toggleActiveState" method from the C# code.

The problem I'm having is that I can't figure out how to invoke that "toggleActiveState" method in the C++ BHO from the C# code.

When I try to call the GetMethod function call in C# to retrieve the method's reference, it returns NULL.

Below are snippets of my code...

Here's the C++ code...

<br />
// This seems to work fine... it saves a reference to the BHO in an IE Property for later retrieval.<br />
HRESULT MyClass::ReferenceMe()<br />
{<br />
	BSTR bstrThisKey = SysAllocString(L"MyClass_IDisp");<br />
	VARIANT vThis;<br />
	HRESULT hr = S_OK;<br />
<br />
	if (!m_spWebBrowser)<br />
		hr = S_FALSE;<br />
	else<br />
	{<br />
		// Save this to a variant that will be referenced in IE Session<br />
		VariantInit(&vThis);<br />
		vThis.vt = VT_DISPATCH;<br />
		vThis.pdispVal = static_cast<IDispatch*>(this);<br />
<br />
		// Add our this pointer to IE session by adding a named property<br />
		if (FAILED( m_spWebBrowser->PutProperty(bstrThisKey, vThis) ))<br />
		{<br />
			hr = S_FALSE;<br />
		}<br />
	}<br />
	<br />
	VariantClear(&vThis);<br />
	SysFreeString(bstrThisKey);<br />
    return hr;<br />
<br />
}<br />
<br />
// This is the method that I want to call from the C# code<br />
// It's declared in the Public portion of the class in the .h file.<br />
void STDMETHODCALLTYPE MyClass::toggleActiveState()<br />
{<br />
	m_bActive = !m_bActive;<br />
}<br />
<br />


And here's my C# code...

<br />
private void toggleBHO()<br />
{<br />
	Object pvarPBHO = null;<br />
	// Get the property from IE that was put there by the C++ code's call to "PutProperty"<br />
	// This does seem to return a COM object, which I'm assuming is my BHO reference.<br />
	pvarPBHO = Explorer.GetProperty("MyClass_IDisp");<br />
	if (pvarPBHO != null)<br />
	{			<br />
		MessageBox.Show("About to call GetType.");<br />
		// Get the object's type.  This seems to work fine.<br />
		Type typExternal = pvarPBHO.GetType();<br />
		if (typExternal != null)<br />
		{                    <br />
			// Now try to retrieve a reference ot the "toggleActiveState" method within the C++ code<br />
			MethodInfo mthInv = null;<br />
			MessageBox.Show("About to call GetMethod.");<br />
			<br />
			// AT THIS POINT THE GetMethod FUNCTION RETURNS NULL...<br />
			<br />
			// I'm not sure if I'm not calling this right, or if my prototype isn't quite right<br />
			// to allow public access to the method, or what.<br />
			mthInv = typExternal.GetMethod("toggleActiveState");<br />
			if (mthInv != null)<br />
				mthInv.Invoke(pvarPBHO, null);<br />
			else<br />
				MessageBox.Show("GetMethod returned NULL.");<br />
		}<br />
		else<br />
			MessageBox.Show("GetType returned NULL.");<br />
	}<br />
	else<br />
		MessageBox.Show("GetProperty returned NULL.");<br />
}<br />


Perhaps my whole approach to this is off. Is there a better way to get these two COM objects to talk to each other?

Thanks very much!
Questionftp FtpWebRespose.GetRespone() Exception Pin
Mostafa Siraj26-Jun-07 8:43
Mostafa Siraj26-Jun-07 8:43 
QuestionUDP Error Pin
ramdil26-Jun-07 6:54
ramdil26-Jun-07 6:54 

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.