COM中的PopupMenu弹出问题? ( 积分: 100 )

  • 主题发起人 主题发起人 delphifanshua
  • 开始时间 开始时间
D

delphifanshua

Unregistered / Unconfirmed
GUEST, unregistred user!
编了个IE的浏览栏 Dll,里面有若干个PopupMenu, 如果是直接打开IE,PopupMenu 可以正常弹出(不管有多少个IE窗口).
但是如果在浏览器中点击链接后打开的新窗口中,在这个新窗口中PopupMenu不能弹出(其它控件都正常),而实际上PopupMenu也是存在的,就是不能弹出。
问:何故?如何处理?请各位高手出招!!!!!
 
贴一下代码,干说别人怎么知道问题所在!!
 
用到的PopupMenu跟平时我们做普通应用程序一样,只是连接到其它控件的DrowDown属性做为下拉菜单,别的地方也没进行设置,在COM中就出现上面的问题,如果在普通的应用程序中进行这样的设置是没有问题的.还请做过IE插件的朋友指教
 
大家看一下COM中还有哪些接口需要添加,或者在接口的方法中如何实现才不会出现楼一的问题
TDelphiBandFactory = class(TComObjectFactory)
private
procedure AddKeys;
procedure RemoveKeys;
public
procedure UpdateRegistry(Register: Boolean);
override;
end;


TDelphiBand = class(TComObject, IDeskBand, IPersist, IPersistStreamInit,
IObjectWithSite, IContextMenu, IInputObject)
private
HasFocus: Boolean;
BandID: DWORD;
SavedWndProc: twndmethod;
ParentWnd: HWND;
Site: IInputObjectSite;
IE:IWebBrowser2;
BandForm: TBandform;
public
// IDeskBand methods
function GetBandInfo(dwBandID, dwViewMode: DWORD;
var pdbi: TDeskBandInfo):
HResult;
stdcall;
function ShowDW(fShow: BOOL): HResult;
stdcall;
function CloseDW(dwReserved: DWORD): HResult;
stdcall;
function ResizeBorderDW(var prcBorder: TRect;
punkToolbarSite: IUnknown;
fReserved: BOOL): HResult;
stdcall;
function GetWindow(out wnd: HWnd): HResult;
stdcall;
function ContextSensitiveHelp(fEnterMode: BOOL): HResult;
stdcall;
// IPersistStreamInit methods
function InitNew: HResult;
stdcall;
function GetClassID(out classID: TCLSID): HResult;
stdcall;
function IsDirty: HResult;
stdcall;
function Load(const stm: IStream): HResult;
stdcall;
function Save(const stm: IStream;
fClearDirty: BOOL): HResult;
stdcall;
function GetSizeMax(out cbSize: Largeint): HResult;
stdcall;
// IObjectWithSite methods
function SetSite(const pUnkSite: IUnknown): HResult;
stdcall;
function GetSite(const riid: TIID;
out site: IUnknown): HResult;
stdcall;
// IContextMenu methods
function QueryContextMenu(Menu: HMENU;
indexMenu, idCmdFirst, idCmdLast,
uFlags: UINT): HResult;
stdcall;
function InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult;
stdcall;
function GetCommandString(idCmd, uType: UINT;
pwReserved: PUINT;
pszName:
LPSTR;
cchMax: UINT): HResult;
stdcall;
/// IInputObject methods
function UIActivateIO(fActivate: BOOL;
var lpMsg: TMsg): HResult;
stdcall;
function HasFocusIO: HResult;
stdcall;
function TranslateAcceleratorIO(var lpMsg: TMsg): HResult;
stdcall;

procedure FocusChange(bHasFocus: Boolean);
procedure BandWndProc(var Message: TMessage);
end;


implementation

uses dialogs, Registry;

function TDelphiBand.GetBandInfo(dwBandID, dwViewMode: DWORD;
var pdbi:
TDeskBandInfo):
HResult;
begin

BandId := dwBandID;
if (pdbi.dwMask or DBIM_MINSIZE) <> 0 then

begin

pdbi.ptMinSize.y := Bandform.width;
pdbi.ptMinSize.x := -1;
end;

if (pdbi.dwMask or DBIM_MAXSIZE) <> 0 then

begin

pdbi.ptMaxSize.x := -1;
pdbi.ptMaxSize.y := -1;
end;

if (pdbi.dwMask or DBIM_INTEGRAL) <> 0 then

begin

pdbi.ptIntegral.x := 1;
pdbi.ptIntegral.y := 1;
end;

if (pdbi.dwMask or DBIM_ACTUAL) <> 0 then

begin

pdbi.ptActual.x := Bandform.Height;
pdbi.ptActual.y := bandform.Width;
end;

if (pdbi.dwMask or DBIM_MODEFLAGS) <> 0 then

begin

pdbi.dwModeFlags := DBIMF_VARIABLEHEIGHT;
end;

if (pdbi.dwMask or DBIM_BKCOLOR) <> 0 then

begin

pdbi.dwMask := pdbi.dwMask and (not DBIM_BKCOLOR);
end;

if (Pdbi.dwMask and DBIM_TITLE) = DBIM_TITLE then

begin

FillChar(pdbi.wszTitle, SizeOf(Caption) + 1, ' ');
StringToWideChar(Caption, @pdbi.wszTitle, Length(Caption) + 1);
end;

Result := NOERROR;
end;


function TDelphiBand.QueryContextMenu(Menu: HMENU;
indexMenu, idCmdFirst,
idCmdLast, uFlags: UINT): HResult;
begin

InsertMenu(Menu, indexMenu, MF_STRING or MF_BYPOSITION, idCmdFirst,
'About...');
Result := 1;
end;


function TDelphiBand.InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult;
begin

if (HiWord(Integer(lpici.lpVerb)) <> 0) or (LoWord(lpici.lpVerb) > 0) then

begin

Result := E_FAIL;
Exit;
end;

case LoWord(lpici.lpVerb) of
0: Showmessage('IE面板组件演示程序1.0');
end;

Result := NO_ERROR;
end;


procedure TDelphiBand.BandWndProc(var Message: TMessage);
begin

if (Message.Msg = WM_PARENTNOTIFY) then

begin

Hasfocus := True;
FocusChange(True);
end;

SavedWndProc(Message);
end;


function TDelphiBand.GetWindow(out wnd: HWnd): HResult;
begin

if not Assigned(BandForm) then

begin

BandForm := TBandForm.CreateParented(ParentWnd);
BandForm.IE:=IE;
end;

Wnd := Bandform.Handle;
SavedWndProc := Bandform.WindowProc;
Bandform.WindowProc := BandWndProc;
Result := S_OK;
end;


procedure TDelphiBand.FocusChange(bHasFocus: Boolean);
begin

if (Site <> nil) then

Site.OnFocusChangeIS(Self, bHasFocus);
end;


function TDelphiBand.TranslateAcceleratorIO(var lpMsg: TMsg): HResult;
begin

if (lpMsg.WParam <> VK_TAB) then

begin

TranslateMessage(lpMSg);
DispatchMessage(lpMsg);
Result := S_OK;
end
else

Result := S_FALSE;
end;


function TDelphiBand.HasFocusIO: HResult;
begin

Result := Integer(not HasFocus);
end;


function TDelphiBand.UIActivateIO(fActivate: BOOL;
var lpMsg: TMsg): HResult;
begin

Hasfocus := fActivate;
if HasFocus then

Bandform.SetFocus;
Result := S_OK;
end;


function TDelphiBand.GetCommandString(idCmd, uType: UINT;
pwReserved: PUINT;
pszName: LPSTR;
cchMax: UINT): HResult;
begin

Result := NOERROR;
end;


function TDelphiBand.SetSite(const pUnkSite: IUnknown): HResult;
begin

if Assigned(pUnkSite) then

begin

Site := pUnkSite as IInputObjectSite;
(pUnkSite as IOleWindow).GetWindow(ParentWnd);
(Site as IServiceProvider).QueryService(IWebbrowserApp, IWebbrowser2, IE);

end;

Result := S_OK;
end;


function TDelphiBand.GetSite(const riid: TIID;
out site: IUnknown): HResult;
begin

if Assigned(Site) then

Result := Site.QueryInterface(riid, site)
else

Result := E_FAIL;
end;


function TDelphiBand.GetClassID(out classID: TCLSID): HResult;
begin

classID := CLSID_DelphiBand;
Result := S_OK;
end;


function TDelphiBand.CloseDW(dwReserved: DWORD): HResult;
begin

if BandForm <> nil then

BandForm.Destroy;
Result := S_OK;
end;


function TDelphiBand.ContextSensitiveHelp(fEnterMode: BOOL): HResult;
begin

Result := E_NOTIMPL;
end;


function TDelphiBand.ShowDW(fShow: BOOL): HResult;
begin

Hasfocus := fShow;
FocusChange(fShow);
Result := S_OK;
end;


function TDelphiBand.ResizeBorderDW(var prcBorder: TRect;
punkToolbarSite:
IUnknown;
fReserved: BOOL): HResult;
begin

Result := E_NOTIMPL;
end;


function TDelphiBand.IsDirty: HResult;
begin

Result := S_FALSE;
end;


function TDelphiBand.Load(const stm: IStream): HResult;
begin

Result := S_OK;
end;


function TDelphiBand.Save(const stm: IStream;
fClearDirty: BOOL): HResult;
begin

Result := S_OK;
end;


function TDelphiBand.GetSizeMax(out cbSize: Largeint): HResult;
begin

Result := E_NOTIMPL;
end;


function TDelphiBand.InitNew: HResult;
begin

Result := E_NOTIMPL;
end;


procedure TDelphiBandFactory.UpdateRegistry(Register: Boolean);
begin

inherited UpdateRegistry(Register);
if Register then

AddKeys
else

RemoveKeys;
end;


procedure TDelphiBandFactory.AddKeys;
var
S: string;
begin

S := GUIDToString(CLSID_DelphiBand);
with TRegistry.Createdo

try
DeleteKey('Software/Microsoft/Windows/CurrentVersion/Explorer/Discardable/PostSetup/Component Categories/'
+ VerticalBand + '/Enum');

RootKey := HKEY_CLASSES_ROOT;
if OpenKey('CLSID/' + S, True) then

begin

WriteString('', '&amp;Delphi Band');
CloseKey;
end;

if OpenKey('CLSID/' + S + '/InProcServer32', True) then

begin

WriteString('ThreadingModel', 'Apartment');
CloseKey;
end;

if OpenKey('CLSID/' + S + '/Implemented Categories/' + VerticalBand, True)
then

CloseKey;
finally
Free;
end;

end;


procedure TDelphiBandFactory.RemoveKeys;
var
S: string;
begin

S := GUIDToString(CLSID_DelphiBand);
with TRegistry.Createdo

try
RootKey := HKEY_CLASSES_ROOT;

DeleteKey('CLSID/' + S + '/Implemented Categories/' + VerticalBand);
DeleteKey('CLSID/' + S + '/InProcServer32');
DeleteKey('CLSID/' + S);
Closekey;
finally
Free;
end;

end;
 
自己顶一下,请各路英雄出招啦!!![:)]
 
如果你想花最少的钱学习流行的计算机技术,本人低价提供
计算机专业高清晰 视 频 教 程,所有教程由业内名家讲解,物超所值,
所有光盘4元/张,特快专递全国三天内到货.
联系方式:手 机:1 3 5 76145612(手机联系佳) Q Q:108410943
E-mail:ncncldjjg@126.com
1、Oracle9iOCP(Oracle认证专家DBA)视频教程(23CD)
2、SQL语言、数据挖掘、SQLServer2000视频教程(6CD)
3、计算机网络原理视频教程(4CD)
4、计算机实用组网技术视频教程(3CD)
5、MCSE(微软认证系统工程师)认证视频教程(11CD)
6、windows2003即学即会视频教程(6CD)
7、J2EE Web程序开发定向班/Java就业班视频教程
(java基础jsp核心技术UML设计)(13CD)
8、J2EE基础高级案例分析视频教程(9CD)
9、马士兵J2SE入门与精通(含坦克大战、BBS实例)视频教程(6CD)
10、java语言深入详解视频教程(12CD)
11、java技术从入门到精通视频教程(21CD)
12、javascript全接触视频教程(13CD)
13、各类网站源程序(9CD)
14、unix原理视频教程(3CD)
15、Linux软件开发工程师(C语言)视频教程(4CD)
16、Linux配置、管理、优化实战工程师视频教程(8CD)
17、Linux内核编程视频教程(11CD)
18、C语言详解视频教程(2CD)
19、VC++6.0(MFC)开发技术术详解视频教程(6CD)
20、ASP.NET中文视频教程(3CD)
21、洪恩C#入门多媒体教程(1CD)
22、XML技术视频教程(2CD)
23、操作系统视频教程(3CD)
24、网络技术基础视频教程(2CD)
25、数据结构视频教程(5CD)
26、清华大学计算机专业多媒体教程(数据结构、汇编、编译原理等)(13CD)
27、大学数学[离散数学线性代数概率与数理统计微积分]视频教程(22CD)
28、LearnKey Asp.Net (老外用英语讲课)(13CD)
29、LearnKey Asp.Net Webservice(老外用英语讲课)(5CD)
30、AppDev Asp.Net2.0 UsingC# (老外用英语讲课)(1CD)
31、APPDev .Net Framework(老外用英语讲课)(2CD)
32、林清安pro/e2001(野火版)视频教程(18CD)
33、深圳大学3D设计视频教程(4CD)
34、3DMAX建模视频教程(老外用英语讲课)(6CD)
35、3DMAX纹理与贴图材质灯光视频教程(老外用英语讲课)(5CD)
36、3DMAX格式500个常用模型库(4CD)
37、lightscape基础入门视频教程(2CD)
38、聚光制造(lightscape3.2入门与精通视频教程)(4CD)
39、coreldraw12中文版入门与精通swf格式视频教程(2CD)
 
后退
顶部