?? mcommondialog.bas
字號:
Attribute VB_Name = "mCommonDialog"
Option Explicit
'********************************************************************************
'CopyRight:重慶康諾數碼科技有限公司Smart項目組
'Date:2004-5-2
'********************************************************************************
' ==========================================================================
' API declares:
' ==========================================================================
Public Enum EErrorCommonDialog
eeBaseCommonDialog = 13450 ' CommonDialog
End Enum
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalCompact Lib "kernel32" (ByVal dwMinFree As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalReAlloc Lib "kernel32" (ByVal hMem As Long, ByVal dwBytes As Long, ByVal wFlags As Long) As Long
Private Declare Function GlobalSize Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Sub CopyMemoryStr Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, ByVal lpvSource As String, ByVal cbCopy As Long)
Private Const MAX_PATH = 260
Private Const MAX_FILE = 260
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Private Type OPENFILENAME
lStructSize As Long ' Filled with UDT size
hwndOwner As Long ' Tied to Owner
hInstance As Long ' Ignored (used only by templates)
lpstrFilter As String ' Tied to Filter
lpstrCustomFilter As String ' Ignored (exercise for reader)
nMaxCustFilter As Long ' Ignored (exercise for reader)
nFilterIndex As Long ' Tied to FilterIndex
lpstrFile As String ' Tied to FileName
nMaxFile As Long ' Handled internally
lpstrFileTitle As String ' Tied to FileTitle
nMaxFileTitle As Long ' Handled internally
lpstrInitialDir As String ' Tied to InitDir
lpstrTitle As String ' Tied to DlgTitle
flags As Long ' Tied to Flags
nFileOffset As Integer ' Ignored (exercise for reader)
nFileExtension As Integer ' Ignored (exercise for reader)
lpstrDefExt As String ' Tied to DefaultExt
lCustData As Long ' Ignored (needed for hooks)
lpfnHook As Long ' Ignored (good luck with hooks)
lpTemplateName As Long ' Ignored (good luck with templates)
End Type
Private Declare Function GetOpenFileName Lib "COMDLG32" Alias "GetOpenFileNameA" (file As OPENFILENAME) As Long
Private Declare Function GetSaveFileName Lib "COMDLG32" Alias "GetSaveFileNameA" (file As OPENFILENAME) As Long
Private Declare Function GetFileTitle Lib "COMDLG32" Alias "GetFileTitleA" (ByVal szFile As String, ByVal szTitle As String, ByVal cbBuf As Long) As Long
Public Enum EOpenFile
OFN_READONLY = &H1
OFN_OVERWRITEPROMPT = &H2
OFN_HIDEREADONLY = &H4
OFN_NOCHANGEDIR = &H8
OFN_SHOWHELP = &H10
OFN_ENABLEHOOK = &H20
OFN_ENABLETEMPLATE = &H40
OFN_ENABLETEMPLATEHANDLE = &H80
OFN_NOVALIDATE = &H100
OFN_ALLOWMULTISELECT = &H200
OFN_EXTENSIONDIFFERENT = &H400
OFN_PATHMUSTEXIST = &H800
OFN_FILEMUSTEXIST = &H1000
OFN_CREATEPROMPT = &H2000
OFN_SHAREAWARE = &H4000
OFN_NOREADONLYRETURN = &H8000
OFN_NOTESTFILECREATE = &H10000
OFN_NONETWORKBUTTON = &H20000
OFN_NOLONGNAMES = &H40000
OFN_EXPLORER = &H80000
OFN_NODEREFERENCELINKS = &H100000
OFN_LONGNAMES = &H200000
OFN_ENABLEINCLUDENOTIFY = &H400000 '// send include message to callback
OFN_ENABLESIZING = &H800000
OFN_NOREADONLYRETURN_C = &H8000&
End Enum
Private Type TCHOOSECOLOR
lStructSize As Long
hwndOwner As Long
hInstance As Long
rgbResult As Long
lpCustColors As Long
flags As Long
lCustData As Long
lpfnHook As Long
lpTemplateName As Long
End Type
Private Declare Function ChooseColor Lib "COMDLG32.DLL" Alias "ChooseColorA" (Color As TCHOOSECOLOR) As Long
Public Enum EChooseColor
CC_RGBInit = &H1
CC_FullOpen = &H2
CC_PreventFullOpen = &H4
CC_ColorShowHelp = &H8
' Win95 only
CC_SolidColor = &H80
CC_AnyColor = &H100
' End Win95 only
CC_ENABLEHOOK = &H10
CC_ENABLETEMPLATE = &H20
CC_EnableTemplateHandle = &H40
End Enum
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Private Type TCHOOSEFONT
lStructSize As Long ' Filled with UDT size
hwndOwner As Long ' Caller's window handle
hdc As Long ' Printer DC/IC or NULL
lpLogFont As Long ' Pointer to LOGFONT
iPointSize As Long ' 10 * size in points of font
flags As Long ' Type flags
rgbColors As Long ' Returned text color
lCustData As Long ' Data passed to hook function
lpfnHook As Long ' Pointer to hook function
lpTemplateName As Long ' Custom template name
hInstance As Long ' Instance handle for template
lpszStyle As String ' Return style field
nFontType As Integer ' Font type bits
iAlign As Integer ' Filler
nSizeMin As Long ' Minimum point size allowed
nSizeMax As Long ' Maximum point size allowed
End Type
Private Declare Function ChooseFont Lib "COMDLG32" Alias "ChooseFontA" (chfont As TCHOOSEFONT) As Long
Private Const LF_FACESIZE = 32
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(LF_FACESIZE) As Byte
End Type
Public Enum EChooseFont
CF_ScreenFonts = &H1
CF_PrinterFonts = &H2
CF_BOTH = &H3
CF_FontShowHelp = &H4
CF_UseStyle = &H80
CF_EFFECTS = &H100
CF_AnsiOnly = &H400
CF_NoVectorFonts = &H800
CF_NoOemFonts = CF_NoVectorFonts
CF_NoSimulations = &H1000
CF_LimitSize = &H2000
CF_FixedPitchOnly = &H4000
CF_WYSIWYG = &H8000 ' Must also have ScreenFonts And PrinterFonts
CF_ForceFontExist = &H10000
CF_ScalableOnly = &H20000
CF_TTOnly = &H40000
CF_NoFaceSel = &H80000
CF_NoStyleSel = &H100000
CF_NoSizeSel = &H200000
' Win95 only
CF_SelectScript = &H400000
CF_NoScriptSel = &H800000
CF_NoVertFonts = &H1000000
CF_InitToLogFontStruct = &H40
CF_Apply = &H200
CF_EnableHook = &H8
CF_EnableTemplate = &H10
CF_EnableTemplateHandle = &H20
CF_FontNotSupported = &H238
CF_WYSIWYG_C = &H8000&
End Enum
' These are extra nFontType bits that are added to what is returned to the
' EnumFonts callback routine
Public Enum EFontType
Simulated_FontType = &H8000
Printer_FontType = &H4000
Screen_FontType = &H2000
Bold_FontType = &H100
Italic_FontType = &H200
Regular_FontType = &H400
Simulated_FontType_C = &H8000&
End Enum
Private Type TPRINTDLG
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
hdc As Long
flags As Long
nFromPage As Integer
nToPage As Integer
nMinPage As Integer
nMaxPage As Integer
nCopies As Integer
hInstance As Long
lCustData As Long
lpfnPrintHook As Long
lpfnSetupHook As Long
lpPrintTemplateName As Long
lpSetupTemplateName As Long
hPrintTemplate As Long
hSetupTemplate As Long
End Type
' DEVMODE collation selections
Private Const DMCOLLATE_FALSE = 0
Private Const DMCOLLATE_TRUE = 1
Private Declare Function PrintDlg Lib "COMDLG32.DLL" Alias "PrintDlgA" (prtdlg As TPRINTDLG) As Integer
Public Enum EPrintDialog
PD_ALLPAGES = &H0
PD_SELECTION = &H1
PD_PAGENUMS = &H2
PD_NOSELECTION = &H4
PD_NOPAGENUMS = &H8
PD_COLLATE = &H10
PD_PRINTTOFILE = &H20
PD_PRINTSETUP = &H40
PD_NOWARNING = &H80
PD_RETURNDC = &H100
PD_RETURNIC = &H200
PD_RETURNDEFAULT = &H400
PD_SHOWHELP = &H800
PD_ENABLEPRINTHOOK = &H1000
PD_ENABLESETUPHOOK = &H2000
PD_ENABLEPRINTTEMPLATE = &H4000
PD_ENABLESETUPTEMPLATE = &H8000
PD_ENABLEPRINTTEMPLATEHANDLE = &H10000
PD_ENABLESETUPTEMPLATEHANDLE = &H20000
PD_USEDEVMODECOPIES = &H40000
PD_USEDEVMODECOPIESANDCOLLATE = &H40000
PD_DISABLEPRINTTOFILE = &H80000
PD_HIDEPRINTTOFILE = &H100000
PD_NONETWORKBUTTON = &H200000
PD_ENABLESETUPTEMPLATE_C = &H8000
End Enum
Private Type DEVNAMES
wDriverOffset As Integer
wDeviceOffset As Integer
wOutputOffset As Integer
wDefault As Integer
End Type
Private Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32
Private Type DevMode
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
' New Win95 Page Setup dialogs are up to you
Private Type POINTL
x As Long
y As Long
End Type
Private Type RECT
left As Long
tOp As Long
Right As Long
Bottom As Long
End Type
Private Type TPAGESETUPDLG
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
flags As Long
ptPaperSize As POINTL
rtMinMargin As RECT
rtMargin As RECT
hInstance As Long
lCustData As Long
lpfnPageSetupHook As Long
lpfnPagePaintHook As Long
lpPageSetupTemplateName As Long
hPageSetupTemplate As Long
End Type
' EPaperSize constants same as vbPRPS constants
Public Enum EPaperSize
epsLetter = 1 ' Letter, 8 1/2 x 11 in.
epsLetterSmall ' Letter Small, 8 1/2 x 11 in.
epsTabloid ' Tabloid, 11 x 17 in.
epsLedger ' Ledger, 17 x 11 in.
epsLegal ' Legal, 8 1/2 x 14 in.
epsStatement ' Statement, 5 1/2 x 8 1/2 in.
epsExecutive ' Executive, 7 1/2 x 10 1/2 in.
epsA3 ' A3, 297 x 420 mm
epsA4 ' A4, 210 x 297 mm
epsA4Small ' A4 Small, 210 x 297 mm
epsA5 ' A5, 148 x 210 mm
epsB4 ' B4, 250 x 354 mm
epsB5 ' B5, 182 x 257 mm
epsFolio ' Folio, 8 1/2 x 13 in.
epsQuarto ' Quarto, 215 x 275 mm
eps10x14 ' 10 x 14 in.
eps11x17 ' 11 x 17 in.
epsNote ' Note, 8 1/2 x 11 in.
epsEnv9 ' Envelope #9, 3 7/8 x 8 7/8 in.
epsEnv10 ' Envelope #10, 4 1/8 x 9 1/2 in.
epsEnv11 ' Envelope #11, 4 1/2 x 10 3/8 in.
epsEnv12 ' Envelope #12, 4 1/2 x 11 in.
epsEnv14 ' Envelope #14, 5 x 11 1/2 in.
epsCSheet ' C size sheet
epsDSheet ' D size sheet
epsESheet ' E size sheet
epsEnvDL ' Envelope DL, 110 x 220 mm
epsEnvC3 ' Envelope C3, 324 x 458 mm
epsEnvC4 ' Envelope C4, 229 x 324 mm
epsEnvC5 ' Envelope C5, 162 x 229 mm
epsEnvC6 ' Envelope C6, 114 x 162 mm
epsEnvC65 ' Envelope C65, 114 x 229 mm
epsEnvB4 ' Envelope B4, 250 x 353 mm
epsEnvB5 ' Envelope B5, 176 x 250 mm
epsEnvB6 ' Envelope B6, 176 x 125 mm
epsEnvItaly ' Envelope, 110 x 230 mm
epsenvmonarch ' Envelope Monarch, 3 7/8 x 7 1/2 in.
epsEnvPersonal ' Envelope, 3 5/8 x 6 1/2 in.
epsFanfoldUS ' U.S. Standard Fanfold, 14 7/8 x 11 in.
epsFanfoldStdGerman ' German Standard Fanfold, 8 1/2 x 12 in.
epsFanfoldLglGerman ' German Legal Fanfold, 8 1/2 x 13 in.
epsUser = 256 ' User-defined
End Enum
' EPrintQuality constants same as vbPRPQ constants
Public Enum EPrintQuality
epqDraft = -1
epqLow = -2
epqMedium = -3
epqHigh = -4
End Enum
Public Enum eOrientation
eoPortrait = 1
eoLandscape
End Enum
Private Declare Function PageSetupDlg Lib "COMDLG32" Alias "PageSetupDlgA" (lppage As TPAGESETUPDLG) As Boolean
Public Enum EPageSetup
PSD_Defaultminmargins = &H0 ' Default (printer's)
PSD_InWinIniIntlMeasure = &H0
PSD_MINMARGINS = &H1
PSD_MARGINS = &H2
PSD_INTHOUSANDTHSOFINCHES = &H4
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -