![]() |
EmbeddedWB & ShowContextMenu -> EVariantInvalidOpErro
Hallo
Moechte das Kontektmenu des Webbrowsers (TEmbeddedWB) anpassen. Funktioniert soweit, nur dass es beim Schliessen eine Fehlermedlung gibt. (D 6.02) Zitat:
Delphi-Quellcode:
uses
ComObj, MSHTML, ActiveX, ShlObj, IeConst; function TForm1.EmbeddedWB1ShowContextMenu(const dwID: Cardinal; const ppt: PPoint; const pcmdtReserved: IInterface; const pdispReserved: IDispatch): HRESULT; const CContextMenuID = 24641; CGetMimeSubMenuCommandID = 27; CAddMenuExtensionsCommandID = 53; var ShDocLcHandle: THandle; MustFreeLibrary: Boolean; OleCommandTarget: IOleCommandTarget; OleWindow: IOleWindow; WindowHandle: HWND; ParentMenu: HMENU; ChildMenu: HMENU; EncodingSubMenu: OleVariant; ChildMenuItemInfo: MENUITEMINFO; InParam, OutParam: OleVariant; PopupResult: LongBool; begin MustFreeLibrary := False; ShDocLcHandle := GetModuleHandle('SHDOCLC.DLL'); if ShDocLcHandle = 0 then begin ShDocLcHandle := LoadLibrary('SHDOCLC.DLL'); MustFreeLibrary := ShDocLcHandle <> 0; end; OleCommandTarget := pcmdtReserved as IOleCommandTarget; OleWindow := pcmdtReserved as IOleWindow; WindowHandle := 0; if SUCCEEDED(OleWindow.GetWindow(WindowHandle)) then begin ParentMenu := LoadMenu(ShDocLcHandle, MAKEINTRESOURCE(CContextMenuID)); if ParentMenu <> 0 then begin ChildMenu := GetSubMenu(ParentMenu, dwID); if SUCCEEDED(OleCommandTarget.Exec(@CGID_ShellDocView, CGetMimeSubMenuCommandID, OLECMDEXECOPT_DODEFAULT, null, EncodingSubMenu)) then begin FillChar(ChildMenuItemInfo, SizeOf(ChildMenuItemInfo), 0); ChildMenuItemInfo.cbSize := sizeof(MENUITEMINFO); ChildMenuItemInfo.fMask := MIIM_SUBMENU; ChildMenuItemInfo.hSubMenu := HMENU(@EncodingSubMenu); SetMenuItemInfo(ChildMenu, IDM_LANGUAGE, FALSE, ChildMenuItemInfo); InParam := ChildMenu; OutParam := dwID; end; DeleteMenu(ChildMenu, IDM_VIEWSOURCE, MF_BYCOMMAND); DeleteMenu(ChildMenu, IDM_PROPERTIES, MF_BYCOMMAND); PopupResult := TrackPopupMenuEx(ChildMenu, TPM_LEFTALIGN or TPM_TOPALIGN or TPM_RETURNCMD or TPM_RIGHTBUTTON or TPM_HORPOSANIMATION or TPM_VERPOSANIMATION, ppt^.x, ppt^.y, WindowHandle, nil); if PopupResult then SendMessage(WindowHandle, WM_COMMAND, MAKEWPARAM(LOWORD(PopupResult), 0), 0); DestroyMenu(ParentMenu); end; end; OleWindow := nil; OleCommandTarget := nil; if MustFreeLibrary and (ShDocLcHandle <> 0) then FreeLibrary(ShDocLcHandle); Result := S_OK; end; |
Re: EmbeddedWB & ShowContextMenu -> EVariantInvalidOp
Habe underdessen herausgefunden, wo der Fehler entsteht. Und zwar bei OleCommandTarget.Exec(...)
Wenn ich den EncodingSubMenu durch POleVariant(nil)^) ersetze, kommt der Fehler nicht mehr. Wie kann ich aber EncodingSubMenu richtig als Parameter einsetzen?
Delphi-Quellcode:
if SUCCEEDED(OleCommandTarget.Exec(@CGID_ShellDocView,
CGetMimeSubMenuCommandID, OLECMDEXECOPT_DODEFAULT, null, POleVariant(nil)^)) then |
Re: EmbeddedWB & ShowContextMenu -> EVariantInvalidOp
So scheint's nun zu funktionieren:
Delphi-Quellcode:
EmbeddedWB1.ExecWB(CGetMimeSubMenuCommandID, null, EncodingSubMenu);
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:46 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz