我把一个BCB的控件引入到DELPHI中,结果编译怎么也通不过。请问要怎么样导入才能用????
还有一个问题就是,BCB中有一个控件(TrayIcon)能把程序做成像OICQ一样在任务栏显示,请问DELPHI中相应的控件是什么?
还有一个问题就是,BCB中有一个控件(TrayIcon)能把程序做成像OICQ一样在任务栏显示,请问DELPHI中相应的控件是什么?
解决方案 »
- 最近倒腾了一遍Delphi 的不同版本 6.0、7.0、2007、2009,大家使用不同版本有什么体会
- 谢谢
- 每个包:数据长度(4个字节)+数据, 这个怎么实现?
- 出现这个 Incompatible types: 'PAnsiChar' and 'PWideChar' 编译错误该如何处理?
- 如何定位给定主窗体标题的窗口里的子控件?急急急急急!!!!!
- ado+odbc+dbf库的清空dbf库的问题。
- 一高兴,把以前的帖子都结了,很多没有答案的也结了!再问个问题:memo组件的背景图的问题。
- 为什么Delphi会自动截断小数点位数!?help me !!!
- clientDataSet过滤可以根据某一行的索引过滤吗
- 用delphi如何在程序中播放wav文件和rm文件
- 怎样在程序里设置 QRband 的 BandType 属性? 在线等待!!!
- 怎么INSERT FUNCTION这么难用?
interfaceuses
SysUtils, Windows, Messages, Classes, Graphics, Controls, ShellAPI,
Forms;const WM_TOOLTRAYICON = WM_USER+1;
WM_RESETTOOLTIP = WM_USER+2;type
TTrayIcon = class(TComponent)
private
IconData: TNOTIFYICONDATA;
fIcon : TIcon;
fToolTip : String;
fWindowHandle : HWND;
fActive : boolean;
fShowDesigning : Boolean;
{ Events } fOnClick : TNotifyEvent;
fOnDblClick : TNotifyEvent;
fOnRightClick : TMouseEvent; function AddIcon : boolean;
function ModifyIcon : boolean;
function DeleteIcon : boolean; procedure SetActive(Value : boolean);
procedure SetShowDesigning(Value : boolean);
procedure SetIcon(Value : TIcon);
procedure SetToolTip(Value : String);
procedure WndProc(var msg : TMessage); procedure FillDataStructure;
protected
constructor create(aOwner : TComponent); override;
destructor destroy; override;
public
published
property Active : boolean read fActive write SetActive;
property ShowDesigning : boolean read fShowDesigning write SetShowDesigning;
property Icon : TIcon read fIcon write SetIcon;
property ToolTip : string read fTooltip write SetToolTip; property OnClick : TNotifyEvent read FOnClick write FOnClick;
property OnDblClick : TNotifyEvent read FOnDblClick write FOnDblClick;
property OnRightClick : TMouseEvent read FOnRightClick write FonRightClick;
end;procedure Register;implementationprocedure TTrayIcon.SetActive(Value : boolean);
begin
if value <> fActive then begin
fActive := Value;
if not (csdesigning in ComponentState) then begin
if Value then begin
AddIcon;
end else begin
DeleteIcon;
end;
end;
end;
end;procedure TTrayIcon.SetShowDesigning(Value : boolean);
begin
if csdesigning in ComponentState then begin
if value <> fShowDesigning then begin
fShowDesigning := Value;
if Value then begin
AddIcon;
end else begin
DeleteIcon;
end;
end;
end;
end;procedure TTrayIcon.SetIcon(Value : Ticon);
begin
if Value <> fIcon then
begin
fIcon.Assign(value);
ModifyIcon;
end;
end;procedure TTrayIcon.SetToolTip(Value : string);
begin
if length( Value ) > 62 then
Value := copy(Value,1,62);
fToolTip := value;
ModifyIcon;
end;constructor TTrayIcon.Create(aOwner : TComponent);
begin
inherited create(aOwner);
FWindowHandle := AllocateHWnd( WndProc );
FIcon := TIcon.Create;
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;destructor TTrayIcon.destroy;
begin
if (not (csDesigning in ComponentState) and fActive)
or ((csDesigning in ComponentState) and fShowDesigning) then
DeleteIcon; FIcon.Free;
DeAllocateHWnd( FWindowHandle );
inherited destroy;
end;procedure TTrayIcon.FillDataStructure;
begin
with IconData do
begin
cbSize := sizeof(TNOTIFYICONDATA);
wnd := FWindowHandle;
uID := 0; // is not passed in with message so make it 0
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
hIcon := fIcon.Handle;
StrPCopy(szTip,fToolTip);
uCallbackMessage := WM_TOOLTRAYICON;
end;
end;function TTrayIcon.AddIcon : boolean;
begin
FillDataStructure;
result := Shell_NotifyIcon(NIM_ADD,@IconData);
if fToolTip = '' then
PostMessage( fWindowHandle, WM_RESETTOOLTIP,0,0 );
end;function TTrayIcon.ModifyIcon : boolean;
begin
FillDataStructure;
if fActive then
result := Shell_NotifyIcon(NIM_MODIFY,@IconData)
else
result := True;
end;function TTrayIcon.DeleteIcon : boolean;
begin
result := Shell_NotifyIcon(NIM_DELETE,@IconData);
end;procedure TTrayIcon.WndProc(var msg : TMessage);
var MouseCo: TPoint;
begin
with msg do
if (msg = WM_RESETTOOLTIP) then
SetToolTip( fToolTip )
else if (msg = WM_TOOLTRAYICON) then
begin
case lParam of
WM_LBUTTONDBLCLK: if assigned (FOnDblClick) then FOnDblClick
(self);
WM_LBUTTONUP : if assigned(FOnClick)then FOnClick(self);
WM_RBUTTONUP : if assigned (FOnRightClick)then
begin
GetCursorPos(MouseCo);
FOnRightClick(self,mbRight,[],
MouseCo.x, MouseCo.y);
end;
end;
end
else // Handle all messages with the default handler
Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
end;procedure Register;
begin
RegisterComponents('Win32', [TTrayIcon]);
end;end.
有空可以下一个大富翁离线包,很有用。
http://cakk.126.com/