编了IE的浏览栏Dll,里面有若干个PopupMenu,如果是直接打开IE,PopupMenu可以正常弹出(不管有多少个IE窗口),但是如果在 浏览器中 点击链接后打开的新窗口中,在这个新窗口中 PopupMenu 不能弹出(其它控件都正常),而实际上 PopupMenu 也是存在的,就是不能弹出。 问,何故?如何处理?
该问题 ptma(守望者)楼主已提过,其中也没有给出解决的办法,希望高手能给予多多指教!!!
该问题 ptma(守望者)楼主已提过,其中也没有给出解决的办法,希望高手能给予多多指教!!!
菜单的问题我之前也有碰到过 关键在于Menus单元里的
var
PopupList: TPopupList; TPopupList创建了一个隐藏Window来处理菜单消息 在initialization节中初始化了PopupList,所以这个Window只属于创建它的线程 我用了这样一个临时的办法来解决这个问题
1.移除PopupList变量声明和其初始化代码
2.添加函数声明function PopupList: TPopupList;
3.添加和改写如下实现代码
var
PopupList_TlsIndex : Cardinal;procedure Init_PopupList_TlsIndex;
begin
PopupList_TlsIndex := TlsAlloc;
end;procedure Clear_PopupList_TlsIndex;
begin
TlsFree(PopupList_TlsIndex);
end;function PopupList: TPopupList;
begin
Result := TlsGetValue(PopupList_TlsIndex);
if not Assigned(Result) then
begin
Result := TPopupList.Create;
TlsSetValue(PopupList_TlsIndex,Result);
end;
end;procedure TPopupList.Add(Popup: TPopupMenu);
begin
if Count = 0 then FWindow := Classes.AllocateHWnd(MainWndProc);
inherited Add(Popup);
end;procedure TPopupList.Remove(Popup: TPopupMenu);
begin
inherited Remove(Popup);
if Count = 0 then
begin
Classes.DeallocateHWnd(FWindow);
TlsSetValue(PopupList_TlsIndex,nil);
Destroy;
end;
end;initialization
Init_PopupList_TlsIndex;
...
finalization
...
Clear_PopupList_TlsIndex;这个办法其目的是把PopupList放到线程局部存储(TLS)里,经过这样修改后Menu看起来是可以出来了 不过也许也带来了内存泄露的问题,不建议使用。
个人以为 用Delphi开发ActiveX以后,才知道什么叫鸡肋 :D。
从中我得到了启发,已解决此问题.
另外还遇到在浏览栏(DLL)的Edit中就不能响应用户输入Backspace退格键,删除前一个字符.
希望各位兄弟帮帮忙!!!
等此问题解决了,一起给各位结分!
也感谢dacsd(dacsd)的参与!