鼠标放到菜单上面,就产生一个事件,而不需要鼠标点击。要怎样实现呢?

解决方案 »

  1.   

    菜单没有mousemove这个事件,自己写一个mousemove根本就不触发事件啊。
      

  2.   

    哦,不好意思,上班不能用deiphi,所以没留神出馊主意了,原来菜单没有onmousemove呀,不好意思
      

  3.   

    楼上,哪里有xpMenu.pas?请明示。
      

  4.   

    这个xpMenu是个第三方控件,我有源码,刚看了一下,有点晕,没细看你要的话我发给你
      

  5.   

    谢谢楼上的朋友,不知道xpMenu能不能达到我的要求呢?
    [email protected]
      

  6.   

    haha,它是个XP效果的界面控件,跟你的要求好像不一样
    一会发给你
      

  7.   

    procedure TForm1.b1DrawItem(Sender: TObject; ACanvas: TCanvas;
      ARect: TRect; Selected: Boolean);
    var
         leftstr,itemcaption:String;
         lp:Integer;
    begin
         lp:=5;
         itemcaption:=TMenuItem(Sender).Caption;
         leftstr:=Copy(itemcaption,1,pos('&',itemcaption)-1);
         ACanvas.TextRect(ARect,lp,2,leftstr);
         inc(lp,ACanvas.TextWidth(leftstr));
         ACanvas.Font.Style :=ACanvas.Font.Style+[fsUnderline];
         ACanvas.TextRect(ARect,lp,2,copy(itemcaption,pos('&',itemcaption)+1,length(itemcaption)));
         if Selected then
         begin
              //调用要激发的事件。
              ShowMessage('ok');
         end;
    end;
      

  8.   

    记着将菜单的OwnerDraw属性打开。这是我自己试过的。*_*
      

  9.   

    //有一个变态的方法!~~
    //通过Application.OnHint来实现~~
    //鼠标移到菜单项会触发TApplication.OnHint事件~~
    //参考如下代码~~procedure TForm1.ApplicationEvents1Hint(Sender: TObject);
    begin
      Caption := Application.Hint;
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
      I: Integer;
    begin
      for I := 0 to ComponentCount - 1 do
        if Components[I] is TMenuItem then
          TMenuItem(Components[I]).Hint := '#' + Components[I].Name;
    end;
      

  10.   

    wizardqi(男巫) 、zswangII(伴水清清)(一贴不灌,何以灌天下?) :
    你们两人的方法,我都试了,都要先点一下菜单,以后鼠标放在菜单上面,才能触发事件。我需要的是不点一次鼠标,就能触发事件的方法,不知你们能否帮忙?谢谢了。