(*
/*

//-------------- wrapper for {Dialog_dir}

CLASS {AL4_dir_dialog|s_Delphi}, NATIVE, UNTESTED :
      
IMPORT: {Control}, {Dialog_dir} .

NATIVE: "uses AL4_dir_dialog, Windows;" .
*/
*)
unit AL4_dir_dialog;
{$I EXTERNAL_DEFINES.inc}
{$I KOLDEF.inc}

interface

uses {$IFDEF KOL} KOL 
     {$ELSE} Classes, Forms, Controls, Menus, 
             StdCtrls, ExtCtrls, ComCtrls, Dialogs
     {$ENDIF} ,
// use AL4 to access system functions (AL4.pas inserted by the compiler into
// a project folder)
     AL4,
// use All_classes from a project folder (generated for a certain project)
     All_classes, AL4_form,
     Windows, Messages;

//{$WARN UNIT_DEPRECATED OFF}
//{$WARN SYMBOL_PLATFORM OFF}
//{$WARN UNSAFE_TYPE OFF}
//{$WARN UNSAFE_CAST OFF}
//{$WARN UNSAFE_CODE OFF}

type
    PPanelDialogDir = ^TPanelDialogDir;
    TPanelDialogDir = object(TObj)
        DialogObject: POpenDirDialog;
    end;


function Do_Create_dialog_dir(P: Integer; X_D: Pointer): Integer;
function Do_Show_dir_dialog(X_D: Integer): Boolean;

implementation

(*
/*
// Create directory dialog
//----------------------------------------------------------------------------
FUN Create_dir_dialog(
    INT F|orm_handle,
    {Control} D|ialog_control) ==> INT, NATIVE :
    "     Result := Do_Create_dialog_dir(X_F, X_D);" .
*/
*)
function Do_Create_dialog_dir(P: Integer; X_D: Pointer): Integer;
var Parent: PAL4Column;
    D: PPanelDialogDir;
    F: PAL4Form;
begin
    F := PAL4Form(P);
    Parent := PAL4Column(F.Get_current_column_handle);
    new(D, Create);
    D.Tag := Integer(X_D);
    PObj(X_D).Tag := DWORD(D);
    //------------------------- 'create DialogObject'
    D.DialogObject := NewOpenDirDialog('', []);
    Result := Integer(D);
end;

(*
/*
// Show directory dialog, return TRUE if directory was selected.
//-----------------------------------------------------
FUN Show_dir_dialog(
{Control} C|ontrol_dialog_file
//INT D|ialog_control
) ==> BOOL, NATIVE:
	INT h|andle_dialog = C.Handle
	NATIVE @
    "    RESULT := Do_Show_dir_dialog(X_h);" .
    
FUN Execute|_dialog(
{Dialog_dir} D|ialog_control) ==> BOOL := D.Show_dir_dialog .    
*/
*)
function Do_Show_dir_dialog(X_D: Integer): Boolean;
var DP: PPanelDialogDir;
    D: POpenDirDialog;
    CD: C_Dialog_dir;
    RD: Ref_obj;
begin
    DP := PPanelDialogDir(X_D);
    RD := Pointer(DP.Tag);
    CD := C_Dialog_dir(RD.Obj);
    D := DP.DialogObject;
    D.Title := CD.F_Title;
    D.InitialPath := CD.F_Initial_path;
    //D.Path := CD.F_Path;
    Result := D.Execute;
    if  Result then
    begin
        CD.F_Path := D.Path;
    end;
end;

end.
(*
/*
END
*/
*)



