Click here to Skip to main content
15,906,455 members
Home / Discussions / C#
   

C#

 
GeneralStrange Question.. Pin
hammackj14-Oct-03 18:32
hammackj14-Oct-03 18:32 
GeneralRe: Strange Question.. Pin
Randhir Sinha14-Oct-03 19:03
Randhir Sinha14-Oct-03 19:03 
GeneralRe: Strange Question.. Pin
Corinna John14-Oct-03 19:52
Corinna John14-Oct-03 19:52 
GeneralRe: Strange Question.. Pin
hammackj15-Oct-03 3:22
hammackj15-Oct-03 3:22 
GeneralRe: Strange Question.. Pin
Randhir Sinha15-Oct-03 3:51
Randhir Sinha15-Oct-03 3:51 
GeneralRe: Strange Question.. Pin
hammackj15-Oct-03 4:02
hammackj15-Oct-03 4:02 
GeneralRe: Strange Question.. Pin
Corinna John15-Oct-03 7:23
Corinna John15-Oct-03 7:23 
GeneralIDocHostUIHandler and WebBrowser Context Menu Pin
J. Dunlap14-Oct-03 18:14
J. Dunlap14-Oct-03 18:14 
I tried to replace the default context menu of my WebBrowser control using the IDocHostUIHandler's ShowContextMenu() method. It worked pretty well, except that whenever I click on my context menu, it does the next command on the IE context menu (things like Save As, Print, View Source, etc). It does my menu command action first, but then it does the next command on its menu, even though its menu is never shown.

The docs say about this method:
"You can prevent Internet Explorer from displaying its default menu by returning S_OK from this method. Returning some other value, like S_FALSE or E_NOTIMPL, allows Internet Explorer to go ahead with its default shortcut menu behavior.

If you return S_OK from this method and nothing more, you can prevent any right-click behavior by the WebBrowser control."


Here's my code:

C#
void IDocHostUIHandler.ShowContextMenu(uint dwID, 
               ref MsHtmHstInterop.tagPOINT ppt, 
               object pcmdtReserved, 
               object pdispReserved)
{
    ContextMenu cm=null;
 
    <font color="green">//The docs say it should be (0x1<<(int)dwID),
    //but this isn't true here, and my problem still exists
    //either way</font>
    switch((ContextMenuCode)dwID)
    {
        case ContextMenuCode.Image:
            <font color="green">//a dummy image menu for test purposes</font>
            cm = new ContextMenu(new MenuItem[]{
                new MenuItem("Image",new EventHandler(this.MenuClick))}
                );
            break;
        default:
            <font color="green">//a dummy default menu for test purposes</font>
            cm = new ContextMenu(new MenuItem[]{
                new MenuItem("Default",new EventHandler(this.MenuClick))}
                );
            break;
    }
 
    <font color="green">//show the menu</font>
    cm.Show(webBrowser,((Control)webBrowser).PointToClient(new Point(ppt.x,ppt.y)));
    
    //<font color="green">The .NET Framework should return S_OK automatically,
    //but I tried these just in case (might be silly of me? :~ ) :</font>
    //System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(0);
    //throw new System.Runtime.InteropServices.COMException("S_OK - No custom handling.",0);
}


Anyhow, this really puzzles me - why does this happen?? Confused | :confused:


"It is impossible to rightly govern the world without God and the Bible." -- George Washington

FLUID UI Toolkit | FloodFill in C# & GDI+







GeneralSolved! Pin
J. Dunlap14-Oct-03 18:41
J. Dunlap14-Oct-03 18:41 
GeneralRe: Solved! Pin
w1424319-Jul-04 20:32
w1424319-Jul-04 20:32 
GeneralImageList in a TreeView -- Pin
Blaise L'amort14-Oct-03 13:02
Blaise L'amort14-Oct-03 13:02 
QuestionBinaryReader/Writer at same time? Pin
Joe Woodbury14-Oct-03 11:12
professionalJoe Woodbury14-Oct-03 11:12 
AnswerRe: BinaryReader/Writer at same time? Pin
Corinna John14-Oct-03 19:55
Corinna John14-Oct-03 19:55 
GeneralRe: BinaryReader/Writer at same time? Pin
Joe Woodbury15-Oct-03 4:26
professionalJoe Woodbury15-Oct-03 4:26 
GeneralI used to use ResourceStrings Pin
Anders Molin14-Oct-03 9:46
professionalAnders Molin14-Oct-03 9:46 
GeneralRe: I used to use ResourceStrings Pin
Ranjan Banerji14-Oct-03 10:19
Ranjan Banerji14-Oct-03 10:19 
GeneralRe: I used to use ResourceStrings Pin
rod termaat15-Oct-03 5:11
rod termaat15-Oct-03 5:11 
GeneralEventHandler Pin
Matias Szulman14-Oct-03 9:31
Matias Szulman14-Oct-03 9:31 
GeneralRe: EventHandler Pin
Meysam Mahfouzi14-Oct-03 17:52
Meysam Mahfouzi14-Oct-03 17:52 
QuestionWhich XML format should I use? Pin
Alvaro Mendez14-Oct-03 9:23
Alvaro Mendez14-Oct-03 9:23 
AnswerRe: Which XML format should I use? Pin
Ryan_Roberts14-Oct-03 9:48
Ryan_Roberts14-Oct-03 9:48 
GeneralRe: Which XML format should I use? Pin
David Stone14-Oct-03 13:16
sitebuilderDavid Stone14-Oct-03 13:16 
AnswerRe: Which XML format should I use? Pin
Nick Parker15-Oct-03 15:46
protectorNick Parker15-Oct-03 15:46 
GeneralMasking input in a datagrid Pin
Wjousts14-Oct-03 7:23
Wjousts14-Oct-03 7:23 
GeneralRe: Masking input in a datagrid Pin
Wjousts15-Oct-03 5:52
Wjousts15-Oct-03 5:52 

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.