|
Hi Mike,
Thanks for the info. I found this link
http://www.codeproject.com/useritems/xptheme.asp
but it says it will only work for XP.
|
|
|
|
|
On XP it looks like (is) a real XP application with the current theme and all, when running under older versions of Windows it look like standard applications on those...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
hello,
i would to like to store the menu item name whenever i click the menu item name(string type of menu item ) by sitting in one appllication and record all menu items names in all applications like word ,excel,notepad,wordpad etc..
for this task ,i used global hooks, i got only menu name not the menu item name... will pl. give any suggestion or code ...
waiting for ur reply soon ...
|
|
|
|
|
Hi
About 2 threads ago I asked how to compile my dll which works as a Browser Helper Object with InternetExplorer.
Now it works fine, although I have one question. I searched www.google.com and other sites but did not find an answer (only how to do with VisualBasic
My question is how to handle the BeforeNavigate2 event.
What I have so far is as follows:
STDMETHODIMP CIEHlprObj::BeforeNavigate2(IDispatch *pDisp, VARIANT *url, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, VARIANT_BOOL *Cancel)
{
return S_OK;
}
I want to be able to cancel the navigation if the user entered a restricted site.
Furthermore I want to change the url in order to redirect the navigation to a different site
how can I do this
thanks in advance
|
|
|
|
|
STDMETHODIMP CIEHlprObj::BeforeNavigate2(IDispatch *pDisp, VARIANT *url, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, VARIANT_BOOL *Cancel)
{
CString TheBestURL = _T("http://www.codeproject.com");
*Cancel = TRUE;
Navigate2(TheBestURL);
return S_OK;
}
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
Hey great!!!! THANKS!!!
And how can I find out what the url is the browser wants to navigate to?
What do I need to do with the VARIANT *url?
I also want to change the *url to redirect the browser to a different site
|
|
|
|
|
That is the URL being navigated to.
|
|
|
|
|
I know, but it is of type VARIANT.
How can I convert it into a "readable" format like char?
And how can I modify the variable *url?
|
|
|
|
|
u can use this : CString strUrl = CString(URL->bstrVal);
|
|
|
|
|
My DLL does not use MFC extension, therefore CString does not work
And how can I modify the variable "url"?
(for example like url = "something")
|
|
|
|
|
The variant holds all kinds of types. check to see if the url.vt == VT_BSTR (it will or it will be VT_BYREF|VT_BSTR) then you can use the url.bstrVal (or if byref url.pbstrVal) to see the url which will be a unicode string.
if (!wcscmp(bstrVal, "http://thesitetheyshouldnotgoto.com")
{
SysFreeString(url.bstrVal);
url.bstrVal = SysAllocString("http://younaughtyuser.com");
}
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
I don't know whether I understand what you mean.
Here is what I have so far
STDMETHODIMP CIEHlprObj::BeforeNavigate2(IDispatch *pDisp, VARIANT *url, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, VARIANT_BOOL *Cancel)
{
if(url->vt == VT_BSTR)
{
if (!wcscmp(url->bstrVal, "http://thesitetheyshouldnotgoto.com"))
{
SysFreeString(url->bstrVal);
url->bstrVal = SysAllocString("http://younaughtyuser.com");
}
}
if(url->vt == VT_BSTR | VT_BYREF)
{
if (!wcscmp(url->pbstrVal, "http://thesitetheyshouldnotgoto.com"))
{
SysFreeString(url->pbstrVal);
url->pbstrVal = SysAllocString("http://younaughtyuser.com");
}
}
return S_OK;
}
But I get 5 compiler errors and 1 warning
|
|
|
|
|
Well since you haven't given the compiler errors I can only venture to guess that the reason is you are doing string compares of unicode vs ansi strings. For example in the code in your previous message you state
if (!wcscmp(url->bstrVal, "http://thesitetheyshouldnotgoto.com"))
{
SysFreeString(url->bstrVal);
url->bstrVal = SysAllocString("http://younaughtyuser.com");
}
It should be
if (!wcscmp(url->bstrVal, L"http://thesitetheyshouldnotgoto.com"))
{
SysFreeString(url->bstrVal);
url->bstrVal = SysAllocString(L"http://younaughtyuser.com");
}
I probably forgot the "L" in my sample above. that would account for 4 of the errors. What's the fifth?
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
You have the URL in url.bstrval
And you can redirect the Browser with Navigate2.
But A question, you want to control the IE or you ar making your own Explorer???
Cheers!!!
Carlos Antollini.
|
|
|
|
|
url.bstrval is of type unsigned short*, isn't it?
How to convert to char?
I have this code so far:
CComVariant varURL(url->bstrVal);
varURL.ChangeType(VT_BSTR);
??? << OLE2T(varURL);
I need a variable for "???"
I want to control the IE
|
|
|
|
|
First
I always do that in this mode:
CString str = _T("");
str = vtFld.bstrVal;
Second
If you want to control the IE, read the answer that Michael Dunn posted you...
Best Regards!!!
Carlos Antollini.
|
|
|
|
|
Check out KB article Q179230 which contains a complete BHO sample, including how to grab the URL and how to cancel navigation.
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
I already took a look at this article, but the example doesn't use BeforeNavigate2 and no variable "url" of type VARIANT.
btw I hate the type VARIANT
|
|
|
|
|
I have defined a class foo, and I have a CList of the class, defined as:
CList <foo, foo&=""> fooList;
After populating the list, I want to process items from that list in a function within another class. The ways I have tried keep giving me C2664 and C2440 errors.
This sounds pretty basic, but what is the proper way to declare my function parameters and make the call with the CList?
TIA.
|
|
|
|
|
Here's how you prototype a CList reference parameter:
void YourFunction ( CList<foo, foo&>& refList );
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
I would like to disable borders which appears with WebBrowser ActiveX. I saw that a solution would be to implement IDocHostUIHandler interface and to use GetHostInfo(), but how to implement that interface from a MFC Dialog Exe. AtlBrowser and WBCustomizer implement IDocHostUIHandler from COM interface.
Thanks in advance.
|
|
|
|
|
I was implementing a reference counting mechanism. How do I address the situation, where I store the pointers in a list or a map and does not have any other references to it. If I use the MFC map or list classes, will the addition to the list/map increment one count. As far as I understand, they either add it as a void* or a CObject*. Is it different in STL lists?
- Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
I was implementing a reference counting mechanism You mean something other than what is available anyway?
If you are adding the pointer to a list you do not need to AddRef. You would AddRef if you were copying the interface.
|
|
|
|
|
If I understood you well, it's some class you're designing (say CYourClass ) that has the ref counting methods (AddRef() and Relase or something similar). In this situation, no container, be it from MFC or STL, is going to call that methods automatically if all you store in them is plain pointers to CYourClass . What you should have to do is store instead some suitable smart pointer that does the job of incrementing/decrementing the objects count at construction, destruction and assignment time. Have a look here at CodeProject or any other major programming site to find a wealth of info about smart pointers.
Once you have your smart pointers up and running, both MFC and STL containers will work OK with them. IMHO, however, STL is preferrable because of portability and design issues.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thankyou for the reply. I have already made the pointer that does the job of inc/dec, assignment etc.
I have a smart pointer implemented, that is used like this:
CPtr<CMyClass> p1 = new CMyClass;
This will make an object of type CMyClass inside the smart pointer and increment the ref count.
if I did
p1 = NULL;
the object would be deleted, because the reference count = 0;
Consider the following case :
I have a class with a member variable m_ptrList of type CPtrList or CTypedPtrList.
CClass::MyFunc()
{
CPtr<CMyClass> p1 = new CMyClass;
m_ptrList.AddHead(p1);
}
The problem that I foresee is that the AddHead will not increment the reference count. So will the object get deleted when MyFunc returns.
Is there something wrong in my understanding of the situation?
-Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|