Having trouble with IOleCommandTarget interface
-
hi. ive implemented a simple bho object with an IOleCommandTarget interface. i have my Exec method and its called upon a click event of a toolbar button ive added to IE. the method looks like that :
STDMETHODIMP CHelloWorldBHO::Exec(const GUID *pguidCmdGroup,
DWORD nCmdID, DWORD nCmdExecOpt,
VARIANTARG *pvaIn, VARIANTARG *pvaOut)
{HRESULT hr = S\_OK; HWND hwnd; if(m\_spWebBrowser!=NULL) HRESULT hr1 = m\_spWebBrowser->get\_HWND((LONG\_PTR\*)&hwnd); else { MessageBox(NULL, \_T("No Web browser pointer"), \_T("Oops"), 0); } return hr;
}
it always displays the "No Web browser pointer" message. it seems my spWebBrowser variable is null even though ive implemented SetSite method. i know that SetSite is fired when IE loads because im handeling an event of IE and it works fine. my button is registerd in :
HKLM {
NoRemove SOFTWARE
{
NoRemove Microsoft
{
NoRemove 'Internet Explorer'
{
NoRemove Extensions
{
ForceRemove '{5D578929-E74E-46A2-A810-4F33D011DC51}'
= s 'PageCop' {
val 'Default Visible' = s 'yes'
val 'ButtonText' = s 'Inspect page'
val 'CLSID' = s '{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}'
val 'ClsidExtension' =
s '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}'
val 'Icon' = s 'C:\icons\WinXP\search4doc.ico'
val 'HotIcon' = s 'C:\ icons\WinXP\search4doc.ico'
}
}
}
}
}
}my bho is registerd in :
HKLM {
NoRemove SOFTWARE {
NoRemove Microsoft {
NoRemove Windows {
NoRemove CurrentVersion {
NoRemove Explorer {
NoRemove 'Browser Helper Objects' {
ForceRemove '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}' = s 'HelloWorldBHO' {
val 'NoExplorer' = d '1'
}
}
}
}
}
}
}
}anyone knows thats the problem?
-
hi. ive implemented a simple bho object with an IOleCommandTarget interface. i have my Exec method and its called upon a click event of a toolbar button ive added to IE. the method looks like that :
STDMETHODIMP CHelloWorldBHO::Exec(const GUID *pguidCmdGroup,
DWORD nCmdID, DWORD nCmdExecOpt,
VARIANTARG *pvaIn, VARIANTARG *pvaOut)
{HRESULT hr = S\_OK; HWND hwnd; if(m\_spWebBrowser!=NULL) HRESULT hr1 = m\_spWebBrowser->get\_HWND((LONG\_PTR\*)&hwnd); else { MessageBox(NULL, \_T("No Web browser pointer"), \_T("Oops"), 0); } return hr;
}
it always displays the "No Web browser pointer" message. it seems my spWebBrowser variable is null even though ive implemented SetSite method. i know that SetSite is fired when IE loads because im handeling an event of IE and it works fine. my button is registerd in :
HKLM {
NoRemove SOFTWARE
{
NoRemove Microsoft
{
NoRemove 'Internet Explorer'
{
NoRemove Extensions
{
ForceRemove '{5D578929-E74E-46A2-A810-4F33D011DC51}'
= s 'PageCop' {
val 'Default Visible' = s 'yes'
val 'ButtonText' = s 'Inspect page'
val 'CLSID' = s '{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}'
val 'ClsidExtension' =
s '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}'
val 'Icon' = s 'C:\icons\WinXP\search4doc.ico'
val 'HotIcon' = s 'C:\ icons\WinXP\search4doc.ico'
}
}
}
}
}
}my bho is registerd in :
HKLM {
NoRemove SOFTWARE {
NoRemove Microsoft {
NoRemove Windows {
NoRemove CurrentVersion {
NoRemove Explorer {
NoRemove 'Browser Helper Objects' {
ForceRemove '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}' = s 'HelloWorldBHO' {
val 'NoExplorer' = d '1'
}
}
}
}
}
}
}
}anyone knows thats the problem?
Make sure you are assigning m_spWebBrowser in the SetSite function by doing a QueryInterface on the passed in IUnknown pointer.
«_Superman_»
-
Make sure you are assigning m_spWebBrowser in the SetSite function by doing a QueryInterface on the passed in IUnknown pointer.
«_Superman_»
im sure that m_spWebBrowser is assigned because im handeling an event of the browser and their im using m_spWebBrowser .