我下载了Express的SideBar控件,类似QQ界面的,用过的进来看看,一看就知.(100分)

  • 主题发起人 主题发起人 芭芭拉
  • 开始时间 开始时间

芭芭拉

Unregistered / Unconfirmed
GUEST, unregistred user!
我下载了Express的SideBar控件,类似QQ界面的,用过的进来看看,一看就知.
可以增加面板上的控钮(如我的好友),可如何在程序动态增加这个面板上具体的数据(如QQ号码)
 
一段代码

--面板基础类
unit MenuPlugFrm;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,DB;

type
TMenuPlugBase = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
CtlHwnd:HWND;
container:integer;
FDisplayName: String;
FPicture: TBitMap;
FInData: variant;
procedure SetInData(const Value: variant);
protected
DataSet:TDataSet;
procedure BuildMenu;virtual;
procedure DoClick(p:pointer);
public
{ Public declarations }
procedure WNDPROC(var Message:TMessage);override;
published
property DisplyName:String Read FDisplayName write FDisplayName;
property Picture:TBitMap Read FPicture write FPicture;
property InData:variant read FInData write SetInData;
end;

implementation

{$R *.dfm}

procedure TMenuPlugBase.BuildMenu;
begin

end;

procedure TMenuPlugBase.DoClick(p: pointer);
begin
SendMessage(CtlHwnd,wm_user+$401,integer(p),0);
end;

procedure TMenuPlugBase.FormCreate(Sender: TObject);
begin
SendMessage(Application.MainForm.Handle,wm_user+$301,handle,0);
end;

procedure TMenuPlugBase.SetInData(const Value: variant);
begin
FInData := Value;
if FinData[0]=1 then
begin
ConTainer:=FInData[1];
DataSet:=TDataSet(integer(FInData[2]));
BuildMenu;
parent:=TWinControl(Container);
Show;
end;
end;

procedure TMenuPlugBase.WNDPROC(var Message: TMessage);
begin
try
With Message do
case msg of
wm_user+$4: CtlHwnd:=wparam;
end;
except
end;
inherited;
end;

end.


--Outlook式样面板
unit OutLookMnu;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MenuPlugFrm, ExtCtrls, dxsbar,DB, ImgList, ActnList,Menus;

type
TOutLookMenuFmt = class(TMenuPlugBase)
dxSideBar1: TdxSideBar;
ImageList1: TImageList;
procedure dxSideBar1ItemClick(Sender: TObject; Item: TdxSideBarItem);
procedure Action1Execute(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
ActionList1:TActionlist;
public
{ Public declarations }
procedure BuildMenu;override;
end;

var
OutLookMenuFmt:TOutLookMenuFmt;

implementation

{$R *.dfm}

{ TOutLookMenuFmt }

procedure TOutLookMenuFmt.BuildMenu;
var
p:TdxSidegroup;
v:TDxSidebarItem;
A:TAction;
j:integer;
ic:Ticon;
stream:TMemoryStream;
begin
ActionList1:=TActionlist.Create(Application.MainForm);
DataSet.First;
p:=nil;
j:=length(DataSet.Fieldbyname('App_id').asstring);
while not DataSet.Eof do
begin
if length(DataSet.Fieldbyname('App_id').asstring)=j then
begin
p:=dxSideBar1.Groups.Add;
p.Caption:=DataSet.Fieldbyname('App_nm').asstring;
p.IconType:=dxsgLargeIcon;
end;
if (p<>nil)and((DataSet.FieldByName('app_rg').asinteger and $1)>0) then
if length(DataSet.Fieldbyname('App_id').asstring)=j+2 then
begin
v:=p.Items.Add;
stream:=TMemoryStream.Create;
TBlobField(DataSet.FieldByName('app_ic')).SaveToStream(stream);
if stream.Size>0 then
begin
ic:=Ticon.Create;
Stream.Seek(soFromBeginning,0);
ic.LoadFromStream(stream);
v.LargeImage:=imagelist1.AddIcon(ic);
ic.Free;
end else
v.LargeImage:=0; //Default Image
stream.Free;
A:=TAction.Create(Application.MainForm);
A.ActionList:=ActionList1;
A.Tag:=integer(DataSet.getbookmark);
A.OnExecute:=Action1Execute;
A.ShortCut:=DataSet.Fieldbyname('App_Sh').asinteger;
if A.ShortCut<>0 then
v.Caption:=DataSet.Fieldbyname('App_Nm').asstring+#$C#$A'('+shortcuttotext(a.ShortCut)+')'
else
v.Caption:=DataSet.Fieldbyname('App_Nm').asstring;
v.ItemObject:=DataSet.getbookmark;
v.Hint:=v.Caption;
end;
DataSet.next;
end;
end;

procedure TOutLookMenuFmt.dxSideBar1ItemClick(Sender: TObject;
Item: TdxSideBarItem);
begin
inherited;
doClick(Item.ItemObject);
end;

procedure TOutLookMenuFmt.Action1Execute(Sender: TObject);
begin
inherited;
doClick(Pointer(TAction(Sender).tag));
end;

procedure TOutLookMenuFmt.FormDestroy(Sender: TObject);
begin
inherited;
if ActionList1<>nil then
begin
while ActionList1.ActionCount>0 do
Actionlist1.Actions[0].Free;
FreeandNil(ActionList1);
end;
end;

initialization
OutLookMenuFmt:=TOutLookMenuFmt.Create(Application.MainForm);
OutLookMenuFmt.Name:='TempMenu';
finalization
OutLookMenuFmt.Free;
end.
 
到下面去看看我的源代码就成了
很全地

http://www.delphibbs.com/delphibbs/dispq.asp?lid=1365676
 
接受答案了.
 

Similar threads

后退
顶部