当前位置: 代码迷 >> PB >> 使用tx textcontrol控件的打印对话框有关问题
  详细解决方案

使用tx textcontrol控件的打印对话框有关问题

热度:13   发布时间:2016-04-29 08:38:15.0
使用tx textcontrol控件的打印对话框问题
自带的例子中在点打印时弹出的打印对话框(应是windows通用的那个)
如何在pb中实现?pb如何调用CommonDialog

我看了下vb的代码如下:
cmdlg.Copies = 1
  cmdlg.FromPage = 1
  cmdlg.ToPage = tx.CurrentPages
  cmdlg.Min = 1
  cmdlg.Max = tx.CurrentPages
  cmdlg.Flags = cdlPDHidePrintToFile Or cdlPDNoSelection
  cmdlg.CancelError = True
  cmdlg.ShowPrinter
cmdlg As CommonDialog
tx.PrintDoc tx.Parent.Caption, cmdlg.FromPage, cmdlg.ToPage, cmdlg.Copies


------解决方案--------------------
保存为本地文件nvo_commdlg.sru,然后导入pbl,自己看看
C/C++ code
$PBExportHeader$nvo_commdlg.sru$PBExportComments$Common dialog encapsulationforwardglobal type nvo_commdlg from nonvisualobjectend typetype openfilename from structure within nvo_commdlgend typetype printdlg from structure within nvo_commdlgend typetype devmode from structure within nvo_commdlgend typetype devnames from structure within nvo_commdlgend typetype choosefont from structure within nvo_commdlgend typetype logfont from structure within nvo_commdlgend typeend forwardtype OPENFILENAME from structure    long        lstructsize    long        hwndowner    long        hinstance    long        lpstrfilter    long        lpstrcustomfilter    long        nMaxCustomFilter    long        nFilterIndex    long        lpstrFile    long        nMaxFile    long        lpstrFileTitle    long        nMaxFileTitle    long        lpstrInitialDir    long        lpstrTitle    long        Flags    integer        nFileOffset    integer        nFileExtension    long        lpstrDefExt    long        lCustData    long        lpfnHook    long        lpTemplateNameend typetype PRINTDLG from structure    long        lStructSize    long        hWndOwner    long        hDevMode    long        hDevNames    long        hDC    long        Flags    integer        nFromPage    integer        nToPage    integer        nMinPage    integer        nMaxPage    integer        nCopies    long        hInstance    long        lCustData    long        lpfnPrintHook    long        lpfnSetupHook    long        lpPrintTemplateName    long        lpSetupTemplateName    long        hPrintTemplate    long        hSetupTemplateend typetype devmode from structure    character        dmDeviceName[32]    integer        dmSpecVersion    integer        dmDriverVersion    integer        dmSize    integer        dmDriverExtra    long        dmFields    integer        dmOrientation    integer        dmPaperSize    integer        dmPaperLength    integer        dmPaperWidth    integer        dmScale    integer        dmCopies    integer        dmDefaultSource    integer        dmPrintQuality    integer        dmColor    integer        dmDuplex    integer        dmYResolution    integer        dmTTOption    integer        dmCollate    character        dmFormName[32]    integer        dmLogPixels    long        dmBitsPerPel    long        dmPelsWidth    long        dmPelsHeight    long        dmDisplayFlags    long        dmDisplayFrequency    long        dmICMMethod    long        dmICMIntent    long        dmMediaType    long        dmDitherType    long        dmReserved1    long        dmReserved2end typetype devnames from structure    integer        wDriverOffset    integer        wDeviceOffset    integer        wOutputOffset    integer        wDefaultend typetype CHOOSEFONT from structure    long        lStructSize    long        hWndOwner    long        hDC    long        lpLogFont    long        iPointSize    long        Flags    long        RGBColors    long        lCustData    long        lpfnHook    long        lpTemplateName    long        hInstance    long        lpszStyle    integer        nFontType    integer        ___MISSING_ALIGNMENT__    long        nSizeMin    long        nSizeMaxend typetype logfont from structure    long        lfheight    long        lfwidth    long        lfescapement    long        lforientation    long        lfweight    character        lfitalic    character        lfunderline    character        lfstrikeout    character        lfcharset    character        lfoutprecision    character        lfclipprecision    character        lfquality    character        lfpitchandfamily    character        lffacename[32]end typeglobal type nvo_commdlg from nonvisualobject autoinstantiateend typetype prototypes// Common Dialog External FunctionsFunction long GetOpenFileNameA(REF OPENFILENAME OpenFileName) library "comdlg32.dll"Function long GetSaveFileNameA(REF OPENFILENAME SaveFileName) library "comdlg32.dll"Function long PrintDlgA(REF PRINTDLG PrintDlg) library "comdlg32.dll"Function long ChooseFontA(REF CHOOSEFONT ChooseFont) library "comdlg32.dll"// Memory FunctionsFunction long GetDevMode(REF DEVMODE Destination, long Source, long Size) library "kernel32.dll" Alias For "RtlMoveMemory"Function long GetDevNames(REF DEVNAMES Destination, long Source, long Size) library "kernel32.dll" Alias For "RtlMoveMemory"Function long GetLogFont(REF LOGFONT Destination, long Source, long Size) library "kernel32.dll" Alias For "RtlMoveMemory"Function long PutLogFont(long Destination, REF LOGFONT Source, long Size) library "kernel32.dll" Alias For "RtlMoveMemory"Function long StrCopy(long Destination, REF string Source, long Size) library "kernel32.dll"  Alias for "RtlMoveMemory"Function long LocalAlloc(long Flagss, long Bytes) library "kernel32.dll"Function long LocalFree(long MemHandle) library "kernel32.dll"Function long CommDlgExtendedError() library "comdlg32.dll"Function long lstrcpy(long Destination, REF string Source) library "kernel32.dll"Function long LocalLock(long Handle) library "kernel32.dll"Function long LocalUnlock(long Handle) library "kernel32.dll"// Misc FunctionsFunction long GetWindowsDirectoryA(REF string Buffer, long Size) library "kernel32.dll"end prototypestype variables// *****************************************************************// All Dialogs members// *****************************************************************PUBLIC long Flags = 0        // Dialog FlagsPUBLIC long hWndParent = 0        // Parent Window// *****************************************************************// Open & Save Dialog public members// *****************************************************************Public:string Filter = ""        // description1~tfilter1~tdescription2~tfilter2integer FilterIndex = 1    // Default filter indexstring InitialDir  = ""         // Default directorystring Title = ""        // Dialog TitlePROTECTEDWRITE string Filename = ""         // returns selected filePROTECTEDWRITE string Files[]        // Selected FilesPROTECTEDWRITE string PathName        // PathPROTECTEDWRITE integer FileCount        // Number of selected files// Flags constantsCONSTANT long OFN_READONLY            = 1CONSTANT long OFN_OVERWRITEPROMPT        = 2CONSTANT long OFN_HIDEREADONLY        = 4CONSTANT long OFN_NOCHANGEDIR        = 8CONSTANT long OFN_SHOWHELP            = 16CONSTANT long OFN_ENABLEHOOK            = 32CONSTANT long OFN_ENABLETEMPLATE        = 64CONSTANT long OFN_ENABLETEMPLATEHANDLE    = 128CONSTANT long OFN_NOVALIDATE            = 256CONSTANT long OFN_ALLOWMULTISELECT        = 512CONSTANT long OFN_EXTENSIONDIFFERENT        = 1024CONSTANT long OFN_PATHMUSTEXIST        = 2048CONSTANT long OFN_FILEMUSTEXIST        = 4096CONSTANT long OFN_CREATEPROMPT        = 8192CONSTANT long OFN_SHAREAWARE            = 16384CONSTANT long OFN_NOREADONLYRETURN        = 32768CONSTANT long OFN_NOTESTFILECREATE        = 65536CONSTANT long OFN_NONETWORKBUTTON        = 131072CONSTANT long OFN_NOLONGNAMES        = 262144CONSTANT long OFN_EXPLORER            = 524288CONSTANT long OFN_NODEREFERENCELINKS    = 1048576CONSTANT long OFN_LONGNAMES            = 2097152// *****************************************************************// Print dialog public members// *****************************************************************integer FromPage    = 1integer ToPage    = 1integer MinPage     = 1integer MaxPage     = 0PROTECTEDWRITE integer Copies = 1 // Flags constantsCONSTANT long PD_ALLPAGES            = 0CONSTANT long PD_SELECTION             = 1CONSTANT long PD_PAGENUMS             = 2CONSTANT long PD_NOSELECTION             = 4CONSTANT long PD_NOPAGENUMS             = 8CONSTANT long PD_COLLATE            = 16CONSTANT long PD_PRINTTOFILE             = 32CONSTANT long PD_PRINTSETUP             = 64CONSTANT long PD_NOWARNING             = 128CONSTANT long PD_RETURNDC             = 256CONSTANT long PD_RETURNIC             = 512CONSTANT long PD_RETURNDEFAULT         = 1024CONSTANT long PD_SHOWHELP             = 2048CONSTANT long PD_ENABLEPRINTHOOK         = 4096CONSTANT long PD_ENABLESETUPHOOK         = 8192CONSTANT long PD_ENABLEPRINTTEMPLATE     = 16384CONSTANT long PD_ENABLESETUPTEMPLATE    = 32768CONSTANT long PD_ENABLEPRINTTEMPLATEHANDLE    = 65536CONSTANT long PD_ENABLESETUPTEMPLATEHANDLE = 131072CONSTANT long PD_USEDEVMODECOPIES         = 262144CONSTANT long PD_USEDEVMODECOPIESANDCOLLATE= 262144CONSTANT long PD_DISABLEPRINTTOFILE        = 524288 CONSTANT long PD_HIDEPRINTTOFILE        = 1048576 CONSTANT long PD_NONETWORKBUTTON         = 2097152// *****************************************************************// Font dialog public members// *****************************************************************long RGBColors    = 0integer FontType    = 0integer SizeMin    = 0integer SizeMax    = 0string FaceName    = ""long  Height    = 0long  Weight    = 0boolean Italic    = Falseboolean Underline    = Falseboolean StrikeOut    = False// Flags constantsCONSTANT long CF_SCREENFONTS             = 1CONSTANT long CF_PRINTERFONTS             = 2CONSTANT long CF_BOTH                 = 3CONSTANT long CF_SHOWHELP             = 4CONSTANT long CF_ENABLEHOOK             = 8CONSTANT long CF_ENABLETEMPLATE         = 16CONSTANT long CF_ENABLETEMPLATEHANDLE     = 32CONSTANT long CF_INITTOLOGFONTSTRUCT         = 64CONSTANT long CF_USESTYLE             = 128CONSTANT long CF_EFFECTS             = 256CONSTANT long CF_APPLY                 = 512CONSTANT long CF_ANSIONLY             = 1024CONSTANT long CF_SCRIPTSONLY             = CF_ANSIONLYCONSTANT long CF_NOVECTORFONTS         = 2048CONSTANT long CF_NOOEMFONTS             = 4096CONSTANT long CF_NOSIMULATIONS         = 8192CONSTANT long CF_LIMITSIZE            = 16384CONSTANT long CF_FIXEDPITCHONLY         = 32768CONSTANT long CF_WYSIWYG             = 65536CONSTANT long CF_FORCEFONTEXIST         = 131072CONSTANT long CF_SCALABLEONLY            = 262144CONSTANT long CF_TTONLY             = 524288CONSTANT long CF_NOFACESEL            = 1048576CONSTANT long CF_NOSTYLESEL             = 2097152 CONSTANT long CF_NOSIZESEL             = 4194304CONSTANT long CF_SELECTSCRIPT             = 8388608CONSTANT long CF_NOSCRIPTSEL             = 16777216CONSTANT long CF_NOVERTFONTS             = 33554432// FontType constantsCONSTANT integer BOLD_FONTTYPE     = 256CONSTANT integer ITALIC_FONTTYPE     = 512CONSTANT integer REGULAR_FONTTYPE     = 1024CONSTANT integer SCREEN_FONTTYPE     = 8192CONSTANT integer PRINTER_FONTTYPE     = 16384CONSTANT integer SIMULATED_FONTTYPE     = 32768
  相关解决方案