If you want to show your custom popup menu in your TWebBrowser component I really recommend to you to download a EmbeddedWB component by bsalsa productions ( <http://www.bsalsa.com/product.html> ).
It is all the same TWebBowser only more user friendly, with more events and methods, added functionality.
By the way, it is all free.
With this EmbeddedWB you can easily make your own popup menu, even diffrent pop-ups for different selected items in web browser.
So for example, make a default popup when no selection exists, and one custom popup for selected text.
If you have EmbeddedWB installed and have one on your form, look for OnShowContextMenu event.
Then your custom popup can be shown with this example code:
function TForm.WebShowContextMenu(const dwID: Cardinal;
const ppt: PPoint; const pcmdtReserved: IInterface;
const pdispReserved: IDispatch): HRESULT;
begin
//When we want to show our custum menu
if (dwID = 4) //any text selection menu is about to show
then begin
TextPopup.Popup(ppt.X,ppt.Y);
end
else
if Assigned(MyPopup) //if our popup is created
then begin
MyPopup.Popup(ppt.X, ppt.Y);
Result := S_OK; //don't show WB popup
end
else Result := S_FALSE; //else show IE Popup
end;
IE has several different menus for images, text and so on. You can check what menu is about to show by
checking dwID:
CONTEXT_MENU_DEFAULT = 0;
CONTEXT_MENU_IMAGE = 1;
CONTEXT_MENU_CONTROL = 2;
CONTEXT_MENU_TABLE = 3;
CONTEXT_MENU_TEXTSELECT = 4;
CONTEXT_MENU_ANCHOR = 5;
CONTEXT_MENU_UNKNOWN = 6;
CONTEXT_MENU_IMGDYNSRC = 7;
CONTEXT_MENU_IMGART = 8;
CONTEXT_MENU_DEBUG = 9;
More info can be found here:
http://msdn2.microsoft.com/en-us/library/aa753264.aspx
http://www.bsalsa.com/ewb_on_show_context.html
Hope, this was helpful.