使用RXLIB中的控件rxtrayicon的问题。(100分)

  • 主题发起人 主题发起人 mycwcgr_new
  • 开始时间 开始时间
M

mycwcgr_new

Unregistered / Unconfirmed
GUEST, unregistred user!
我将rxtrayicon1控件的POPUPMENU属性设为POPUPMENU1控件,将TForm1.RxTrayIcon1Click
事件定义为popupmenu1.Popup(x,y),这样左键与右键能调出POPUPMENU1,不幸的是当我点击
屏幕其它位置时,用右键调出的POPUPMENU1能自动消失,而用左键调出的POPUPMENU1菜单却
常常不能消失(请多试几次,比如按下面的顺序:先点FORM!,再左点trayicon图标打开菜单
,再点屏幕其它位置时,POPUPMENU1菜单不能消失)。
object Form1: TForm1
Left = 345
Top = 227
Width = 357
Height = 236
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = False
PixelsPerInch = 106
TextHeight = 13
object PopupMenu1: TPopupMenu
Left = 160
Top = 104
object a11: TMenuItem
Caption = 'a1'
object b11: TMenuItem
Caption = 'b1'
end
object b21: TMenuItem
Caption = 'b2'
end
end
object a21: TMenuItem
Caption = 'a2'
end
object a31: TMenuItem
Caption = 'a3'
end
end
object RxTrayIcon1: TRxTrayIcon
Icon.Data = {
0000010001002020100000000000E80200001600000028000000200000004000
0000010004000000000080020000000000000000000000000000000000000000
0000000080000080000000808000800000008000800080800000C0C0C0008080
80000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000BB000000000BB0000000000000000000BB000000000BB00000000000000
0000BBBB0000000BBBB0000000000000000BBBBB0000000BBBBB000000000000
00BBBBBB0000000BBBBBB0000000000000BBBBBBB00000BBBBBBB00000000000
0BBBBBBBB00000BBBBBBBB00000000000BBBBBBBB00000BBBBBBBB0000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000BBB0000000000000000000
000000000BBBBB000000000000000000000000000BBBBB000000000000000000
00000000BBBBBBB0000000000000000000000000BBBBBBB00000000000000000
00000000BBBBBBB000000000000000000000000BBBBBBBBB0000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000FFFF
FFFF800000037FFFFFFD6000000D5FFFFFF55FE00FF55F8003F55F0001F55E00
00F55C0000755800003558000035500000155000001550000015500100155003
80155001001550000015500000155800003558000035580000355C0000755E00
00F55F0001F55F8003F55FE00FF55FFFFFF56000000D7FFFFFFD80000003}
PopupMenu = PopupMenu1
OnClick = RxTrayIcon1Click
Left = 56
Top = 24
end


unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, RXShell;
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
a11: TMenuItem;
a21: TMenuItem;
RxTrayIcon1: TRxTrayIcon;
a31: TMenuItem;
b11: TMenuItem;
b21: TMenuItem;
procedure RxTrayIcon1Click(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.RxTrayIcon1Click(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
popupmenu1.Popup(x,y);
end;

end.


 
换个控件
trayicon
 
你将RXShell.pas中的DoClick过程改为如下.我测试通过.
procedure TRxTrayIcon.DoClick(Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if (Button = mbRight) and CheckMenuPopup(X, Y) then
Exit;
if (Button = mbleft) and CheckMenuPopup(X, Y) then
if Assigned(FOnClick) then
FOnClick(Self, Button, Shift, X, Y);
end;
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
755
import
I
I
回复
0
查看
512
import
I
I
回复
0
查看
534
import
I
后退
顶部