StatusBar有多个子栏时,如何确定鼠标在状态栏上双击时是双击哪一个子栏?
由于TStatusPanel并无鼠标事件,所以只好另想办法:
void __fastcall TForm1::StatusBar1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
mousex=X;
}
void __fastcall TForm1::StatusBar1DblClick(TObject *Sender)
{
int i,x;
x=0;
for(i=0;i<StatusBar1->Panels->Count;i++)
{
x+=StatusBar1->Panels->Items[i]->Width;//右边
if(mousex<x)break;
}
//此时的i已经指明了是哪个子栏
switch(i)
{
case 0:
break;
case 1:
break;
//.............
}
}
本文地址:http://com.8s8s.com/it/it5847.htm