Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi openpicturedialog .. kleines Problemchen (https://www.delphipraxis.net/8030-openpicturedialog-kleines-problemchen.html)

NoXeno 27. Aug 2003 10:31


openpicturedialog .. kleines Problemchen
 
Hallo,

steh hier auf den Schlau. :oops: Ich hab nen openpicturedialog, möchte dass er aber immer von dem initialdir anfängt. Mach er hier aber nicht, er startet da, wo ich das letzte bild geöffnet habe.

Kann mir jemand hierzu etwas Nachhilfe geben :?: :?:


Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
    openpicturedialog1.InitialDir:=ExtractFilePath(Application.ExeName);
    IF openpicturedialog1.Execute THEN
    BEGIN
         image1.picture.loadfromfile(openpicturedialog1.filename);
    END;
end;

TimmA 27. Aug 2003 10:39

Re: openpicturedialog .. kleines Problemchen
 
hi,

Delphi-Quellcode:
OpenDialog1.InitialDir := 'C:\OrdnerAufDeinerHDD\bla\blub\';
... so müsste es gehen

NoXeno 27. Aug 2003 10:48

Re: openpicturedialog .. kleines Problemchen
 
Zitat:

Zitat von TimmA
Delphi-Quellcode:
openDialog1.InitialDir := 'C:\OrdnerAufDeinerHDD\bla\blub\';
... so müsste es gehen

hab ich schon probiert.. er öffnet zwar zuerst diesen Ordner, aber lädt man noch ein Bild, nimmt er den zuletzt benutzten Ordner..


es muss also anders funktionieren :wall:

Wormid 27. Aug 2003 11:01

Re: openpicturedialog .. kleines Problemchen
 
Delphi-Quellcode:
  OpenDialog1.FileName := '';
  OpenDialog1.InitialDir := ExtractFilePath(ParamStr(0));
  if OpenDialog1.Execute then
    Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
So scheint es zu funktionieren... Nicht nur den Ordener setzen, sondern auch den letzten Filename, da der Dialog scheinbar dem Pfad dort den Vorrang gibt.

Gruß

Wormid

Memo 27. Aug 2003 11:04

Re: openpicturedialog .. kleines Problemchen
 
Das einzigste was bei meinen Versuchen geklappt hat, war
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var open :TOpenPictureDialog;
begin
   try
     open := TOpenPictureDialog.Create(self);
     open.InitialDir := ExtractFilePath(Application.ExeName);
    IF open.Execute THEN
       image1.picture.loadfromfile(open.filename);
   finally
    open.Free;
   end;
end;
warum das InitialDir beim 2.Versuch ohne Wirkung ist, ist mir auch schleierhaft. Auch noChangeDir war wirkungslos.

//Edit Code noch geändert

NoXeno 27. Aug 2003 11:06

Re: openpicturedialog .. kleines Problemchen
 
super :hello:

klappt wunderbar!! danke dir!!

xiao

Memo 27. Aug 2003 11:08

Re: openpicturedialog .. kleines Problemchen
 
bitte dir
Trotzdem komisches Verhalten.

Memo 27. Aug 2003 11:47

Re: openpicturedialog .. kleines Problemchen
 
Ich hab es mir gerade nach mal angesehen. Wormid hatte es in seinem Beitrag schon drin(haben wir blos alle überlesen). Man brauch nur mit
Delphi-Quellcode:
 OpenDialog1.FileName := ''
zurücksetzen und dann geht es auch ohne dynamisches Erzeugen.

NoXeno 27. Aug 2003 12:02

Re: openpicturedialog .. kleines Problemchen
 
:angle:

ja.. Wormid meinte ich auch oben mit meinen dankeschön..

deinem Engagement sei aber auch dank.. :)

dk3hn 18. Nov 2008 15:13

Re: openpicturedialog .. kleines Problemchen
 
Danke für den Tip! Ich dachte eben beim selben Problem schon, ich würde spinnen...
:stupid:

DonManfred 17. Feb 2010 14:45

Re: openpicturedialog .. kleines Problemchen
 
Ich habe das gleiche Problem und bin bei der Suche hier auf diesen thread gestossen...
Unter Windows 7 scheint beides nicht zu fruchten; also weder OpenDialog.Filename auf '' zu setzen noch das ganze dynamisch zu erzeugen. Der scheint irgendwie den letzten benutzten Pfad zu verwenden...

Bei mir auf dem Rechner (XP) klappt das wunderbar, bei meinem Chef (win7) klappt es nicht.

Irgend welche tips?

jfheins 17. Feb 2010 15:19

Re: openpicturedialog .. kleines Problemchen
 
Neues Feature von Windows 7:
Zitat:

lpstrInitialDir
Pointer to a NULL terminated string that can specify the initial directory. The algorithm for selecting the initial directory varies on different platforms.

Windows 7:

1. If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory.
2. Otherwise, if lpstrFile contains a path, that path is the initial directory.
3. Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory.
4. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
5. Otherwise, the initial directory is the personal files directory of the current user.
6. Otherwise, the initial directory is the Desktop folder.


Windows 2000/XP/Vista:

1. If lpstrFile contains a path, that path is the initial directory.
2. Otherwise, lpstrInitialDir specifies the initial directory.
3. Otherwise, if the application has used an Open or Save As dialog box in the past, the path most recently used is selected as the initial directory. However, if an application is not run for a long time, its saved selected path is discarded.
4. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
5. Otherwise, the initial directory is the personal files directory of the current user.
6. Otherwise, the initial directory is the Desktop folder.
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:15 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz