#DEFINE ASCIIZP INT
#DEFINE POINTINT INT

//#DEFINE POpenFilename   *TOpenFilename
#DEFINE POpenFilename INT

struct TOpenFileName
{
    INT     lStructSize;
    HWnd    hWndOwner;
    THandle hInstance;
    ASCIIZP lpstrFilter;
    ASCIIZP lpstrCustomFilter;
    INT     nMaxCustFilter;
    INT     nFilterIndex;
    ASCIIZP lpstrFile;
    INT     nMaxFile;
    ASCIIZP lpstrFileTitle;
    INT     nMaxFileTitle;
    ASCIIZP lpstrInitialDir;
    ASCIIZP lpstrTitle;
    INT     Flags;
    WORD    nFileOffset;
    WORD    nFileExtension;
    ASCIIZP lpstrDefExt;
    INT     lCustData;
    INT     lpfnHook;
    ASCIIZP lpTemplateName;
}



import Bool GetOpenFileName(POpenFilename OpenFile)  COMMDLG 1;
import Bool GetSaveFileName(POpenFilename OpenFile)  COMMDLG 2;
import WORD GetFileTitle(*ASCIIZ FileName, ASCIIZ Title, Word TitleSize)  COMMDLG 27;


#DEFINE   ofn_ReadOnly        0x00000001
#DEFINE   ofn_OverWritePrompt 0x00000002
#DEFINE   ofn_HideReadOnly    0x00000004
#DEFINE   ofn_NoChangeDir     0x00000008
#DEFINE   ofn_ShowHelp        0x00000010
#DEFINE   ofn_EnableHook      0x00000020
#DEFINE   ofn_EnableTemplate  0x00000040
#DEFINE   ofn_EnableTemplateH 0x00000080
#DEFINE   ofn_NoValidate      0x00000100
#DEFINE   ofn_AllowMultiSelect 0x00000200
#DEFINE   ofn_ExtentionDifferent 0x00000400
#DEFINE   ofn_PathMustExist   0x00000800
#DEFINE   ofn_FileMustExist   0x00001000
#DEFINE   ofn_CreatePrompt    0x00002000
#DEFINE   ofn_ShareAware      0x00004000
#DEFINE   ofn_NoReadOnlyReturn 0x00008000
#DEFINE   ofn_NoTextFileCreate 0x00010000

/* Return values for the registered message sent to the hook function
  when a sharing violation occurs.  ofn_ShareFallThrough allows the
  filename to be accepted, ofn_ShareNoWarn rejects the name but puts
  up no warning (returned when the app has already put up a warning
  message), and ofn_ShareWarn puts up the default warning message
  for sharing violations.

  Note:  Undefined return values map to ofn_ShareWarn. */

#DEFINE   ofn_ShareFallThrough 2
#DEFINE   ofn_ShareNoWarn 1
#DEFINE   ofn_ShareWarn 0


//#DEFINE PChooseColor    *TChooseColor
#DEFINE PChooseColor POINTER
structure TChooseColor
{
    INT       lStructSize;
    HWND      hWndOwner;
    HWND      hInstance;
    INT       rgbResult;
    INT       lpCustColors;
    INT       Flags;
    INT       lCustData;
    POINTINT  lpfnHook;
    ASCIIZP   lpTemplateName;
}

import Bool ChooseColor(PChooseColor CC)  COMMDLG 5;


#DEFINE   cc_RGBInit              0x00000001
#DEFINE   cc_FullOpen             0x00000002
#DEFINE   cc_PreventFullOpen      0x00000004
#DEFINE   cc_ShowHelp             0x00000008
#DEFINE   cc_EnableHook           0x00000010
#DEFINE   cc_EnableTemplate       0x00000020
#DEFINE   cc_EnableTemplateHandle 0x00000040


//#DEFINE PFindReplace    *TFindReplace
#DEFINE PFindReplace    POINTER
structure TFindReplace
{
    INT       lStructSize;          // size of this struct $20
    HWND      hWndOwner;            // handle to owner's window
    THANDLE   hInstance;            /* instance handle of.EXE that
                                       contains cust. dlg. template */
    INT       Flags;                // one or more of the fr_??
    ASCIIZP   lpstrFindWhat;        // ptr. to search string
    ASCIIZP   lpstrReplaceWith;     // ptr. to replace string
    WORD      wFindWhatLen;         // size of find buffer
    WORD      wReplaceWithLen;      // size of replace buffer
    INT       lCustData;            // data passed to hook fn.
    POINTINT  lpfnHook;
                                    // ptr. to hook fn. or nil
    ASCIIZP   lpTemplateName;       // custom template name
}


#DEFINE   fr_Down                   0x00000001
#DEFINE   fr_WholeWord              0x00000002
#DEFINE   fr_MatchCase              0x00000004
#DEFINE   fr_FindNext               0x00000008
#DEFINE   fr_Replace                0x00000010
#DEFINE   fr_ReplaceAll             0x00000020
#DEFINE   fr_DialogTerm             0x00000040
#DEFINE   fr_ShowHelp               0x00000080
#DEFINE   fr_EnableHook             0x00000100
#DEFINE   fr_EnableTemplate         0x00000200
#DEFINE   fr_NoUpDown               0x00000400
#DEFINE   fr_NoMatchCase            0x00000800
#DEFINE   fr_NoWholeWord            0x00001000
#DEFINE   fr_EnableTemplateHandle   0x00002000
#DEFINE   fr_HideUpDown             0x00004000
#DEFINE   fr_HideMatchCase          0x00008000
#DEFINE   fr_HideWholeWord          0x00010000

import HWnd FindText    (PFindReplace FindReplace)  COMMDLG 11;
import HWnd ReplaceText (PFindReplace FindReplace)  COMMDLG 12;


//#DEFINE PChooseFont   *TChooseFont
#DEFINE PChooseFont   POINTER
structure TChooseFont
{
    int       lStructSize;            //
    HWnd      hWndOwner;              // caller's window handle
    HDC       hDC;                    // printer DC/IC or nil
    POINTINT  lpLogFont;              // ptr. to a LOGFONT struct
    int16     iPointSize;             // 10 * size in points of selected font
    int       Flags;                  // enum. type flags
    int       rgbColors;              // returned text color
    int       lCustData;              // data passed to hook fn.
    POINTINT  lpfnHook;
                                      // ptr. to hook function
    ASCIIZP   lpTemplateName;         // custom template name
    THandle   hInstance;              /* instance handle of.EXE that
                                          contains cust. dlg. template */
    ASCIIZP   lpszStyle;              /* return the style field here
                                          must be lf_FaceSize or bigger */
    Word      nFontType;              /* same value reported to the EnumFonts
                                          call back with the extra fonttype_
                                          bits added */
    int16     nSizeMin;               // minimum pt size allowed &
    int16     nSizeMax;               /* max pt size allowed if
                                          cf_LimitSize is used      */
}

import Bool ChooseFont(PChooseFont ChooseFond)  COMMDLG 15;


#DEFINE   cf_ScreenFonts      0x00000001
#DEFINE   cf_PrinterFonts     0x00000002
#DEFINE   cf_Both             cf_ScreenFonts | cf_PrinterFonts
#DEFINE   cf_ShowHelp         0x00000004
#DEFINE   cf_EnableHook       0x00000008
#DEFINE   cf_EnableTemplate   0x00000010
#DEFINE   cf_EnableTemplateHn 0x00000020
#DEFINE   cf_InitToLogfontStr 0x00000040
#DEFINE   cf_UseStyle         0x00000080
#DEFINE   cf_Effects          0x00000100
#DEFINE   cf_Apply            0x00000200
#DEFINE   cf_AnsiOnly         0x00000400
#DEFINE   cf_NoVectorFonts    0x00000800
#DEFINE   cf_NoOEMFonts       cf_NoVectorFonts
#DEFINE   cf_NoSimulations    0x00001000
#DEFINE   cf_LimitSize        0x00002000
#DEFINE   cf_FixedPitchOnly   0x00004000
#DEFINE   cf_WYSIWYG          0x00008000 // must also have cf_ScreenFonts & cf_PrinterFonts
#DEFINE   cf_ForceFontExist   0x00010000
#DEFINE   cf_ScalableOnly     0x00020000
#DEFINE   cf_TTOnly           0x00040000
#DEFINE   cf_NoFaceSel        0x00080000
#DEFINE   cf_NoStyleSel       0x00100000
#DEFINE   cf_NoSizeSel        0x00200000

/* these are extra nFontType bits that are added to what is returned to the
  EnumFonts callback routine */

#DEFINE   Simulated_FontType  0x8000
#DEFINE   Printer_FontType    0x4000
#DEFINE   Screen_FontType     0x2000
#DEFINE   Bold_FontType       0x0100
#DEFINE   Italic_FontType     0x0200
#DEFINE   Regular_FontType    0x0400

#DEFINE   wm_ChooseFont_GetLogfont wm_User + 1


/* strings used to obtain unique window message for communication
  between dialog and caller */

#DEFINE   LBSelChString   "commdlg_LBSelChangedNotify"
#DEFINE   ShareViString   "commdlg_ShareViolation"
#DEFINE   FileOKString    "commdlg_FileNameOK"
#DEFINE   ColorOKString   "commdlg_ColorOK"
#DEFINE   SetRGBString    "commdlg_SetRGBColor"
#DEFINE   FindMsgString   "commdlg_FindReplace"
#DEFINE   HelpMsgString   "commdlg_help"

// HIWORD values for lParam of commdlg_LBSelChangeNotify message


#DEFINE   cd_LBSelNoItems -1
#DEFINE   cd_LBSelChange  0
#DEFINE   cd_LBSELSUB     1
#DEFINE   cd_LBSelAdd     2

//#DEFINE PPrintDlg   *TPrintDlg
#DEFINE PPrintDlg   POINTER
structure TPrintDlg
{
    INT       lStructSize;
    HWND      hWndOwner;
    THANDLE   hDevMode;
    THANDLE   hDevNames;
    HDC       hDC;
    INT       Flags;
    WORD      nFromPage;
    WORD      nToPage;
    WORD      nMinPage;
    WORD      nMaxPage;
    WORD      nCopies;
    THANDLE   hInstance;
    INT       lCustData;
    POINTINT  lpfnPrintHook;
    POINTINT  lpfnSetupHook;
    ASCIIZP   lpPrintTemplateName;
    ASCIIZP   lpSetupTemplateName;
    THANDLE   hPrintTemplate;
    THANDLE   hSetupTemplate;
}

import Bool PrintDlg(PPrintDlg PrintDlg)  COMMDLG 20;


#DEFINE   pd_AllPages           0x00000000
#DEFINE   pd_Selection          0x00000001
#DEFINE   pd_PageNums           0x00000002
#DEFINE   pd_NoSelection        0x00000004
#DEFINE   pd_NoPageNums         0x00000008
#DEFINE   pd_Collate            0x00000010
#DEFINE   pd_PrintToFile        0x00000020
#DEFINE   pd_PrintSetup         0x00000040
#DEFINE   pd_NoWarning          0x00000080
#DEFINE   pd_ReturnDC           0x00000100
#DEFINE   pd_ReturnIC           0x00000200
#DEFINE   pd_ReturnDefault      0x00000400
#DEFINE   pd_ShowHelp           0x00000800
#DEFINE   pd_EnablePrintHook    0x00001000
#DEFINE   pd_EnableSetupHook    0x00002000
#DEFINE   pd_EnablePrintTemp    0x00004000
#DEFINE   pd_EnableSetupTemp    0x00008000
#DEFINE   pd_EnablePrintTempH   0x00010000
#DEFINE   pd_EnableSetupTempH   0x00020000
#DEFINE   pd_UseDevModeCopies   0x00040000
#DEFINE   pd_DisablePrintToFile 0x00080000
#DEFINE   pd_HidePrintToFile    0x00100000


//#DEFINE PDevNames   *TDevNames
#DEFINE PDevNames   POINTER
structure TDevNames
{
    Word wDriverOffset;
    Word wDeviceOffset;
    Word wOutputOffset;
    Word wDefault;
}


#DEFINE   dn_DefaultPrn 0x0001

import int CommDlgExtendedError()  COMMDLG 26;


#DEFINE   cderr_DialogFailure    0xFFFF

#DEFINE   cderr_GeneralCodes     0x0000
#DEFINE   cderr_StructSize       0x0001
#DEFINE   cderr_Initialization   0x0002
#DEFINE   cderr_NoTemplate       0x0003
#DEFINE   cderr_NoHInstance      0x0004
#DEFINE   cderr_LoadStrFailure   0x0005
#DEFINE   cderr_FindResFailure   0x0006
#DEFINE   cderr_LoadResFailure   0x0007
#DEFINE   cderr_LockResFailure   0x0008
#DEFINE   cderr_MemAllocFailure  0x0009
#DEFINE   cderr_MemLockFailure   0x000A
#DEFINE   cderr_NoHook           0x000B
#DEFINE   cderr_RegisterMsgFail  0x000C

#DEFINE   pderr_PrinterCodes     0x1000
#DEFINE   pderr_SetupFailure     0x1001
#DEFINE   pderr_ParseFailure     0x1002
#DEFINE   pderr_RetDefFailure    0x1003
#DEFINE   pderr_LoadDrvFailure   0x1004
#DEFINE   pderr_GetDevModeFail   0x1005
#DEFINE   pderr_InitFailure      0x1006
#DEFINE   pderr_NoDevices        0x1007
#DEFINE   pderr_NoDefaultPrn     0x1008
#DEFINE   pderr_DNDMMismatch     0x1009
#DEFINE   pderr_CreateICFailure  0x100A
#DEFINE   pderr_PrinterNotFound  0x100B
#DEFINE   pderr_DefaultDifferent 0x100C

#DEFINE   cferr_ChooseFontCodes  0x2000
#DEFINE   cferr_NoFonts          0x2001
#DEFINE   cferr_MaxLessThanMin   0x2002

#DEFINE   fnErr_FilenameCodes    0x3000
#DEFINE   fnErr_SubclassFailure  0x3001
#DEFINE   fnErr_InvalidFilename  0x3002
#DEFINE   fnErr_BufferTooSmall   0x3003

#DEFINE   frErr_FindReplaceCodes 0x4000
#DEFINE   frErr_BufferLengthZero 0x4001

#DEFINE   ccErr_ChooseColorCodes 0x5000

