1 (edited by AD1408 2021-11-27 21:08:00)

Topic: (UNRESOLVED) Select directory and..

I like to select pre-defined directory and load image. Pre-defined image folder located under application root folder.


Using the following script takes me to the pre-defined folder named RatingImages ( but Windows open dialog displayed is missing Open, Cancel buttons file field etc.

procedure frmItems_btnOpemImg01_OnClick (Sender: TObject; var Cancel: boolean);
begin
OpenFile(ExtractFilePath(Application.ExeName) + '\RatingImages','');
end;

Could somebody fix the above please?

Adam
God... please help me become the person my dog thinks I am.

2 (edited by sibprogsistem 2021-11-23 21:09:31)

Re: (UNRESOLVED) Select directory and..

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
openDialog:TOpenDialog;
begin

  openDialog := TOpenDialog.Create(Form1);
  openDialog.Options := ofHideReadOnly+ofAllowMultiSelect+ofEnableSizing;
  openDialog.Filter := 'PNG|*.png|JPG|*.jpg|BMP|*.bmp';
  openDialog.DefaultExt := '.png';

  if openDialog.Execute then
  begin
    Form1.Image1.Picture.LoadFromFile(openDialog.fileName);
  end;

  openDialog.Free;
end;

Re: (UNRESOLVED) Select directory and..

Hi Sibprogsistem,


Thank you very much for the reply.


The script you have shared doesn't take user to specified folder on windows open dialog.


When button is clicked; I want windows open dialog opens specified folder, then I choose an image there. Specific folder RatingImages is within the MVD app root folder.

Adam
God... please help me become the person my dog thinks I am.

Re: (UNRESOLVED) Select directory and..

AD1408 wrote:

Hi Sibprogsistem,


Thank you very much for the reply.


The script you have shared doesn't take user to specified folder on windows open dialog.


When button is clicked; I want windows open dialog opens specified folder, then I choose an image there. Specific folder RatingImages is within the MVD app root folder.

openDialog.InitialDir := ExtractFilePath(Application.ExeName);

Re: (UNRESOLVED) Select directory and..

Tried the following but still couldn't get it working

procedure frmItems_btnOpemImg01_OnClick (Sender: TObject; var Cancel: boolean);
var
openDialog:TOpenDialog;

begin
  openDialog := TOpenDialog.Create(Form1);
  openDialog.Options := ofHideReadOnly+ofAllowMultiSelect+ofEnableSizing;
  openDialog.DefaultExt := '.PNG';
  openDialog.Filter := 'PNG | *.PNG';

  if openDialog.Execute then
  begin
    openDialog.InitialDir := ExtractFilePath(Application.ExeName) + '\RatingImages';
  end;

  openDialog.Free;
end;

Please use the above the correct if wrong. Maybe I couldn't explain what I'm trying to do
1. I click the button to load image
2. I want windows open dialog opens specified folder INSTEAD of default image load folder

Adam
God... please help me become the person my dog thinks I am.

6 (edited by sibprogsistem 2021-11-24 06:38:46)

Re: (UNRESOLVED) Select directory and..

AD1408 wrote:

Tried the following but still couldn't get it working

procedure frmItems_btnOpemImg01_OnClick (Sender: TObject; var Cancel: boolean);
var
openDialog:TOpenDialog;

begin
  openDialog := TOpenDialog.Create(Form1);
  openDialog.Options := ofHideReadOnly+ofAllowMultiSelect+ofEnableSizing;
  openDialog.DefaultExt := '.PNG';
  openDialog.Filter := 'PNG | *.PNG';

  if openDialog.Execute then
  begin
    openDialog.InitialDir := ExtractFilePath(Application.ExeName) + '\RatingImages';
  end;

  openDialog.Free;
end;

Please use the above the correct if wrong. Maybe I couldn't explain what I'm trying to do
1. I click the button to load image
2. I want windows open dialog opens specified folder INSTEAD of default image load folder

procedure frmItems_btnOpemImg01_OnClick (Sender: TObject; var Cancel: boolean);
var
openDialog:TOpenDialog;

begin
  openDialog := TOpenDialog.Create(Form1);
  openDialog.Options := ofHideReadOnly+ofAllowMultiSelect+ofEnableSizing;
  openDialog.DefaultExt := '.PNG';
  openDialog.Filter := 'PNG | *.png';
  openDialog.InitialDir := ExtractFilePath(Application.ExeName) + '\RatingImages';

  if openDialog.Execute then
  begin
    // Form1.Image1.Picture.LoadFromFile(openDialog.fileName);
  end;

  openDialog.Free;
end;

Re: (UNRESOLVED) Select directory and..

Still cannot get into RatingImages folder within app root folder on click of the button.


Once again what I'm trying to do:
1. Click on image button on frmItems
2. Windows open dialog opened
3. Windows open dialog opens RatingImages folder within app root folder
4. User select an image from RatingImages folder and loads into frmItems


Here is a sample app that correction can be applied:

Post's attachments

Attachment icon FolderTest.zip 12.76 kb, 205 downloads since 2021-11-24 

Adam
God... please help me become the person my dog thinks I am.

Re: (UNRESOLVED) Select directory and..

команда - ExtractFilePath(Application.ExeName)  уже имеет '\' в конце записи
Вы пытаетесь добавить '\RatingImages'
в итоге получается такой адрес ***\\RatingImages

Post's attachments

Attachment icon FolderTest.rar 11.62 kb, 268 downloads since 2021-11-24 

Re: (UNRESOLVED) Select directory and..

Thanks a lot sibprogsistem....


Now it does locate the specified folder. However, it doesn't load to image on the form for saving using button. Image loaded using MVD image component open button. I was hoping to load the image on the form without using MVD default buttons. Instead using custom button or clicking on image event; while show buttons property for image component checked off.

---------------------------


Большое спасибо sibprogsistem ....


Теперь он находит указанную папку. Однако он не загружается в изображение в форме для сохранения с помощью кнопки. Изображение загружено с помощью кнопки открытия компонента изображения MVD. Я надеялся загрузить изображение в форму без использования кнопок MVD по умолчанию. Вместо использования настраиваемой кнопки или щелчка по событию изображения; в то время как свойство показа кнопок для компонента изображения отмечено.


sibprogsistem wrote:

команда - ExtractFilePath(Application.ExeName)  уже имеет '\' в конце записи
Вы пытаетесь добавить '\RatingImages'
в итоге получается такой адрес ***\\RatingImages

Adam
God... please help me become the person my dog thinks I am.

10 (edited by sibprogsistem 2021-11-24 16:33:05)

Re: (UNRESOLVED) Select directory and..

if openDialog.Execute then
  begin
     frmItems.DBImage11.Picture.LoadFromFile(openDialog.fileName);
     frmItems.DBImage11.dbFileName := openDialog.fileName;
  end;
Post's attachments

Attachment icon FolderTest.rar 855.13 kb, 290 downloads since 2021-11-24 

Re: (UNRESOLVED) Select directory and..

Thanks but still not working when used in different project.
I used the code in my actual project which has a different name. It cannot find the RatingImages folder.
I also tried by changing FolderTest project name and re-compiled. It stop working after changing the name.


-------------------------------------


Спасибо, но все еще не работает при использовании в другом проекте.
Я использовал код в своем реальном проекте, который имеет другое имя. Не удается найти папку RatingImages.
Я также попытался изменить имя проекта FolderTest и перекомпилировать. Он перестает работать после смены названия.

Adam
God... please help me become the person my dog thinks I am.

Re: (UNRESOLVED) Select directory and..

добавьте свой проект

Re: (UNRESOLVED) Select directory and..

sibprogsistem wrote:

добавьте свой проект

Post's attachments

Attachment icon FolderTest2.zip 859.49 kb, 209 downloads since 2021-11-25 

Adam
God... please help me become the person my dog thinks I am.

Re: (UNRESOLVED) Select directory and..

AD1408 wrote:
sibprogsistem wrote:

добавьте свой проект

я мел ввиду тот проект в котором у Вас не работает..

15 (edited by AD1408 2021-11-27 10:23:41)

Re: (UNRESOLVED) Select directory and..

sibprogsistem wrote:
AD1408 wrote:
sibprogsistem wrote:

добавьте свой проект

я мел ввиду тот проект в котором у Вас не работает..



I cannot speak Russian. Google translates your text as:
"I'm chalk because of the project in which you do not work .. "


I'm not clear but I guess you are saying I didn't post the actual project. If this is the case, then It doesn't matter which other project; the script you kindly provided doesn't work any other project with a different name... at least I couldn't make it work.
However, I truly appreciate your help and time... Once again thank you very much.


Perhaps some English speaking MVD users may be able to help me.......

Adam
God... please help me become the person my dog thinks I am.