IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

Sélectionner un dossier


Sujet :

Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2012
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Transports

    Informations forums :
    Inscription : Juillet 2012
    Messages : 28
    Par défaut Sélectionner un dossier
    Bonjour,

    Voila je cherche le moyen d'avoir un opendialog mais pour un dossier et non un fichier.

    J'ai trouver 2/3 fonction le permettant mais pas comme je veut

    Je vais mettre du code et des images sa iras plus vite que des explications

    Le mieu que j'ai trouver est celui-ci :



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    unit BrowseForFolderU;
     
    interface
     
    function BrowseForFolder(const browseTitle: String;
      const initialFolder: String = '';
      mayCreateNewFolder: Boolean = False): String;
     
    implementation
     
    uses
      Windows, Forms, shlobj;
     
    var
      lg_StartFolder: String;
     
    ////////////////////////////////////////////////////////////////////////
    // Call back function used to set the initial browse directory.
    ////////////////////////////////////////////////////////////////////////
    function BrowseForFolderCallBack(Wnd: HWND; uMsg: UINT; lParam,
    lpData: LPARAM): Integer stdcall;
    begin
      if uMsg = BFFM_INITIALIZED then
        SendMessage(Wnd,BFFM_SETSELECTION, 1, Integer(@lg_StartFolder[1]));
      result := 0;
    end;
     
    ////////////////////////////////////////////////////////////////////////
    // This function allows the user to browse for a folder
    //
    // Arguments:-
    //         browseTitle : The title to display on the browse dialog.
    //       initialFolder : Optional argument. Use to specify the folder
    //                       initially selected when the dialog opens.
    //  mayCreateNewFolder : Flag indicating whether the user can create a
    //                       new folder.
    //
    // Returns: The empty string if no folder was selected (i.e. if the user
    //          clicked cancel), otherwise the full folder path.
    ////////////////////////////////////////////////////////////////////////
    function BrowseForFolder(const browseTitle: String;
      const initialFolder: String ='';
      mayCreateNewFolder: Boolean = False): String;
    var
      browse_info: TBrowseInfo;
      folder: array[0..MAX_PATH] of char;
      find_context: PItemIDList;
    begin
      //--------------------------
      // Initialise the structure.
      //--------------------------
      FillChar(browse_info,SizeOf(browse_info),#0);
      lg_StartFolder := initialFolder;
      browse_info.pszDisplayName := @folder[0];
      browse_info.lpszTitle := PChar(browseTitle);
      Browse_info.ulFlags := BIF_USENEWUI;
      if not mayCreateNewFolder then
        browse_info.ulFlags := browse_info.ulFlags or BIF_NONEWFOLDERBUTTON;
     
      browse_info.hwndOwner := Application.Handle;
      if initialFolder <> '' then
        browse_info.lpfn := BrowseForFolderCallBack;
      find_context := SHBrowseForFolder(browse_info);
      if Assigned(find_context) then
      begin
        if SHGetPathFromIDList(find_context,folder) then
          result := folder
        else
          result := '';
        GlobalFreePtr(find_context);
      end
      else
        result := '';
    end;
     
    end.
    Fonction d'appel simple et efficace mais c'est pas l'interface que j'aurais voulu

    Alors celui-la juste un peu vieillot

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    Var
      Dir : string;
    Begin
      Dir := EBureau.Text;
      if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt], 0) then
      EBureau.Text := Dir;
    End;
    Disons qu'on est en 2012 et que Windows 95/98 c finit comme même ^^

    Celui-la ressemble a se que je voudrais. mais la procédure de sélectionner un fichier dans le dossier est un peu lourde pour l'utilisateur.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
     
    interface
     
    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    FileCtrl;
     
    type
    TDirDialog = class(TOpenDialog)
    private
    FIsJustExecute: boolean;
    function GetDirectory: string;
    procedure SetDirectory(Directory: string);
    protected
    procedure DoFolderChange; override;
    public
    constructor Create(AOwner: TComponent); override;
    function Execute: Boolean; override;
    published
    property FileName;
    property Directory: string read GetDirectory write SetDirectory;
    end;
     
    procedure Register;
     
    implementation
     
    constructor TDirDialog.Create(AOwner: TComponent);
    begin
    inherited Create(AOwner);
    FIsJustExecute := False;
    FileName := 'Dummy.dat';
    Filter := '*.*|*.*';
    end;
     
    procedure TDirDialog.DoFolderChange;
    begin
    inherited DoFolderChange;
     
    if FIsJustExecute then
    begin
    FIsJustExecute := False;
    ShowWindow(GetDlgItem(GetParent(Handle),1136),SW_HIDE);
    ShowWindow(GetDlgItem(GetParent(Handle),1152),SW_HIDE);
     
    SetDlgItemText(GetParent(Handle),1089,'');
    SetDlgItemText(GetParent(Handle),1090,'');
    SetDlgItemText(GetParent(Handle),1091,'Répertoire :');
    SetDlgItemText(GetParent(Handle),1,'OK');
    end;
    end;
     
    function TDirDialog.Execute: Boolean;
    begin
    FIsJustExecute := True;
    if Title='' then Title := 'Sélectionnez un répertoire';
    Result := inherited Execute;
    end;
     
    function TDirDialog.GetDirectory: string;
    begin
    if FileName<>'' then
    if ExtractFileName(FileName)='Dummy.dat' then
    Result:=ExtractFileDir(FileName)
    else
    Result:=FileName
    else
    Result:='';
    end;
     
    procedure TDirDialog.SetDirectory(Directory: string);
    begin
    FileName := IncludeTrailingBackslash(Directory) + 'Dummy.dat';
    end;
     
    procedure Register;
    begin
    RegisterComponents('Dialogues', [TDirDialog]);
    end;
     
    end.


    voila une image de se que je voudrais exactement comme fenetre

  2. #2
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 993
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 993
    Par défaut
    si tu as déjà commencé avec SHBrowseForFolder, regarde plus près TBrowseInfo regarde BIF_NEWDIALOGSTYLE en plus de BIF_USENEWUI

    SelectDirectory avec sdNewUI doit faire la même chose, tu n'avais pas besoin de le coder à la main

    TBrowseForFolder est une action qui encapsule cela aussi

    Pense qu'Office a ses propres dialogues aussi

    utilise TFileOpenDialog pour Vista avec l'option fdoPickFolders


    J'ignore comment se comporte TFileOpenDialog si il tourne sous XP, il te faudra peut-etre utilisé un TOpenDialog en parallèle
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  3. #3
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2012
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Transports

    Informations forums :
    Inscription : Juillet 2012
    Messages : 28
    Par défaut
    Merci a toi.

    j'ai résolu avec TFILEOPENDIALOG.


    Le texte du bouton sélectionner est même paramétrable

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    unit Win7FileDialog;
     
    interface
     
    uses
      SysUtils, Classes, Forms, Dialogs, Windows,DesignIntf, ShlObj,
      ActiveX, CommDlg;
     
    Type
      TOpenOption = (fosOverwritePrompt,
      fosStrictFileTypes,
      fosNoChangeDir,
      fosPickFolders,
      fosForceFileSystem,
      fosAllNonStorageItems,
      fosNoValidate,
      fosAllowMultiSelect,
      fosPathMustExist,
      fosFileMustExist,
      fosCreatePrompt,
      fosShareAware,
      fosNoReadOnlyReturn,
      fosNoTestFileCreate,
      fosHideMRUPlaces,
      fosHidePinnedPlaces,
      fosNoDereferenceLinks,
      fosDontAddToRecent,
      fosForceShowHidden,
      fosDefaultNoMiniMode,
      fosForcePreviewPaneOn);
     
      TOpenOptions = set of TOpenOption;
     
    type
      TDialogType = (dtOpen,dtSave);
     
    type
      TWin7FileDialog = class(TOpenDialog)
      private
        FOptions: TOpenOptions;
        FDialogType: TDialogType;
        FOKButtonLabel: string;
        FFilterArray: TComdlgFilterSpecArray;
        procedure SetOKButtonLabel(const Value: string);
      protected
        function CanClose(Filename:TFilename): Boolean;
        function DoExecute: Bool;
      public
        FileDialog: IFileDialog;
        FileDialogCustomize: IFileDialogCustomize;
        FileDialogEvents: IFileDialogEvents;
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
        function Execute: Boolean; override;
      published
        property DefaultExt;
        property DialogType: TDialogType read FDialogType write FDialogType
          default dtOpen;
        property FileName;
        property Filter;
        property FilterArray: TComdlgFilterSpecArray read fFilterArray
          write fFilterArray;
        property FilterIndex;
        property InitialDir;
        property Options: TOpenOptions read FOptions write FOptions
          default [fosNoReadOnlyReturn, fosOverwritePrompt];
        property Title;
        property OKButtonLabel: string read fOKButtonLabel write SetOKButtonLabel;
        property OnCanClose;
        property OnFolderChange;
        property OnSelectionChange;
        property OnTypeChange;
        property OnClose;
        property OnShow;
      end;
     
      TFileDialogEvent = class(TInterfacedObject, IFileDialogEvents,
        IFileDialogControlEvents)
      private
        function OnFileOk(const pfd: IFileDialog): HResult; stdcall;
        function OnFolderChanging(const pfd: IFileDialog;
          const psiFolder: IShellItem): HResult; stdcall;
        function OnFolderChange(const pfd: IFileDialog): HResult; stdcall;
        function OnSelectionChange(const pfd: IFileDialog): HResult; stdcall;
        function OnShareViolation(const pfd: IFileDialog; const psi: IShellItem;
          out pResponse: DWORD): HResult; stdcall;
        function OnTypeChange(const pfd: IFileDialog): HResult; stdcall;
        function OnOverwrite(const pfd: IFileDialog; const psi: IShellItem;
          out pResponse: DWORD): HResult; stdcall;
     
        function OnItemSelected(const pfdc: IFileDialogCustomize; dwIDCtl,
          dwIDItem: DWORD): HResult; stdcall;
        function OnButtonClicked(const pfdc: IFileDialogCustomize;
          dwIDCtl: DWORD): HResult; stdcall;
        function OnCheckButtonToggled(const pfdc: IFileDialogCustomize;
          dwIDCtl: DWORD; bChecked: BOOL): HResult; stdcall;
        function OnControlActivating(const pfdc: IFileDialogCustomize;
          dwIDCtl: DWORD): HResult; stdcall;
      public
        ParentDialog: TWin7FileDialog;
     
    end;
     
    procedure Register;
     
    implementation
     
    constructor TWin7FileDialog.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
    end;
     
    destructor TWin7FileDialog.Destroy;
    begin
      inherited Destroy;
    end;
     
    procedure TWin7FileDialog.SetOKButtonLabel(const Value: string);
    begin
      if Value<>fOKButtonLabel then
        begin
          fOKButtonLabel := Value;
        end;
    end;
     
    function TWin7FileDialog.CanClose(Filename: TFilename): Boolean;
    begin
      Result := DoCanClose;
    end;
     
    function PathFromShellItem(aShellItem: IShellItem): string;
    var
      hr: HRESULT;
      aPath: PWideChar;
    begin
      hr:=aShellItem.GetDisplayName(SIGDN_FILESYSPATH,aPath);
      if hr = 0 then
        begin
          Result:=aPath;
        end
        else
          Result:='';
    end;
     
    function TFileDialogEvent.OnFileOk(const pfd: IFileDialog): HResult; stdcall;
    var
      aShellItem: IShellItem;
      hr: HRESULT;
      aFilename: PWideChar;
    begin
      {Get selected filename and check CanClose}
      aShellItem:=nil;
      hr:=pfd.GetResult(aShellItem);
      if hr = 0 then
        begin
          hr:=aShellItem.GetDisplayName(SIGDN_FILESYSPATH,aFilename);
          if hr = 0 then
            begin
              ParentDialog.Filename:=aFilename;
              if not ParentDialog.CanClose(aFilename) then
              begin
                result := s_FALSE;
                Exit;
              end;
            end;
        end;
     
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnFolderChanging(const pfd: IFileDialog;
      const psiFolder: IShellItem): HResult; stdcall;
    begin
      {Not currently handled}
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnFolderChange(const pfd: IFileDialog):
      HResult; stdcall;
    begin
      ParentDialog.DoFolderChange;
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnSelectionChange(const pfd: IFileDialog):
      HResult; stdcall;
    begin
      ParentDialog.DoSelectionChange;
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnShareViolation(const pfd: IFileDialog;
      const psi: IShellItem;out pResponse: DWORD): HResult; stdcall;
    begin
      {Not currently handled}
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnTypeChange(const pfd: IFileDialog):
      HResult; stdcall;
    begin
      ParentDialog.DoTypeChange;
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnOverwrite(const pfd: IFileDialog;
      const psi: IShellItem;out pResponse: DWORD): HResult; stdcall;
    begin
      {Not currently handled}
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnItemSelected(const pfdc: IFileDialogCustomize;
      dwIDCtl,dwIDItem: DWORD): HResult; stdcall;
    begin
      {Not currently handled}
    //  Form1.Caption := Format('%d:%d', [dwIDCtl, dwIDItem]);
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnButtonClicked(const pfdc: IFileDialogCustomize;
      dwIDCtl: DWORD): HResult; stdcall;
    begin
      {Not currently handled}
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnCheckButtonToggled(const pfdc: IFileDialogCustomize;
      dwIDCtl: DWORD; bChecked: BOOL): HResult; stdcall;
    begin
      {Not currently handled}
      result := s_OK;
    end;
     
    function TFileDialogEvent.OnControlActivating(const pfdc: IFileDialogCustomize;
      dwIDCtl: DWORD): HResult; stdcall;
    begin
      {Not currently handled}
      result := s_OK;
    end;
     
    procedure ParseDelimited(const sl : TStrings; const value : string;
      const delimiter : string) ;
    var
       dx : integer;
       ns : string;
       txt : string;
       delta : integer;
    begin
       delta := Length(delimiter) ;
       txt := value + delimiter;
       sl.BeginUpdate;
       sl.Clear;
       try
         while Length(txt) > 0 do
         begin
           dx := Pos(delimiter, txt) ;
           ns := Copy(txt,0,dx-1) ;
           sl.Add(ns) ;
           txt := Copy(txt,dx+delta,MaxInt) ;
         end;
       finally
         sl.EndUpdate;
       end;
    end;
     
     
    //function TWin7FileDialog.DoExecute(Func: Pointer): Bool;
    function TWin7FileDialog.DoExecute: Bool;
    var
      aFileDialogEvent: TFileDialogEvent;
      aCookie: cardinal;
      aWideString: WideString;
      aFilename: PWideChar;
      hr: HRESULT;
      aShellItem: IShellItem;
      aShellItemFilter: IShellItemFilter;
      aComdlgFilterSpec: TComdlgFilterSpec;
      aComdlgFilterSpecArray: TComdlgFilterSpecArray;
      i: integer;
      aStringList: TStringList;
      aFileTypesCount: integer;
      aFileTypesArray: TComdlgFilterSpecArray;
      aOptionsSet: Cardinal;
     
    begin
      if DialogType = dtSave then
      begin
        CoCreateInstance(CLSID_FileSaveDialog, nil, CLSCTX_INPROC_SERVER,
          IFileSaveDialog, FileDialog);
      end
      else
      begin
        CoCreateInstance(CLSID_FileOpenDialog, nil, CLSCTX_INPROC_SERVER,
          IFileOpenDialog, FileDialog);
      end;
     
    //  FileDialog.QueryInterface(
    //    StringToGUID('{8016B7B3-3D49-4504-A0AA-2A37494E606F}'),
    //    FileDialogCustomize);
    //  FileDialogCustomize.AddText(1000, 'My first Test');
     
      {Set Initial Directory}
      aWideString:=InitialDir;
      aShellItem:=nil;
      hr:=SHCreateItemFromParsingName(PWideChar(aWideString), nil,
        StringToGUID(SID_IShellItem), aShellItem);
      FileDialog.SetFolder(aShellItem);
     
      {Set Title}
      aWideString:=Title;
      FileDialog.SetTitle(PWideChar(aWideString));
     
      {Set Options}
      aOptionsSet:=0;
      if fosOverwritePrompt in Options then aOptionsSet:=
        aOptionsSet + FOS_OVERWRITEPROMPT;
      if fosStrictFileTypes in Options then aOptionsSet:=
        aOptionsSet + FOS_STRICTFILETYPES;
      if fosNoChangeDir in Options then aOptionsSet:=
        aOptionsSet + FOS_NOCHANGEDIR;
      if fosPickFolders in Options then aOptionsSet:=
        aOptionsSet + FOS_PICKFOLDERS;
      if fosForceFileSystem in Options then aOptionsSet:=
        aOptionsSet + FOS_FORCEFILESYSTEM;
      if fosAllNonStorageItems in Options then aOptionsSet:=
        aOptionsSet + FOS_ALLNONSTORAGEITEMS;
      if fosNoValidate in Options then aOptionsSet:=
        aOptionsSet + FOS_NOVALIDATE;
      if fosAllowMultiSelect in Options then aOptionsSet:=
        aOptionsSet + FOS_ALLOWMULTISELECT;
      if fosPathMustExist in Options then aOptionsSet:=
        aOptionsSet + FOS_PATHMUSTEXIST;
      if fosFileMustExist in Options then aOptionsSet:=
         aOptionsSet + FOS_FILEMUSTEXIST;
      if fosCreatePrompt in Options then aOptionsSet:=
        aOptionsSet + FOS_CREATEPROMPT;
      if fosShareAware in Options then aOptionsSet:=
        aOptionsSet + FOS_SHAREAWARE;
      if fosNoReadOnlyReturn in Options then aOptionsSet:=
        aOptionsSet + FOS_NOREADONLYRETURN;
      if fosNoTestFileCreate in Options then aOptionsSet:=
        aOptionsSet + FOS_NOTESTFILECREATE;
      if fosHideMRUPlaces in Options then aOptionsSet:=
        aOptionsSet + FOS_HIDEMRUPLACES;
      if fosHidePinnedPlaces in Options then aOptionsSet:=
        aOptionsSet + FOS_HIDEPINNEDPLACES;
      if fosNoDereferenceLinks in Options then aOptionsSet:=
        aOptionsSet + FOS_NODEREFERENCELINKS;
      if fosDontAddToRecent in Options then aOptionsSet:=
        aOptionsSet + FOS_DONTADDTORECENT;
      if fosForceShowHidden in Options then aOptionsSet:=
        aOptionsSet + FOS_FORCESHOWHIDDEN;
      if fosDefaultNoMiniMode in Options then aOptionsSet:=
        aOptionsSet + FOS_DEFAULTNOMINIMODE;
      if fosForcePreviewPaneOn in Options then aOptionsSet:=
        aOptionsSet + FOS_FORCEPREVIEWPANEON;
      FileDialog.SetOptions(aOptionsSet);
     
      {Set OKButtonLabel}
      aWideString:=OKButtonLabel;
      FileDialog.SetOkButtonLabel(PWideChar(aWideString));
     
      {Set Default Extension}
      aWideString:=DefaultExt;
      FileDialog.SetDefaultExtension(PWideChar(aWideString));
     
      {Set Default Filename}
      aWideString:=FileName;
      FileDialog.SetFilename(PWideChar(aWideString));
     
      {Set FileTypes (either from Filter or FilterArray)}
      if length(Filter)>0 then
      begin
      aStringList:=TStringList.Create;
      try
        ParseDelimited(aStringList,Filter,'|');
        aFileTypesCount:=Trunc(aStringList.Count/2)-1;
        i:=0;
        While i <= aStringList.Count-1 do
        begin
          SetLength(aFileTypesArray,Length(aFileTypesArray)+1);
          aFileTypesArray[Length(aFileTypesArray)-1].pszName:=
            PWideChar(WideString(aStringList[i]));
          aFileTypesArray[Length(aFileTypesArray)-1].pszSpec:=
            PWideChar(WideString(aStringList[i+1]));
          Inc(i,2);
        end;
        FileDialog.SetFileTypes(length(aFileTypesArray),aFileTypesArray);
      finally
        aStringList.Free;
      end;
      end
      else
      begin
        FileDialog.SetFileTypes(length(FilterArray),FilterArray);
      end;
     
      {Set FileType (filter) index}
      FileDialog.SetFileTypeIndex(FilterIndex);
     
      aFileDialogEvent:=TFileDialogEvent.Create;
      aFileDialogEvent.ParentDialog:=self;
      aFileDialogEvent.QueryInterface(IFileDialogEvents,FileDialogEvents);
      FileDialog.Advise(aFileDialogEvent,aCookie);
     
      hr:=FileDialog.Show(Application.Handle);
      if hr = 0 then
        begin
          aShellItem:=nil;
          hr:=FileDialog.GetResult(aShellItem);
          if hr = 0 then
            begin
              hr:=aShellItem.GetDisplayName(SIGDN_FILESYSPATH,aFilename);
              if hr = 0 then
                begin
                  Filename:=aFilename;
                end;
            end;
          Result:=true;
        end
        else
        begin
          Result:=false;
        end;
     
      FileDialog.Unadvise(aCookie);
    end;
     
    function TWin7FileDialog.Execute: Boolean;
    begin
      Result := DoExecute;
    end;
     
     
    procedure Register;
    begin
      RegisterComponents('Dialogs', [TWin7FileDialog]);
    end;
     
    end.
    Si jamais quelqu'un fait la même recherche

    Je mettrais SHBrowseForFolder en parallèle pour XP.
    Pour ce qui est de BIF_USENEWUI
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    BIF_USENEWUI = BIF_NEWDIALOGSTYLE or BIF_EDITBOX;
    j'ai ça dans SHLOBJ donc normalement l'utilisation de USENEWUI inclut NEWDIALOGSTYLE.

  4. #4
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 993
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 993
    Par défaut
    Je suppose que tu n'as pas une version récente de Delphi genre 6 ou 7 d'où ton utilisation de TWin7FileDialog que l'on trouve sur StackOverflow

    Car TFileOpenDialog depuis au moins RAD 2007 !
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  5. #5
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2012
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Transports

    Informations forums :
    Inscription : Juillet 2012
    Messages : 28
    Par défaut
    CodeGear™ Delphi® 2009 Version 12.0.3420.21218 Copyright © 2009 Embarcadero Technologies, Inc. Tous droits réservés.
    Voila ma version de delphi.

    Je connais pas du tous delphi. Je codais sous windev avants donc sa change une vie xD

  6. #6
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 993
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 993
    Par défaut
    Oublie donc ce code qui est une version baclée du TFileOpenDialog
    Tu le trouveras dans la palette d'outil dans la section "Dialogues" avec le TOpenDialog, TColorDialog ...

    Ah Windev, j'en fait en 5.5, 7.0 et 7.5 beta, à part l'outil de reporting qui était franchement meilleur, c'était vraiment pas un langage fait pour mes projets industriels, les sockets en multi-thread était totalement buggé
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Que doit contenir un dossier de programmation ?
    Par b30ff dans le forum Débats sur le développement - Le Best Of
    Réponses: 11
    Dernier message: 26/06/2004, 19h09
  2. Verifier qu'un dossier existe (batch)
    Par kakou dans le forum Scripts/Batch
    Réponses: 2
    Dernier message: 08/01/2003, 13h46
  3. Réponses: 4
    Dernier message: 07/12/2002, 15h24
  4. Comment vider un dossier ?
    Par Zinoc dans le forum C++Builder
    Réponses: 3
    Dernier message: 25/06/2002, 14h14
  5. Permission sur un dossier
    Par Bjorn dans le forum C
    Réponses: 6
    Dernier message: 25/06/2002, 12h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo