Click here to Skip to main content
15,924,452 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCHtmlView Pin
r2-r22-Dec-01 3:29
r2-r22-Dec-01 3:29 
GeneralUrgent::++ How to make IE popup adds Killer application in VC++ Pin
Ibrar Ahmad22-Dec-01 0:26
Ibrar Ahmad22-Dec-01 0:26 
GeneralRe: Urgent::++ How to make IE popup adds Killer application in VC++ Pin
Nish Nishant22-Dec-01 0:29
sitebuilderNish Nishant22-Dec-01 0:29 
GeneralRe: Urgent::++ How to make IE popup adds Killer application in VC++ Pin
Ibrar Ahmad22-Dec-01 0:40
Ibrar Ahmad22-Dec-01 0:40 
GeneralRe: Urgent::++ How to make IE popup adds Killer application in VC++ Pin
Michael Dunn22-Dec-01 8:37
sitebuilderMichael Dunn22-Dec-01 8:37 
GeneralRe: Urgent::++ How to make IE popup adds Killer application in VC++ Pin
moliate23-Dec-01 14:16
moliate23-Dec-01 14:16 
GeneralRe: Urgent::++ How to make IE popup adds Killer application in VC++ Pin
Ibrar Ahmad25-Dec-01 7:38
Ibrar Ahmad25-Dec-01 7:38 
GeneralRe: Urgent::++ How to make IE popup adds Killer application in VC++ Pin
moliate25-Dec-01 15:08
moliate25-Dec-01 15:08 
First, create an ATL_COM project, using the AppWizard. Add a new ALT object, and change the implementation so it supports <code>IObjectWithSite</code>. The code will look something like this:
<pre>
class ATL_NO_VTABLE CIEHelp :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CIEHelp, &CLSID_IEHelp>,
public IObjectWithSiteImpl<CIEHelp>, // Add this <H>
public IDispatchImpl<IIEHelp, &IID_IIEHelp, &LIBID_KILLPOPUPLib>
{
....

BEGIN_COM_MAP(CIEHelp)
COM_INTERFACE_ENTRY(IIEHelp)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY_IMPL(IObjectWithSite) // ... and this. <H>
END_COM_MAP()
....
</pre>

Then override <code>IObjectWithSite::SetSite</code> and <code>IDispatch::Invoke</code>. SetSite will get you a pointer to the <code>IWebBrowser2</code> interface, and allow you to <code>Advise</code> to get events. Invoke is where the events go. If you find a new window opening, kill it.. You can switch the DISPID parameter and look for <code>DISPID_NEWWINDOW2</code>. When you got an event you can get the IE instance like this:
<pre>
// in IDispatch implementation

switch(dispidMember)
...
case DISPID_NEWWINDOW2:
IWebBrowser2* pIE;
if (pDispParams->cArgs > 0 && pDispParam->rgvarg[0].vt == VT_DISPATCH)
{
//else we have an error <H>
HRESULT hr = CoCreateInstance(CLSID_InternetExplorer,
NULL,
CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2,
(void**)&pIE);
hr = pIE->put_RegisterAsBrowser(TRUE);
hr = pIE->get_Application(pDispParam->rgvarg[0]);
// do stuff, like looking at browser properties, document properties
// and so on, and if the new window is unwanted:
hr = pIE->Quit();
//cleanup
}
break;
</pre>
Finally edit the Registry script to register as a BHO. The rgs file will look something loke this, just edit names and GUIDS:
<pre>
HKCR
{
IEHlprObj.IEHlprObj.1 = s 'IEHlprObj Class'
{
CLSID = s '{CE7C3CF0-4B15-11D1-ABED-709549C10000}'
}
IEHlprObj.IEHlprObj = s 'IEHlprObj Class'
{
CurVer = s 'IEHlprObj.IEHlprObj.1'
}
NoRemove CLSID
{
ForceRemove {CE7C3CF0-4B15-11D1-ABED-709549C10000}
= s 'IEHlprObj Class'
{
ProgID = s 'IEHlprObj.IEHlprObj.1'
VersionIndependentProgID = s 'IEHlprObj.IEHlprObj'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
}
}
}

HKLM
{
SOFTWARE
{
Microsoft
{
Windows
{
CurrentVersion
{
Explorer
{
'Browser Helper Objects'
{
{CE7C3CF0-4B15-11D1-ABED-709549C10000}
}
}
}
}
}
}
}
</pre>
I havn't tested any of the code, but hope it will get you on your way. There are probably lots of tutorials on BHOs if you run into any problems...

/moliate
GeneralAdding strings to list box in sdk Pin
vin21-Dec-01 20:11
vin21-Dec-01 20:11 
GeneralRe: Adding strings to list box in sdk Pin
Michael Dunn21-Dec-01 20:29
sitebuilderMichael Dunn21-Dec-01 20:29 
GeneralProblem: How to go to the URL from the program Pin
21-Dec-01 20:11
suss21-Dec-01 20:11 
GeneralRe: Problem: How to go to the URL from the program Pin
Michael Dunn21-Dec-01 20:36
sitebuilderMichael Dunn21-Dec-01 20:36 
Generalproblem working with PropertySheet.. Pin
anish21-Dec-01 19:18
anish21-Dec-01 19:18 
QuestionHow get current path of the Explorer???? Pin
21-Dec-01 14:44
suss21-Dec-01 14:44 
AnswerRe: How get current path of the Explorer???? Pin
Nish Nishant21-Dec-01 16:56
sitebuilderNish Nishant21-Dec-01 16:56 
Generalfatal error solution Pin
anilaj21-Dec-01 8:53
anilaj21-Dec-01 8:53 
GeneralRe: fatal error solution Pin
Alvaro Mendez21-Dec-01 10:29
Alvaro Mendez21-Dec-01 10:29 
GeneralTransparent text window Pin
21-Dec-01 8:45
suss21-Dec-01 8:45 
GeneralRe: Transparent text window Pin
Christian Graus21-Dec-01 13:33
protectorChristian Graus21-Dec-01 13:33 
GeneralRe: Transparent text window Pin
567890123426-Dec-01 1:08
567890123426-Dec-01 1:08 
GeneralRe: Transparent text window Pin
28-Dec-01 5:57
suss28-Dec-01 5:57 
GeneralDouble-Click Time Pin
Brad Bruce21-Dec-01 7:29
Brad Bruce21-Dec-01 7:29 
GeneralRe: Double-Click Time Pin
Alvaro Mendez21-Dec-01 7:40
Alvaro Mendez21-Dec-01 7:40 
GeneralRe: Double-Click Time Pin
Brad Bruce21-Dec-01 7:49
Brad Bruce21-Dec-01 7:49 
Generalfull path to a shortcut Pin
kasturirawat21-Dec-01 6:55
kasturirawat21-Dec-01 6:55 

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.