: TStringList *OldDrives;
: OldDrives = new TStringList;
: OldDrives->Assign(DriveBox->Items); // Remember old drive list
: // Show the connection dialog
: if (WNetConnectionDialog(Application->Handle,RESOURCETYPE_DISK) == NO_ERROR){
: DriveBox->TextCase = tcLowerCase; // Refresh the drive list box
: for (int i=0;DriveBox->Items->Count - 1;i++){
: // AnsiString S=(TString*)DriveBox->Items[i];
: if (OldDrives->IndexOf(DriveBox->Items[i]) == -1){ // Find new Drive letter
: DriveBox->ItemIndex = i; // Updates the drive list box to new drive // letter
: DriveBox->Drive = DriveBox->Text[1]; // Cascades the update to connected directory // lists, etc
: }
: }
: DriveBox->SetFocus();
: }
: 위에 것은 네트웍드라이브에 연결시키는 소스입니다.
: 그런데 중간에 OldDrives->IndexOf(DriveBox->Items[i] 부분에서
: 할당이 잘못됐다고 에러가 발생합니다.
: 어떻게 해결해야 할지 모르겠어요..
: 가르쳐 주세요
: 그럼 안녕히 계세요.
: 건강하시고요.
임펠리테리입니다.
소스 내에 나오는 DriveBox는, 아마도 콤보박스에서 상속을 받은, 디스크 드라이브들의
리스트를 가지고 있는 서드파티 컴퍼넌트인 모양이군요.
사실 그 컴퍼넌트에서 어떻게 구현했는지에 따라 답변이 달라질 수도 있습니다만,
콤보박스에서 상속을 받아서 콤보박스의 Items 프로퍼티를 그대로 가지고 있다고
가정하고 답변을 하도록 하죠.
DriveBox->Items[i] 는 다음과 같이 수정해야 합니다.
DriveBox->Items->Strings[i]
이렇게 하면 해당 i번째의 문자열을 받아올 수 있습니다.
그럼 도움되시길...
|