您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Delphi >> 怎样用自定义的弹出菜单替换控件的弹出菜单

怎样用自定义的弹出菜单替换控件的弹出菜单

来源:网络整理     时间:2016/8/26 2:15:18     关键词:

关于网友提出的“ 怎样用自定义的弹出菜单替换控件的弹出菜单”问题疑问,本网通过在网上对“ 怎样用自定义的弹出菜单替换控件的弹出菜单”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 怎样用自定义的弹出菜单替换控件的弹出菜单
描述:


最近在考研网上遇到一个比较谈得来得朋友,要我帮他做个考研倒记时的东东。
用到了flash.ocx控件(c:\winnt\system32\macromed\flash.ocx)
但是安装了它之后,右键弹出的菜单却是它本身的菜单。
解决办法如下:
1、建立自己的popupmenu1弹出式菜单;
2、加入 Additional中的ApplicationEvents到窗体;
type
  TForm1 = class(TForm)
{....................}
  procedure ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
  private
  
  public
  
  end;
type
  TMyFlash = class(TShockwaveFlash)
  public
    procedure WMRBUTTONDOWN(var msg: TMsg); message WM_RBUTTONDOWN;
  end;
{//实现代码}
procedure TMyFlash.WMRBUTTONDOWN(var msg: TMsg);
var
  P: Tpoint;
begin
  if popupmenu <> nil then{ //加入自己的事件}
  begin
    GetCursorPos(p); {//获得当前鼠标位置}
    popupmenu.Popup(p.x, p.y); {//弹出菜单}
  end;
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
  if Msg.message = WM_RBUTTONDOWN then
  begin
   {//如果去掉下面这行就是屏蔽右键菜单,现在为自定义右键菜单}
    popupmenu1.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
    Handled := True;
  end;
end;
但是小弟遇到了如下问题:
将flash的窗口设置成client型,要实现鼠标在flash的窗口上拖动则窗体移动。就是说点窗体任何部位都能拖动窗体。
以前做了纯粹的form界面的拖动,代码如下:
申明:
type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure wmnchittest(var msg: twmnchittest); message wm_nchittest;
  public
    { Public declarations }
  end;
实现:
procedure TForm1.wmnchittest(var msg: twmnchittest);
begin
  inherited;
  if (HTclient= msg.result) then msg.result := htcaption;
end;


解决方案1:

你再添一个过程就可以了:
type
  TMyFlash = class(TShockwaveFlash)
  private
    procedure WMLButtonDown(var msg: TWMLButtonDown); message WM_LBUTTONDOWN;
    procedure WMRButtonDown(var msg: TWMRButtonDown); message WM_RBUTTONDOWN;
  end;
...
{ TMyFlash }
procedure TMyFlash.WMLButtonDown(var msg: TWMLButtonDown);
begin
  ReleaseCapture;
  Form1.Perform(WM_SYSCOMMAND, $F012, 0)
end;
procedure TMyFlash.WMRButtonDown(var msg: TWMRButtonDown);
var
  p: TPoint;
begin
  GetCursorPos(p); {//获得当前鼠标位置}
  Form1.PopupMenu1.Popup(p.X, p.Y); {//弹出菜单}
end;


以上介绍了“ 怎样用自定义的弹出菜单替换控件的弹出菜单”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3594808.html

相关图片

相关文章