请问怎样才能移动PAGECONTROL上的标签页呀??
本帖最后由 MYMGrub 于 2009-08-27 11:55:35 编辑 如题,怎样才能移动PAGECONTROL上的标签页?就象BC上那个多页似的,能通过鼠标移动每一页,并且能改变页之间的顺序,找了好久也没找到头绪呀...最好能详细一些。先谢谢各位了啊:)
[解决办法]
分别在PageControl的OnMouseDown, OnDragDrop, OnDragOver事件中添加以下代码:
void __fastcall TForm1::PageControl1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
TPageControl *pgc = dynamic_cast <TPageControl *> (Sender);
pgc->BeginDrag(false);
}
//---------------------------------------
void __fastcall TForm1::PageControl1DragDrop(TObject *Sender,
TObject *Source, int X, int Y)
{
RECT TabRect;
TPageControl *pgc = dynamic_cast <TPageControl *> (Sender);
if (Sender->ClassNameIs("TPageControl"))
{
for (int j=0; j < PageControl1->PageCount; j++)
{
pgc->Perform(TCM_GETITEMRECT, j, LPARAM(&TabRect));
if (PtInRect(TabRect, TPoint(X, Y)))
{
if (pgc->ActivePageIndex != j)
{
pgc->ActivePage->PageIndex = j;
break;
}
}
}
}
}
//---------------------------------------
void __fastcall TForm1::PageControl1DragOver(TObject *Sender,
TObject *Source, int X, int Y, TDragState State, bool &Accept)
{
if (Sender->ClassNameIs("TPageControl"))
Accept = true;
}