' api_commdlg.sbp

#ifdef UNICODE
Const _FuncName_ChooseColor = "ChooseColorW"
Const _FuncName_ChooseFont = "ChooseFontW"
Const _FuncName_FindText = "FindTextW"
Const _FuncName_GetOpenFileName = "GetOpenFileNameW"
Const _FuncName_GetSaveFileName = "GetSaveFileNameW"
Const _FuncName_GetFileTitle = "GetFileTitleW"
Const _FuncName_PageSetupDlg = "PageSetupDlgW"
Const _FuncName_PrintDlg = "PrintDlgW"
#else
Const _FuncName_ChooseColor = "ChooseColorA"
Const _FuncName_ChooseFont = "ChooseFontA"
Const _FuncName_FindText = "FindTextA"
Const _FuncName_GetOpenFileName = "GetOpenFileNameA"
Const _FuncName_GetSaveFileName = "GetSaveFileNameA"
Const _FuncName_GetFileTitle = "GetFileTitleA"
Const _FuncName_PageSetupDlg = "PageSetupDlgA"
Const _FuncName_PrintDlg = "PrintDlgA"
#endif

TypeDef LPCOMMDLGHOOKPROC = *Function(hdlg As HWND, uiMsg As DWord, wp As WPARAM, lp As LPARAM) As ULONG_PTR

' Common dialog error
Const CDERR_DIALOGFAILURE =    &HFFFF

Const CDERR_GENERALCODES =     &H0000
Const CDERR_STRUCTSIZE =       &H0001
Const CDERR_INITIALIZATION =   &H0002
Const CDERR_NOTEMPLATE =       &H0003
Const CDERR_NOHINSTANCE =      &H0004
Const CDERR_LOADSTRFAILURE =   &H0005
Const CDERR_FINDRESFAILURE =   &H0006
Const CDERR_LOADRESFAILURE =   &H0007
Const CDERR_LOCKRESFAILURE =   &H0008
Const CDERR_MEMALLOCFAILURE =  &H0009
Const CDERR_MEMLOCKFAILURE =   &H000A
Const CDERR_NOHOOK =           &H000B
Const CDERR_REGISTERMSGFAIL =  &H000C

Const PDERR_PRINTERCODES =     &H1000
Const PDERR_SETUPFAILURE =     &H1001
Const PDERR_PARSEFAILURE =     &H1002
Const PDERR_RETDEFFAILURE =    &H1003
Const PDERR_LOADDRVFAILURE =   &H1004
Const PDERR_GETDEVMODEFAIL =   &H1005
Const PDERR_INITFAILURE =      &H1006
Const PDERR_NODEVICES =        &H1007
Const PDERR_NODEFAULTPRN =     &H1008
Const PDERR_DNDMMISMATCH =     &H1009
Const PDERR_CREATEICFAILURE =  &H100A
Const PDERR_PRINTERNOTFOUND =  &H100B
Const PDERR_DEFAULTDIFFERENT = &H100C

Const CFERR_CHOOSEFONTCODES =  &H2000
Const CFERR_NOFONTS =          &H2001
Const CFERR_MAXLESSTHANMIN =   &H2002

Const FNERR_FILENAMECODES =    &H3000
Const FNERR_SUBCLASSFAILURE =  &H3001
Const FNERR_INVALIDFILENAME =  &H3002
Const FNERR_BUFFERTOOSMALL =   &H3003

Const FRERR_FINDREPLACECODES = &H4000
Const FRERR_BUFFERLENGTHZERO = &H4001

Const CCERR_CHOOSECOLORCODES = &H5000
Declare Function CommDlgExtendedError Lib "comdlg32" () As DWord


'-------------
' ChooseColor
'-------------
Const CC_RGBINIT =              &H00000001
Const CC_FULLOPEN =             &H00000002
Const CC_PREVENTFULLOPEN =      &H00000004
Const CC_SHOWHELP =             &H00000008
Const CC_ENABLEHOOK =           &H00000010
Const CC_ENABLETEMPLATE =       &H00000020
Const CC_ENABLETEMPLATEHANDLE = &H00000040
Const CC_SOLIDCOLOR =           &H00000080
Const CC_ANYCOLOR =             &H00000100
TypeDef LPCCHOOKPROC = LPCOMMDLGHOOKPROC
Type CHOOSECOLORW
	lStructSize    As DWord
	hwndOwner      As HWND
	hInstance      As HINSTANCE
	rgbResult      As DWord
	lpCustColors   As *DWord
	Flags          As DWord
	lCustData      As DWord
	lpfnHook       As LPCCHOOKPROC
	lpTemplateName As LPCWSTR
End Type
Type CHOOSECOLORA
	lStructSize    As DWord
	hwndOwner      As HWND
	hInstance      As HINSTANCE
	rgbResult      As DWord
	lpCustColors   As *DWord
	Flags          As DWord
	lCustData      As DWord
	lpfnHook       As LPCCHOOKPROC
	lpTemplateName As LPCSTR
End Type
#ifdef UNICODE
TypeDef CHOOSECOLOR = CHOOSECOLORW
#else
TypeDef CHOOSECOLOR = CHOOSECOLORA
#endif
Declare Function ChooseColor Lib "comdlg32" Alias _FuncName_ChooseColor (ByRef cc As CHOOSECOLOR) As BOOL


'------------
' ChooseFont
'------------
Const CF_SCREENFONTS =           &H00000001
Const CF_PRINTERFONTS =          &H00000002
Const CF_BOTH =                  CF_SCREENFONTS or CF_PRINTERFONTS
Const CF_SHOWHELP =              &H00000004
Const CF_ENABLEHOOK =            &H00000008
Const CF_ENABLETEMPLATE =        &H00000010
Const CF_ENABLETEMPLATEHANDLE =  &H00000020
Const CF_INITTOLOGFONTSTRUCT =   &H00000040
Const CF_USESTYLE =              &H00000080
Const CF_EFFECTS =               &H00000100
Const CF_APPLY =                 &H00000200
Const CF_ANSIONLY =              &H00000400
Const CF_SCRIPTSONLY =           CF_ANSIONLY
Const CF_NOVECTORFONTS =         &H00000800
Const CF_NOOEMFONTS =            CF_NOVECTORFONTS
Const CF_NOSIMULATIONS =         &H00001000
Const CF_LIMITSIZE =             &H00002000
Const CF_FIXEDPITCHONLY =        &H00004000
Const CF_WYSIWYG =               &H00008000
Const CF_FORCEFONTEXIST =        &H00010000
Const CF_SCALABLEONLY =          &H00020000
Const CF_TTONLY =                &H00040000
Const CF_NOFACESEL =             &H00080000
Const CF_NOSTYLESEL =            &H00100000
Const CF_NOSIZESEL =             &H00200000
Const CF_SELECTSCRIPT =          &H00400000
Const CF_NOSCRIPTSEL =           &H00800000
Const CF_NOVERTFONTS =           &H01000000
Const SIMULATED_FONTTYPE =  &H8000
Const PRINTER_FONTTYPE =    &H4000
Const SCREEN_FONTTYPE =     &H2000
Const BOLD_FONTTYPE =       &H0100
Const ITALIC_FONTTYPE =     &H0200
Const REGULAR_FONTTYPE =    &H0400
TypeDef LPCFHOOKPROC = LPCOMMDLGHOOKPROC
Type CHOOSEFONTW
	lStructSize            As DWord
	hwndOwner              As HWND
	hDC                    As HDC
	lpLogFont              As *LOGFONTW
	iPointSize             As Long
	Flags                  As DWord
	rgbColors              As DWord
	lCustData              As LPARAM
	lpfnHook               As LPCFHOOKPROC
	lpTemplateName         As LPCWSTR
	hInstance              As HINSTANCE
	lpszStyle              As LPWSTR
	nFontType              As Word
	___MISSING_ALIGNMENT__ As Word
	nSizeMin               As Long
	nSizeMax               As Long
End Type
Type CHOOSEFONTA
	lStructSize            As DWord
	hwndOwner              As HWND
	hDC                    As HDC
	lpLogFont              As *LOGFONTA
	iPointSize             As Long
	Flags                  As DWord
	rgbColors              As DWord
	lCustData              As LPARAM
	lpfnHook               As LPCFHOOKPROC
	lpTemplateName         As LPCSTR
	hInstance              As HINSTANCE
	lpszStyle              As LPSTR
	nFontType              As Word
	___MISSING_ALIGNMENT__ As Word
	nSizeMin               As Long
	nSizeMax               As Long
End Type
#ifdef UNICODE
TypeDef CHOOSEFONT = CHOOSEFONTW
#else
TypeDef CHOOSEFONT = CHOOSEFONTA
#endif
Declare Function ChooseFont Lib "comdlg32" Alias _FuncName_ChooseFont (ByRef cf As CHOOSEFONT) As BOOL


'----------
' FindText
'----------
Const FR_DOWN =                       &H00000001
Const FR_WHOLEWORD =                  &H00000002
Const FR_MATCHCASE =                  &H00000004
Const FR_FINDNEXT =                   &H00000008
Const FR_REPLACE =                    &H00000010
Const FR_REPLACEALL =                 &H00000020
Const FR_DIALOGTERM =                 &H00000040
Const FR_SHOWHELP =                   &H00000080
Const FR_ENABLEHOOK =                 &H00000100
Const FR_ENABLETEMPLATE =             &H00000200
Const FR_NOUPDOWN =                   &H00000400
Const FR_NOMATCHCASE =                &H00000800
Const FR_NOWHOLEWORD =                &H00001000
Const FR_ENABLETEMPLATEHANDLE =       &H00002000
Const FR_HIDEUPDOWN =                 &H00004000
Const FR_HIDEMATCHCASE =              &H00008000
Const FR_HIDEWHOLEWORD =              &H00010000
TypeDef LPFRHOOKPROC = LPCOMMDLGHOOKPROC
Type FINDREPLACEW
	lStructSize      As DWord
	hwndOwner        As HWND
	hInstance        As HINSTANCE
	Flags            As DWord
	lpstrFindWhat    As LPWSTR
	lpstrReplaceWith As LPWSTR
	wFindWhatLen     As Word
	wReplaceWithLen  As Word
	lCustData        As LPARAM
	lpfnHook         As LPFRHOOKPROC
	lpTemplateName   As LPCWSTR
End Type
Type FINDREPLACEA
	lStructSize      As DWord
	hwndOwner        As HWND
	hInstance        As HINSTANCE
	Flags            As DWord
	lpstrFindWhat    As LPSTR
	lpstrReplaceWith As LPSTR
	wFindWhatLen     As Word
	wReplaceWithLen  As Word
	lCustData        As LPARAM
	lpfnHook         As LPFRHOOKPROC
	lpTemplateName   As LPCSTR
End Type
#ifdef UNICODE
TypeDef FINDREPLACE = FINDREPLACEW
#else
TypeDef FINDREPLACE = FINDREPLACEA
#endif
Declare Function FindText Lib "comdlg32" Alias _FuncName_FindText (ByRef fr As FINDREPLACE) As BOOL


'------------------------
' Get Open/Save FileName
'------------------------
Const OFN_READONLY =               &H00000001
Const OFN_OVERWRITEPROMPT =        &H00000002
Const OFN_HIDEREADONLY =           &H00000004
Const OFN_NOCHANGEDIR =            &H00000008
Const OFN_SHOWHELP =               &H00000010
Const OFN_ENABLEHOOK =             &H00000020
Const OFN_ENABLETEMPLATE =         &H00000040
Const OFN_ENABLETEMPLATEHANDLE =   &H00000080
Const OFN_NOVALIDATE =             &H00000100
Const OFN_ALLOWMULTISELECT =       &H00000200
Const OFN_EXTENSIONDIFFERENT =     &H00000400
Const OFN_PATHMUSTEXIST =          &H00000800
Const OFN_FILEMUSTEXIST =          &H00001000
Const OFN_CREATEPROMPT =           &H00002000
Const OFN_SHAREAWARE =             &H00004000
Const OFN_NOREADONLYRETURN =       &H00008000
Const OFN_NOTESTFILECREATE =       &H00010000
Const OFN_NONETWORKBUTTON =        &H00020000
Const OFN_NOLONGNAMES =            &H00040000
Const OFN_EXPLORER =               &H00080000
Const OFN_NODEREFERENCELINKS =     &H00100000
Const OFN_LONGNAMES =              &H00200000
Const OFN_ENABLEINCLUDENOTIFY =    &H00400000
Const OFN_ENABLESIZING =           &H00800000
TypeDef LPOFNHOOKPROC = LPCOMMDLGHOOKPROC
Type OPENFILENAMEW
	lStructSize       As DWord
	hwndOwner         As HWND
	hInstance         As HINSTANCE
	lpstrFilter       As LPCWSTR
	lpstrCustomFilter As LPWSTR
	nMaxCustFilter    As DWord
	nFilterIndex      As DWord
	lpstrFile         As LPWSTR
	nMaxFile          As DWord
	lpstrFileTitle    As LPWSTR
	nMaxFileTitle     As DWord
	lpstrInitialDir   As LPCWSTR
	lpstrTitle        As LPCWSTR
	Flags             As DWord
	nFileOffset       As Word
	nFileExtension    As Word
	lpstrDefExt       As LPCWSTR
	lCustData         As LPARAM
	lpfnHook          As LPOFNHOOKPROC
	lpTemplateName    As LPCWSTR
End Type
Type OPENFILENAMEA
	lStructSize       As DWord
	hwndOwner         As HWND
	hInstance         As HINSTANCE
	lpstrFilter       As LPCSTR
	lpstrCustomFilter As LPSTR
	nMaxCustFilter    As DWord
	nFilterIndex      As DWord
	lpstrFile         As LPSTR
	nMaxFile          As DWord
	lpstrFileTitle    As LPSTR
	nMaxFileTitle     As DWord
	lpstrInitialDir   As LPCSTR
	lpstrTitle        As LPCSTR
	Flags             As DWord
	nFileOffset       As Word
	nFileExtension    As Word
	lpstrDefExt       As LPCSTR
	lCustData         As LPARAM
	lpfnHook          As LPOFNHOOKPROC
	lpTemplateName    As LPCSTR
End Type
#ifdef UNICODE
TypeDef OPENFILENAME = OPENFILENAMEW
#else
TypeDef OPENFILENAME = OPENFILENAMEA
#endif
Declare Function GetOpenFileName Lib "comdlg32" Alias _FuncName_GetOpenFileName (ByRef ofn As OPENFILENAME) As BOOL
Declare Function GetSaveFileName Lib "comdlg32" Alias _FuncName_GetSaveFileName (ByRef ofn As OPENFILENAME) As BOOL
Declare Function GetFileTitle Lib "comdlg32" Alias _FuncName_GetFileTitle (lpszFile As LPCTSTR, lpszTitle As LPTSTR, cbBuf As Word) As Integer


'--------------
' PageSetupDlg
'--------------
Const PSD_DEFAULTMINMARGINS =             &H00000000
Const PSD_INWININIINTLMEASURE =           &H00000000
Const PSD_MINMARGINS =                    &H00000001
Const PSD_MARGINS =                       &H00000002
Const PSD_INTHOUSANDTHSOFINCHES =         &H00000004
Const PSD_INHUNDREDTHSOFMILLIMETERS =     &H00000008
Const PSD_DISABLEMARGINS =                &H00000010
Const PSD_DISABLEPRINTER =                &H00000020
Const PSD_NOWARNING =                     &H00000080
Const PSD_DISABLEORIENTATION =            &H00000100
Const PSD_RETURNDEFAULT =                 &H00000400
Const PSD_DISABLEPAPER =                  &H00000200
Const PSD_SHOWHELP =                      &H00000800
Const PSD_ENABLEPAGESETUPHOOK =           &H00002000
Const PSD_ENABLEPAGESETUPTEMPLATE =       &H00008000
Const PSD_ENABLEPAGESETUPTEMPLATEHANDLE = &H00020000
Const PSD_ENABLEPAGEPAINTHOOK =           &H00040000
Const PSD_DISABLEPAGEPAINTING =           &H00080000
Const PSD_NONETWORKBUTTON =               &H00200000
TypeDef LPPAGESETUPHOOK = LPCOMMDLGHOOKPROC
TypeDef LPPAGEPAINTHOOK = LPCOMMDLGHOOKPROC
Type PAGESETUPDLGW
	lStructSize             As DWord
	hwndOwner               As HWND
	hDevMode                As HGLOBAL
	hDevNames               As HGLOBAL
	Flags                   As DWord
	ptPaperSize             As POINTAPI
	rtMinMargin             As RECT
	rtMargin                As RECT
	hInstance               As HINSTANCE
	lCustData               As LPARAM
	lpfnPageSetupHook       As LPPAGESETUPHOOK
	lpfnPagePaintHook       As LPPAGEPAINTHOOK
	lpPageSetupTemplateName As LPCWSTR
	hPageSetupTemplate      As HGLOBAL
End Type
Type PAGESETUPDLGA
	lStructSize             As DWord
	hwndOwner               As HWND
	hDevMode                As HGLOBAL
	hDevNames               As HGLOBAL
	Flags                   As DWord
	ptPaperSize             As POINTAPI
	rtMinMargin             As RECT
	rtMargin                As RECT
	hInstance               As HINSTANCE
	lCustData               As LPARAM
	lpfnPageSetupHook       As LPPAGESETUPHOOK
	lpfnPagePaintHook       As LPPAGEPAINTHOOK
	lpPageSetupTemplateName As LPCSTR
	hPageSetupTemplate      As HGLOBAL
End Type
#ifdef UNICODE
TypeDef PAGESETUPDLG = PAGESETUPDLGW
#else
TypeDef PAGESETUPDLG = PAGESETUPDLGA
#endif

Declare Function PageSetupDlg Lib "comdlg32" Alias _FuncName_PageSetupDlg (ByRef psd As PAGESETUPDLG) As BOOL


'----------
' PrintDlg
'----------
Const PD_ALLPAGES =                   &H00000000
Const PD_SELECTION =                  &H00000001
Const PD_PAGENUMS =                   &H00000002
Const PD_NOSELECTION =                &H00000004
Const PD_NOPAGENUMS =                 &H00000008
Const PD_COLLATE =                    &H00000010
Const PD_PRINTTOFILE =                &H00000020
Const PD_PRINTSETUP =                 &H00000040
Const PD_NOWARNING =                  &H00000080
Const PD_RETURNDC =                   &H00000100
Const PD_RETURNIC =                   &H00000200
Const PD_RETURNDEFAULT =              &H00000400
Const PD_SHOWHELP =                   &H00000800
Const PD_ENABLEPRINTHOOK =            &H00001000
Const PD_ENABLESETUPHOOK =            &H00002000
Const PD_ENABLEPRINTTEMPLATE =        &H00004000
Const PD_ENABLESETUPTEMPLATE =        &H00008000
Const PD_ENABLEPRINTTEMPLATEHANDLE =  &H00010000
Const PD_ENABLESETUPTEMPLATEHANDLE =  &H00020000
Const PD_USEDEVMODECOPIES =           &H00040000
Const PD_USEDEVMODECOPIESANDCOLLATE = &H00040000
Const PD_DISABLEPRINTTOFILE =         &H00080000
Const PD_HIDEPRINTTOFILE =            &H00100000
Const PD_NONETWORKBUTTON =            &H00200000
TypeDef LPPAGEPAINTHOOK = LPCOMMDLGHOOKPROC
TypeDef LPSETUPHOOKPROC = LPCOMMDLGHOOKPROC
#ifdef _WIN64
Type PRINTDLGW
#else
Type Align(1) PRINTDLGW
#endif
	lStructSize         As DWord
	hwndOwner           As HWND
	hDevMode            As HGLOBAL
	hDevNames           As HGLOBAL
	hDC                 As HDC
	Flags               As DWord
	nFromPage           As Word
	nToPage             As Word
	nMinPage            As Word
	nMaxPage            As Word
	nCopies             As Word
	hInstance           As HINSTANCE
	lCustData           As LPARAM
	lpfnPrintHook       As LPPAGEPAINTHOOK
	lpfnSetupHook       As LPSETUPHOOKPROC
	lpPrintTemplateName As LPCWSTR
	lpSetupTemplateName As LPCWSTR
	hPrintTemplate      As HGLOBAL
	hSetupTemplate      As HGLOBAL
End Type
#ifdef _WIN64
Type PRINTDLGA
#else
Type Align(1) PRINTDLGA
#endif
	lStructSize         As DWord
	hwndOwner           As HWND
	hDevMode            As HGLOBAL
	hDevNames           As HGLOBAL
	hDC                 As HDC
	Flags               As DWord
	nFromPage           As Word
	nToPage             As Word
	nMinPage            As Word
	nMaxPage            As Word
	nCopies             As Word
	hInstance           As HINSTANCE
	lCustData           As LPARAM
	lpfnPrintHook       As LPPAGEPAINTHOOK
	lpfnSetupHook       As LPSETUPHOOKPROC
	lpPrintTemplateName As LPCSTR
	lpSetupTemplateName As LPCSTR
	hPrintTemplate      As HGLOBAL
	hSetupTemplate      As HGLOBAL
End Type
#ifdef UNICODE
TypeDef PRINTDLG = PRINTDLGW
#else
TypeDef PRINTDLG = PRINTDLGA
#endif
Declare Function PrintDlg Lib "comdlg32" Alias _FuncName_PrintDlg (ByRef pd As PRINTDLG) As BOOL
