Add button to Internet Explorer toolbar during run time
I am currently create a simple additional button to my Internet Explorer 7, toolbar. The button works. I am using Visual C++.
But now, I would like to create a to create a button during my Internet Explorer is running. Means, on certain condition, my program (a dll registered with regsvr32) will add a button to the toolbar. and after certain condition, the button also can be disappeared.
How can I achieve this?
update:
I tried using this line:
ShowWindow(hWndButton, SW_HIDE);
It hides my Internet Explorer browser. Under Task Manager, it is still running. How to make it hide only the button object?
edit:
I want to modify this code..
STDMETHODIMP CButtonDemoBHO::Exec(const GUID*, DWORD nCmdID, DWORD d, VARIANTARG*, VARIANTARG* pvaOut){
ATLTRACE("CButtonDemoBHO::Exec\n");
switch (nCmdID){
case BUTTON_PRESSED:
MessageBox(m_hWnd, L"You have pressed the button", L"Button Pressed", MB_OK);
<------- I would like to hide the button here.
break;
case MENU_ITEM_SELECT:
MessageBox(m_hWnd, L"You have 开发者_如何学编程simulated a button press with the menu ", L"Menu Pressed", MB_OK);
break;
}
return S_OK;
}
Can you add the button always (as you are now), but hide it/unhide it when you want it seen?
Edited to add:
To hide the button, you need to use ShowWindow()
. Here are two ways:
- If the button is a
CButton
, calltheButton.ShowWindow(SW_HIDE)
- If the button is a plain window, call
ShowWindow(hWndButton, SW_HIDE)
Edited again:
I found the source code you're trying to modify: forum-assist.
Basically, whichever class defines the button, or knows how to find it (probably RebarHandler.cpp
) is where you should add methods to show and hide the button. Then you have to call that from CButtonDemoBHO::Exec()
.
I can't tell you how to get from CButtonDemoBHO
to CRebarHandler
without analyzing the whole project.
精彩评论