Autor Beitrag
bobby
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25

Win XP
D7 Prof
BeitragVerfasst: Do 12.08.04 02:17 
My app consist from Main form and 6 other forms. One of those other forms is my 'folder select dialog'. If, while running the app, Main form and one of other forms access the 'folder select dialog' (not both forms at once), than close the app - the app will exit with memory violation error. If I open the 'folder select dialog' just from one of the forms - app will exit without errors.
After some hacking the code I had following situation: just activating two forms that acess the 'folder select dialog', and close the app after that - errors again.
My temporary solution is to have more 'folder select dialogs' (one for each form).
Do anybody knows better solution?
What I need to do to get it working with just one 'folder selector dialog'.
In all the forms I have used:
ausblenden Delphi-Quelltext
1:
2:
implementation
Uses: selector;

Selector is the name of my 'folder select dialog'.
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Do 12.08.04 11:58 
hi,

please show that part of your code, where you call the select dialogue.

Regards
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
bobby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25

Win XP
D7 Prof
BeitragVerfasst: Do 12.08.04 14:24 
In Main Form:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
procedure TIntegrator.ChangeProjectsRoot1Click(Sender: TObject);
var
  OldRoot: string;
  counter: integer;
  itemCount: integer;
  keyName: string;
begin
  OldRoot := ProjectRoot;
  SelectForm.Caption := 'Select CD tree root';
  SelectForm.ShowModal;
  ProjectRoot := SelectForm.ShellTreeView1.Path;
  if rightStr(ProjectRoot, 1) <> '\' then
    ProjectRoot := ProjectRoot + '\';
  Mkisofs_form.Edit7.Text := ProjectRoot;
  sorter_form.ShellTreeView1.Root := ProjectRoot;
  sorter_form.Edit1.Text := ProjectRoot;
  caa_form.ShellTreeView1.Root := ProjectRoot;
  // Change root in caa_form
  counter := 0;
  while counter < caa_form.ListBox2.Count do
  begin
    caa_form.ListBox2.Items.Strings[counter] :=
      AnsiReplaceText(caa_form.ListBox2.Items.Strings[counter], OldRoot,
      ProjectRoot);
    counter := counter + 1;
  end;
  counter := 0;
  while counter < caa_form.ListBox3.Count do
  begin
    caa_form.ListBox3.Items.Strings[counter] :=
      AnsiReplaceText(caa_form.ListBox3.Items.Strings[counter], OldRoot,
      ProjectRoot);
    counter := counter + 1;
  end;
  // Change root in sorter_form
  itemcount := sorter_form.ValueListEditor1.RowCount - 1;
  for counter := 1 to itemCount do
  begin
    keyName := sorter_form.ValueListEditor1.Keys[counter];
    keyName := StringReplace(keyName, WinToLin(OldRoot), WinToLin(ProjectRoot),
      [rfReplaceAll]);
    sorter_form.ValueListEditor1.Keys[counter] := keyName;
  end;
end;


In mkisofs_form:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure Tmkisofs_form.Button1Click(Sender: TObject);
var
  RootCD: string;
begin
  selectform.Caption := 'Select CD tree root';
  SelectForm.ShowModal;
  RootCD := SelectForm.ShellTreeView1.Path;
  if rightStr(RootCD, 1) <> '\' then
    RootCD := RootCD + '\';
  Edit7.Text := RootCD;
end;

procedure Tmkisofs_form.Button2Click(Sender: TObject);
var
  OutIMG: string;
begin
  selectform.Caption := 'Select output folder';
  SelectForm.ShowModal;
  OutIMG := SelectForm.ShellTreeView1.Path;
  if rightStr(OutIMG, 1) <> '\' then
    OutIMG := OutIMG + '\';
  Edit8.Text := OutIMG;
end;


Select_form have ShellTreeView and one button. Code of select_form is:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TSelectForm.SelectBtClick(Sender: TObject);
begin
  close;
end;

procedure TSelectForm.ShellTreeView1Click(Sender: TObject);
begin
  if ShellTreeView1.Path = 'My Computer' then
    SelectBt.Enabled := false
  else if ShellTreeView1.Path = 'Control Panel' then
    SelectBt.Enabled := false
  else
    SelectBt.Enabled := true;
end;

procedure TSelectForm.FormActivate(Sender: TObject);
begin
  SelectBT.Enabled := false;
end;
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: Do 12.08.04 21:17 
if you use this code
ausblenden Delphi-Quelltext
1:
2:
3:
Application.CreateForm(TSelectForm,SelectForm);
SelectForm.Show;
selectform.Caption := 'Select CD tree root';

instead of
ausblenden Delphi-Quelltext
1:
2:
  selectform.Caption := 'Select CD tree root';   
  SelectForm.ShowModal;

you can open and close the form as often you want 8).

if possible, you can also use the standard-directory-selection-dialog:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
Unit: FileCtrl

function SelectDirectory(const Caption: stringconst Root: WideString; out Directory: string): Boolean; overload;
function SelectDirectory(var Directory: string; Options: TSelectDirOpts; HelpCtx: Longint): Boolean; overload;

for more information use the delphi-help

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
bobby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25

Win XP
D7 Prof
BeitragVerfasst: Fr 13.08.04 00:30 
@Patrick
You suggest me not to create form at start, but dinamicaly in run-time?
I'm not very familiar with creating components dinamicaly. If I got it right, I can design a form with IDE, but I need to exclude it from Project>Options>Forms>Auto-create forms list, then I should use your method ?
bobby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25

Win XP
D7 Prof
BeitragVerfasst: Fr 13.08.04 12:16 
Do I also need to free(destroy) the form after I use it?
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: Fr 13.08.04 12:32 
Zitat:
Do I also need to free(destroy) the form after I use it?

nope, just close it.
Zitat:
You suggest me not to create form at start, but dinamicaly in run-time?

exactly :mrgreen:
Zitat:

I'm not very familiar with creating components dinamicaly. If I got it right, I can design a form with IDE, but I need to exclude it from Project>Options>Forms>Auto-create forms list, then I should use your method ?

you are absolutly right.
try it!
i had the same problem with a exception after closing a form a second time.
this solved my problems.

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
bobby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25

Win XP
D7 Prof
BeitragVerfasst: Fr 13.08.04 13:35 
Thank you very much, it works like a charm :D
Just for info, I'v put your name in About_box/Credits.