SetItemVisible()
来源:互联网 发布:vmware 14 mac os 编辑:程序博客网 时间:2024/05/22 17:33
//-----------------------------------------------------------------------------
/******************************************************************************
*函数名 : SetItemVisible()
*说明 : 设定ListView中的某一行可见
*参数 : lv 需要设定的ListView控件
* Item 需可见的Item行
*返回值 : 无
****************************************************************************/
void __fastcall SetItemVisible(TListView *lv, TListItem *Item)
{
TListItem *BottomItem;
bool DownUp;
try
{
DownUp = lv->TopItem->Index > Item->Index;
BottomItem = lv->GetItemAt(10, lv->Height - 35);
while(1)
{
if(BottomItem == NULL)
{
if(Item->Index >= lv->TopItem->Index) break;
}
else
{
if(Item->Index >= lv->TopItem->Index &&
Item->Index <= BottomItem->Index)
break;
}
SendMessage(lv->Handle, WM_KEYDOWN, DownUp ? VK_PRIOR : VK_NEXT, 0);
BottomItem = lv->GetItemAt(10, lv->Height - 35);
}
}
catch(Exception &e)
{
MessageBox(Application->Handle, e.Message.c_str(),
Application->Title.c_str(), MB_OK | MB_ICONERROR);
}
}
/******************************************************************************
*函数名 : SetItemVisible()
*说明 : 设定ListView中的某一行可见
*参数 : lv 需要设定的ListView控件
* Item 需可见的Item行
*返回值 : 无
****************************************************************************/
void __fastcall SetItemVisible(TListView *lv, TListItem *Item)
{
TListItem *BottomItem;
bool DownUp;
try
{
DownUp = lv->TopItem->Index > Item->Index;
BottomItem = lv->GetItemAt(10, lv->Height - 35);
while(1)
{
if(BottomItem == NULL)
{
if(Item->Index >= lv->TopItem->Index) break;
}
else
{
if(Item->Index >= lv->TopItem->Index &&
Item->Index <= BottomItem->Index)
break;
}
SendMessage(lv->Handle, WM_KEYDOWN, DownUp ? VK_PRIOR : VK_NEXT, 0);
BottomItem = lv->GetItemAt(10, lv->Height - 35);
}
}
catch(Exception &e)
{
MessageBox(Application->Handle, e.Message.c_str(),
Application->Title.c_str(), MB_OK | MB_ICONERROR);
}
}