|
|
1.1 ! root 1: //--------------------------------------------------------------------------- ! 2: ! 3: #include <vcl.h> ! 4: #pragma hdrstop ! 5: ! 6: #include "UserListFormUnit.h" ! 7: #include "MainFormUnit.h" ! 8: #include "sbbs.h" ! 9: #include "userdat.h" ! 10: //--------------------------------------------------------------------------- ! 11: #pragma package(smart_init) ! 12: #pragma resource "*.dfm" ! 13: TUserListForm *UserListForm; ! 14: //--------------------------------------------------------------------------- ! 15: __fastcall TUserListForm::TUserListForm(TComponent* Owner) ! 16: : TForm(Owner) ! 17: { ! 18: } ! 19: //--------------------------------------------------------------------------- ! 20: void __fastcall TUserListForm::FormShow(TObject *Sender) ! 21: { ! 22: char str[128]; ! 23: int i,last; ! 24: user_t user; ! 25: TListItem* Item; ! 26: ! 27: ColumnToSort=0; ! 28: SortBackwards=false; ! 29: Screen->Cursor=crAppStart; ! 30: ! 31: last=lastuser(&MainForm->cfg); ! 32: ListView->AllocBy=last; ! 33: ! 34: for(i=0;i<last;i++) { ! 35: user.number=i+1; ! 36: if(getuserdat(&MainForm->cfg,&user)!=0) ! 37: continue; ! 38: if(user.misc&DELETED) ! 39: continue; ! 40: Item=ListView->Items->Add(); ! 41: Item->Caption=AnsiString(i+1); ! 42: Item->SubItems->Add(user.alias); ! 43: Item->SubItems->Add(user.name); ! 44: Item->SubItems->Add(user.level); ! 45: Item->SubItems->Add((int)getage(&MainForm->cfg,user.birth)); ! 46: sprintf(str,"%c",user.sex); ! 47: Item->SubItems->Add(str); ! 48: Item->SubItems->Add(user.location); ! 49: Item->SubItems->Add(user.modem); ! 50: Item->SubItems->Add(user.note); ! 51: Item->SubItems->Add(user.comp); ! 52: Item->SubItems->Add(user.phone); ! 53: Item->SubItems->Add(user.netmail); ! 54: Item->SubItems->Add(user.logons); ! 55: Item->SubItems->Add(unixtodstr(&MainForm->cfg,user.firston,str)); ! 56: Item->SubItems->Add(unixtodstr(&MainForm->cfg,user.laston,str)); ! 57: } ! 58: ! 59: Screen->Cursor=crDefault; ! 60: } ! 61: //--------------------------------------------------------------------------- ! 62: void __fastcall TUserListForm::ListViewColumnClick(TObject *Sender, ! 63: TListColumn *Column) ! 64: { ! 65: if(Column->Index == ColumnToSort) ! 66: SortBackwards=!SortBackwards; ! 67: else ! 68: SortBackwards=false; ! 69: ColumnToSort = Column->Index; ! 70: ((TCustomListView *)Sender)->AlphaSort(); ! 71: } ! 72: //--------------------------------------------------------------------------- ! 73: void __fastcall TUserListForm::ListViewCompare(TObject *Sender, ! 74: TListItem *Item1, TListItem *Item2, int Data, int &Compare) ! 75: { ! 76: /* Decimal compare */ ! 77: if (ColumnToSort == 0 || ColumnToSort==3 || ColumnToSort==4 ! 78: || ColumnToSort == 12) { ! 79: int num1, num2; ! 80: ! 81: if(ColumnToSort==0) { ! 82: num1=Item1->Caption.ToIntDef(0); ! 83: num2=Item2->Caption.ToIntDef(0); ! 84: } else { ! 85: int ix = ColumnToSort - 1; ! 86: num1=Item1->SubItems->Strings[ix].ToIntDef(0); ! 87: num2=Item2->SubItems->Strings[ix].ToIntDef(0); ! 88: } ! 89: if(SortBackwards) ! 90: Compare=(num2-num1); ! 91: else ! 92: Compare=(num1-num2); ! 93: } else { ! 94: int ix = ColumnToSort - 1; ! 95: if(SortBackwards) ! 96: Compare = CompareText(Item2->SubItems->Strings[ix] ! 97: ,Item1->SubItems->Strings[ix]); ! 98: else ! 99: Compare = CompareText(Item1->SubItems->Strings[ix] ! 100: ,Item2->SubItems->Strings[ix]); ! 101: } ! 102: } ! 103: //--------------------------------------------------------------------------- ! 104: void __fastcall TUserListForm::FormClose(TObject *Sender, ! 105: TCloseAction &Action) ! 106: { ! 107: ListView->Items->Clear(); ! 108: ! 109: } ! 110: //--------------------------------------------------------------------------- ! 111: ! 112: ! 113: ! 114: ! 115: void __fastcall TUserListForm::EditUserPopupClick(TObject *Sender) ! 116: { ! 117: char str[256]; ! 118: ! 119: if(ListView->Selected==NULL) ! 120: return; ! 121: sprintf(str,"%sUSEREDIT %s %s" ! 122: ,MainForm->cfg.exec_dir,MainForm->cfg.data_dir ! 123: ,ListView->Selected->Caption.c_str()); ! 124: WinExec(str,SW_SHOWNORMAL); ! 125: } ! 126: //--------------------------------------------------------------------------- ! 127:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.