🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Renan Fri, 28 Jul 2006 02:05
List Files
#3197
Author: Renan
Date: Fri, 28 Jul 2006 02:05
9 lines
1037 bytes
Hello

I think this question is an API (but I'm not sure).
I want to select some files(in a treeview, for example) and rename 
them. I know how to rename, but I don't know how to select them. I want to select 30 files, and put each file in a separated editbox. 
All files are going to be in the same directory.

Renan
Re: List Files
#3198
Author: Thorsten Kettner
Date: Fri, 28 Jul 2006 07:12
24 lines
1732 bytes
"Renan" <gulbrrs@gmail.com> wrote:
>I think this question is an API (but I'm not sure).
>I want to select some files(in a treeview, for example) and 
>rename them. I know how to rename, but I don't know how to 
>select them. I want to select 30 files, and put each file in a 
>separated editbox. 
>All files are going to be in the same directory.

You can use VCL for that: Place a TOpenDialog on your form, set
its Option ofAllowMultiSelect, place a TStringGrid on the form, 
too and do as follows:

  if(OpenDialog1->Execute())
  {
    StringGrid1->RowCount = OpenDialog1->Files->Count;
    StringGrid1->Cols[0] = OpenDialog1->Files;
  }

Then let the user rename the files. (Or do you want to rename 
them by an algorithm? Then you wouldn't even need the grid).

If you want to display filenames without paths in the grid, look
for ExtractFileName().
Re: List Files
#3200
Author: Bob Gonder
Date: Fri, 28 Jul 2006 09:09
7 lines
1050 bytes
Renan wrote:

>I think this question is an API (but I'm not sure).

It could be.
You could use the VCL like Thorsten suggested, or Windows'
GetOpenFileName().
Re: List Files
#3208
Author: Renan
Date: Sat, 29 Jul 2006 21:30
43 lines
2092 bytes
Yes is going to be an algorithm. For example:

1 - Series S01E03 Pilot DVDRip.XviD-WAT.avi

Series is the name of the serie
S01 means Season 01
E03 episode 3
Pilot  is the name of the episode
DVDRip.XviD-WAT - format of video and person who did it.

all files changes the name of episodes and number of episode.
Some files are not from the same person.
Sometimes S01 became S02... S020.
My algorithm have to do like this

Series S01E01 Pilot1 DVDRip.XviD-WAT.avi
Series S01E01 Pilot1 DVDRip.XviD-WAT.srt
Series S01E02 Pilot2 DVDRip.XviD-WAT.avi
Series S01E02 Pilot2 DVDRip.XviD-WAT.srt
Series S01E03 Pilot3 DVDRip.XviD-WAT.avi
Series S01E03 Pilot3 DVDRip.XviD-WAT.srt

...

Thanks
   Renan

>You can use VCL for that: Place a TOpenDialog on your form, set
>its Option ofAllowMultiSelect, place a TStringGrid on the form, 
>too and do as follows:
>
>  if(OpenDialog1->Execute())
>  {
>    StringGrid1->RowCount = OpenDialog1->Files->Count;
>    StringGrid1->Cols[0] = OpenDialog1->Files;
>  }
>
>Then let the user rename the files. (Or do you want to rename 
>them by an algorithm? Then you wouldn't even need the grid).
>
>If you want to display filenames without paths in the grid, look
>for ExtractFileName().
Re: List Files
#3215
Author: Renan
Date: Mon, 31 Jul 2006 13:51
35 lines
1952 bytes

>  if(OpenDialog1->Execute())
>  {
>    StringGrid1->RowCount = OpenDialog1->Files->Count;
>    StringGrid1->Cols[0] = OpenDialog1->Files;
>  }
>
>Then let the user rename the files. (Or do you want to rename 
>them by an algorithm? Then you wouldn't even need the grid).
>
>If you want to display filenames without paths in the grid, look
>for ExtractFileName().

        if(OpenDialog1->Execute())
        {
        Edit1->Text = ExtractFileName(OpenDialog1->FileName);
        Edit2->Text = ExtractFileName(OpenDialog1->FileName);
        }

With this code, even if I select 2 diferent files, Edit1 and Edit2 
gets the same filename. What can I do to select 2 files?

        if(OpenDialog1->Execute())
        {
        Edit1->Text = ExtractFileName(OpenDialog1->Files);
        Edit2->Text = ExtractFileName(OpenDialog1->Files);
        }

With this code, I get an error msg:

[C++ Error] Unit1.cpp(32): E2034 Cannot convert 'TStrings * const' to 'AnsiString'
[C++ Error] Unit1.cpp(32): E2342 Type mismatch in parameter 'FileName' (wanted 'const AnsiString', got 'TStrings *')

What's wrong?
Re: List Files
#3217
Author: Thorsten Kettner
Date: Tue, 01 Aug 2006 06:56
37 lines
2451 bytes
"Renan" <gulbrrs@gmail.com> wrote:
>        Edit1->Text = ExtractFileName(OpenDialog1->FileName);
>        Edit2->Text = ExtractFileName(OpenDialog1->FileName);
>
>With this code, even if I select 2 diferent files, Edit1 and 
>Edit2 gets the same filename. What can I do to select 2 files?

Of course. Why should OpenDialog1->FileName suddenly contain 
another value than before? Use FileName only if the dialog is 
for picking one single file.

>
>        Edit1->Text = ExtractFileName(OpenDialog1->Files);
>        Edit2->Text = ExtractFileName(OpenDialog1->Files);
>With this code, I get an error msg:
>
>[C++ Error] Unit1.cpp(32): E2034 Cannot convert 'TStrings * 
>const' to 'AnsiString'

Yes. OpenDialog1->Files is a string list whereas ExtractFileName
expects a string. Use TStrings::Strings to access the single 
strings contained in the string list:

  Edit1->Text = ExtractFileName(OpenDialog1->Files->Strings[0]);
  Edit2->Text = ExtractFileName(OpenDialog1->Files->Strings[1]);

This said, I wonder what the edit boxes are for, anyhow. You 
said the renaming would be done by an algorithm. So why not do 
the conversion silently by code? Why put the file names into 
edit boxes?

Even if the renaming would not be done automatically, but by
user input, I would not recommend TEdit. Who knows how many 
files the user will select. You would have to create a lot of
edit boxes - one per file. If you need a series of edit boxes, 
use TStringGrid instead.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads