views:

72

answers:

1

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;
 }
+2  A: 

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:

  1. If the button is a CButton, call theButton.ShowWindow(SW_HIDE)
  2. 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.

egrunin
This is also ok. but I dont know how to do it.
karikari
This button resides on the IE toolbar. Which one should I use?
karikari
How can I tell that the button is either a CButton or a plain window?
karikari