主题:制作象QQ中的伸缩菜单!!
famahu
[专家分:30] 发布于 2005-08-17 17:11:00
就象QQ一样,当我们点一下我的”好友“的这个菜单时会自动伸或缩。不知道用CB能不能模仿??
如果可以,需要用到那些组件,也可以给我源文件。。。
先谢谢了!!
回复列表 (共3个回复)
沙发
fama [专家分:100] 发布于 2005-08-16 12:16:00
顶一下。。支持楼主!![em1]
板凳
fama [专家分:100] 发布于 2005-08-23 14:34:00
哈哈。。这个效果我实现了。。把ListBox放到Panel中,然后根据Panel的坐标(TOP,Height)等来实现菜单的伸缩的功能。。
具体代码如下:
void __fastcall TForm1::B1Click(TObject *Sender)
{
if(f1==0)
{
f1=1; //伸
P1->Show();
counts = L1->Items->Count;
hh = L1->ItemHeight;
hh = hh*(counts)+5;
P1->Height=hh;
B2->Top = B1->Top+hh+22;
if(f2==1) //2已经伸
{
counts = L2->Items->Count;
hh = L2->ItemHeight;
hh = hh*(counts)+5;
P2->Height=hh;
P2->Top = B2->Top+22;
}
}
else
{
f1=0;
P1->Hide(); //缩
hh = P1->Height;
B2->Top= B2->Top - hh;
if(f2==1)
{
counts = L2->Items->Count;
hh = L2->ItemHeight;
hh = hh*(counts)+5;
P2->Height=hh;
P2->Top = B2->Top+22;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B2Click(TObject *Sender)
{
if(f1==0&&f2==0) // 1已缩 2要伸
{
f2=1;
B2->Top = B1->Top+22;
P2->Top= B2->Top+22;
counts = L2->Items->Count;
hh = L2->ItemHeight;
hh = hh*(counts)+5;
P2->Height=hh;
P2->Show();
}
else if(f1==0&&f2==1) // 1已缩 2要缩
{
f2=0;
B2->Top = B1->Top+22;
P2->Hide();
}
else if(f1==1&&f2==0) // 1已伸 2 要伸
{
f2=1;
B2->Top = P1->Top + P1->Height;
P2->Top = B2->Top +22;
counts = L2->Items->Count;
hh = L2->ItemHeight;
hh = hh*(counts)+5;
P2->Height=hh;
P2->Show();
}
else // 1已伸 2 要缩
{
f2=0;
B2->Top = P1->Top + P1->Height;
P2->Hide();
}
}
3 楼
christ115 [专家分:1580] 发布于 2005-08-23 21:22:00
你们的名字好像。。。
我来回复