home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / TextToPict2084669252007.psc / CdlgEx.cls < prev    next >
Text File  |  2007-08-13  |  20KB  |  703 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CommonDialog"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
  15. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  16. 'General Declarations
  17. Option Explicit
  18. Private Type BROWSEINFO  ' Folder Dialog
  19.    hOwner           As Long
  20.    pidlRoot         As Long
  21.    pszDisplayName   As String
  22.    lpszTitle        As String
  23.    ulFlags          As Long
  24.    lpfn             As Long
  25.    lParam           As Long
  26.    iImage           As Long
  27. End Type
  28.  
  29. Private Type OPENFILENAME 'Open & Save Dialog
  30.     lStructSize As Long
  31.     hWndOwner As Long
  32.     hInstance As Long
  33.     lpstrFilter As String
  34.     lpstrCustomFilter As String
  35.     nMaxCustFilter As Long
  36.     nFilterIndex As Long
  37.     lpstrFile As String
  38.     nMaxFile As Long
  39.     lpstrFileTitle As String
  40.     nMaxFileTitle As Long
  41.     lpstrInitialDir As String
  42.     lpstrTitle As String
  43.     Flags As Long
  44.     nFileOffset As Integer
  45.     nFileExtension As Integer
  46.     lpstrDefExt As String
  47.     lCustData As Long
  48.     lpfnHook As Long
  49.     lpTemplateName As String
  50. End Type
  51.  
  52. Private Type CHOOSECOLOR 'Color Dialog
  53.     lStructSize As Long
  54.     hWndOwner As Long
  55.     hInstance As Long
  56.     rgbResult As Long
  57.     lpCustColors As String
  58.     Flags As Long
  59.     lCustData As Long
  60.     lpfnHook As Long
  61.     lpTemplateName As String
  62. End Type
  63.  
  64. Const LF_FACESIZE = 32 'Font Dialog
  65. Private Type LOGFONT 'Font Dialog
  66.     lfHeight As Long
  67.     lfWidth As Long
  68.     lfEscapement As Long
  69.     lfOrientation As Long
  70.     lfWeight As Long
  71.     lfItalic As Byte
  72.     lfUnderline As Byte
  73.     lfStrikeOut As Byte
  74.     lfCharSet As Byte
  75.     lfOutPrecision As Byte
  76.     lfClipPrecision As Byte
  77.     lfQuality As Byte
  78.     lfPitchAndFamily As Byte
  79.     lfFaceName(LF_FACESIZE) As Byte
  80. End Type
  81.  
  82. Private Type ChooseFont 'Font Dialog
  83.     lStructSize As Long
  84.     hWndOwner As Long
  85.     hdc As Long
  86.     lpLogFont As Long
  87.     iPointSize As Long
  88.     Flags As Long
  89.     rgbColors As Long
  90.     lCustData As Long
  91.     lpfnHook As Long
  92.     lpTemplateName As String
  93.     hInstance As Long
  94.     lpszStyle As String
  95.     nFontType As Integer
  96.     MISSING_ALIGNMENT As Integer
  97.     nSizeMin As Long
  98.     nSizeMax As Long
  99. End Type
  100. ' extra font constant
  101. Const CF_INITTOLOGFONTSTRUCT = &H40&
  102. Const SCREEN_FONTTYPE = &H2000
  103. Const BOLD_FONTTYPE = &H100
  104. Const FW_BOLD = 700
  105. Const LOGPIXELSY = 90
  106.  
  107. Private Type PrintDlg 'PrintDialog
  108.     lStructSize As Long
  109.     hWndOwner As Long
  110.     hDevMode As Long
  111.     hDevNames As Long
  112.     hdc As Long
  113.     Flags As Long
  114.     nFromPage As Integer
  115.     nToPage As Integer
  116.     nMinPage As Integer
  117.     nMaxPage As Integer
  118.     nCopies As Integer
  119.     hInstance As Long
  120.     lCustData As Long
  121.     lpfnPrintHook As Long
  122.     lpfnSetupHook As Long
  123.     lpPrintTemplateName As String
  124.     lpSetupTemplateName As String
  125.     hPrintTemplate As Long
  126.     hSetupTemplate As Long
  127. End Type
  128.  
  129. Const CCHDEVICENAME = 32 'PrintDialog
  130. Const CCHFORMNAME = 32 'PrintDialog
  131. Private Type DEVMODE 'PrintDialog
  132.     dmDeviceName As String * CCHDEVICENAME
  133.     dmSpecVersion As Integer
  134.     dmDriverVersion As Integer
  135.     dmSize As Integer
  136.     dmDriverExtra As Integer
  137.     dmFields As Long
  138.     dmOrientation As Integer
  139.     dmPaperSize As Integer
  140.     dmPaperLength As Integer
  141.     dmPaperWidth As Integer
  142.     dmScale As Integer
  143.     dmCopies As Integer
  144.     dmDefaultSource As Integer
  145.     dmPrintQuality As Integer
  146.     dmColor As Integer
  147.     dmDuplex As Integer
  148.     dmYResolution As Integer
  149.     dmTTOption As Integer
  150.     dmCollate As Integer
  151.     dmFormName As String * CCHFORMNAME
  152.     dmUnusedPadding As Integer
  153.     dmBitsPerPel As Integer
  154.     dmPelsWidth As Long
  155.     dmPelsHeight As Long
  156.     dmDisplayFlags As Long
  157.     dmDisplayFrequency As Long
  158. End Type
  159.  
  160. Private Type DEVNAMES 'PrintDialog
  161.     wDriverOffset As Integer
  162.     wDeviceOffset As Integer
  163.     wOutputOffset As Integer
  164.     wDefault As Integer
  165.     extra As String * 100
  166. End Type
  167. 'extra printer constants - for Printer Dialog
  168. Const DM_DUPLEX = &H1000&
  169. Const DM_ORIENTATION = &H1&
  170. ' memory management constants - for Printer Dialog
  171. Const GMEM_MOVEABLE = &H2
  172. Const GMEM_ZEROINIT = &H40
  173.  
  174.  
  175. ' ------------- Dialog calling functions
  176. ' -------------- Standard
  177. 'Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
  178. 'Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
  179. Private Declare Function ChooseColorAPI Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long
  180. Private Declare Function ChooseFont Lib "comdlg32.dll" Alias "ChooseFontA" (pChoosefont As ChooseFont) As Long
  181. 'Private Declare Function PrintDlg Lib "comdlg32.dll" Alias "PrintDlgA" (pPrintdlg As PrintDlg) As Long
  182. 'Private Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal hOwner As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long
  183. Private Declare Function SHAbout Lib "Shell32" Alias "ShellAboutA" (ByVal hOwner As Long, ByVal sAppName As String, ByVal sPrompt As String, ByVal hicon As Long) As Long
  184.  
  185. ' GDI functions
  186. ' For Font Dialog
  187. Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
  188. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  189. Private Declare Function GetTextFace Lib "gdi32" Alias "GetTextFaceA" (ByVal hdc As Long, ByVal nCount As Long, ByVal lpFacename As String) As Long
  190. Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
  191.  
  192.  
  193. ' user32 functions
  194. ' For Font and Printer Dialog
  195. Private Declare Function GetDC Lib "user32" (ByVal hOwner As Long) As Long
  196.  
  197. ' kernel32 functions
  198. ' For Font Dialog
  199. Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (p1 As Any, p2 As Any) As Long
  200. ' For Printer Dialog
  201. Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
  202. Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
  203. Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
  204. Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
  205. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
  206.  
  207.  
  208. ' common dialog action types
  209.  
  210. Public Enum CdlgExt_Actions
  211.        cdlgOpen = 1
  212.        cdlgSave = 2
  213.        cdlgColor = 3
  214.        cdlgFont = 4
  215.        cdlgPrinter = 5
  216.        cdlgHelp = 6
  217.        cdlgAbout = 7
  218.        cdlgFolder = 8
  219.        cdlgFormat = 9
  220.        cdlgIcon = 10
  221.    '    cdlgObjectProp = 11
  222.        cdlgRestart = 12
  223.        cdlgRun = 13
  224.        cdlgShutDown = 14
  225.  End Enum
  226.  
  227.  Public Enum CdlgEx_IconSize
  228.        IconSizeSmall = 16
  229.        IconSizeLarge = 32
  230.  End Enum
  231.  
  232. ' --------------- Enum Flags r 10-2-05
  233. Public Enum CdlgExt_Flags
  234.  ' Open & Save Dialog
  235.  cdlOFNAllowMultiselect = &H200
  236.  cdlOFNCreatePrompt = &H2000
  237.  cdlOFNExplorer = &H80000
  238.  cdlOFNExtensionDifferent = &H400
  239.  cdlOFNFileMustExist = &H1000
  240.  cdlOFNHelpButton = &H10
  241.  cdlOFNHideReadOnly = &H4
  242.  cdlOFNLongNames = &H200000
  243.  cdlOFNNoChangeDir = &H8
  244.  cdlOFNNoDereferenceLinks = &H100000
  245.  cdlOFNNoLongNames = &H40000
  246.  cdlOFNNoReadOnlyReturn = &H8000
  247.  cdlOFNNoValidate = &H100
  248.  cdlOFNOverwritePrompt = &H2
  249.  cdlOFNPathMustExist = &H800
  250.  cdlOFNReadOnly = &H1
  251.  cdlOFNShareAware = &H4000
  252.  'Color Dialog
  253.  cdlCCFullOpen = &H2
  254.  cdlCCHelpButton = &H8
  255.  cdlCCPreventFullOpen = &H4
  256.  cdlCCRGBInit = &H1
  257. ' Printer Dialog
  258.  cdlPDAllPages = &H0
  259.  cdlPDCollate = &H10
  260.  cdlPDDisablePrintToFile = &H80000
  261.  cdlPDHelpButton = &H800
  262.  cdlPDHidePrintToFile = &H100000
  263.  cdlPDNoPageNums = &H8
  264.  cdlPDNoSelection = &H4
  265.  cdlPDNoWarning = &H80
  266.  cdlPDPageNums = &H2
  267.  cdlPDPrintSetup = &H40
  268.  cdlPDPrintToFile = &H20
  269.  cdlPDReturnDC = &H100
  270.  cdlPDReturnDefault = &H400
  271.  cdlPDReturnIC = &H200
  272.  cdlPDSelection = &H1
  273.  cdlPDUseDevModeCopies = &H40000
  274. ' Font Dialog
  275.  cdlCFANSIOnly = &H400
  276.  cdlCFApply = &H200
  277.  cdlCFBoth = &H3
  278.  cdlCFEffects = &H100
  279.  cdlCFFixedPitchOnly = &H4000
  280.  cdlCFForceFontExist = &H10000
  281.  cdlCFHelpButton = &H4
  282.  cdlCFLimitSize = &H2000
  283.  cdlCFNoFaceSel = &H80000
  284.  cdlCFNoSimulations = &H1000
  285.  cdlCFNoSizeSel = &H200000
  286.  cdlCFNoStyleSel = &H100000
  287.  cdlCFNoVectorFonts = &H800
  288.  cdlCFPrinterFonts = &H2
  289.  cdlCFScalableOnly = &H20000
  290.  cdlCFScreenFonts = &H1
  291.  cdlCFTTOnly = &H40000
  292.  cdlCFWYSIWYG = &H8000
  293. ' Other Dialog
  294.  'Restart Dialog
  295.  Restart_Logoff = &H0
  296.  Restart_ShutDown = &H1
  297.  Restart_Reboot = &H2
  298.  Restart_Force = &H4
  299.  ' Run Dialog
  300.  Run_NoBrowse = &H10
  301.  Run_NoDefault = &H20
  302.  Run_CalcDir = &H40
  303.  Run_NoLable = &H80
  304.  ' Properties Dialog
  305.  ObjProp_System = &H0
  306.  ObjProp_Printer = &H100
  307.  ObjProp_File = &H200
  308.  ObjProp_Mouse = &H300
  309.  ObjProp_Locale = &H400
  310.  ObjProp_MMedia = &H500
  311.  ObjProp_TimeDate = &H600
  312.  ObjProp_Network = &H700
  313.  ObjProp_Screen = &H800
  314.  ObjProp_Internet = &H900
  315.  ' Browse for Folder Dialog
  316.  Folder_COMPUTER = &H1000
  317.  Folder_PRINTER = &H2000
  318.  Folder_INCLUDEFILES = &H4001
  319. End Enum
  320. 'Enum Help Commands
  321. Public Enum CdlgExt_HelpCommand
  322.  HelpCommandHelp = &H102&
  323.  HelpContents = &H3&
  324.  HelpContext = &H1
  325.  HelpContextPOPUP = &H8&
  326.  HelpForceFile = &H9&
  327.  HelpHelpOnHelp = &H4
  328.  HelpIndex = &H3
  329.  HelpKeyHelp = &H101
  330.  HelpPartialKey = &H105&
  331.  HelpQuit = &H2
  332.  HelpSetContents = &H5&
  333.  HelpSetIndex = &H5
  334.  HelpMultiKey = &H201&
  335.  HelpSetWinPos = &H203&
  336. End Enum
  337.  
  338. Private retvalue As Long 'General
  339. Const MAX_PATH = 260 'General
  340. Private OFN As OPENFILENAME ' Open & Save Dialog
  341.  
  342. 'Inner variables for properties
  343. Private mFileName As String
  344. Private mFileTitle As String
  345. Private mhOwner As Long
  346. Private mDialogTitle As String
  347. Private mFilter As String
  348. Private mInitDir As String
  349. Private mDefaultExt As String
  350. Private mFilterIndex As Long
  351. Private mHelpFile As String
  352. Private mHelpCommand As CdlgExt_HelpCommand
  353. Private mHelpKey As Long
  354. Private mRGBResult As Long
  355. Private mItalic As Boolean
  356. Private mUnderline As Boolean
  357. Private mStrikethru As Boolean
  358. Private mFontName As String
  359. Private mFontSize As Long
  360. Private mBold As Boolean
  361. Private mDialogPrompt As String
  362. Private mFlags As CdlgExt_Flags
  363. Private mCancelError As Boolean
  364. Private mhIcon As Long
  365. Private mAppName As String
  366. Private mIconSize As CdlgEx_IconSize
  367.  
  368. Public Property Let CancelError(ByVal vData As Boolean)
  369.    mCancelError = vData
  370. End Property
  371.  
  372. Public Property Get CancelError() As Boolean
  373.   CancelError = mCancelError
  374. End Property
  375.  
  376. Public Property Get hOwner() As Long
  377.     hOwner = mhOwner
  378. End Property
  379.  
  380. Public Property Let hOwner(ByVal New_hOwner As Long)
  381.     mhOwner = New_hOwner
  382. End Property
  383.  
  384. Public Property Get Flags() As CdlgExt_Flags
  385.     Flags = mFlags
  386. End Property
  387.  
  388. Public Property Let Flags(ByVal New_Flags As CdlgExt_Flags)
  389.     mFlags = New_Flags
  390. End Property
  391.  
  392. Public Property Get DialogTitle() As String
  393.    DialogTitle = mDialogTitle
  394. End Property
  395.  
  396. Public Property Let DialogTitle(sTitle As String)
  397.    mDialogTitle = sTitle
  398. End Property
  399.  
  400. Public Property Get DialogPrompt() As String
  401.     DialogPrompt = mDialogPrompt
  402. End Property
  403.  
  404. Public Property Let DialogPrompt(ByVal New_Prompt As String)
  405.     mDialogPrompt = New_Prompt
  406. End Property
  407.  
  408. Public Property Get AppName() As String
  409.     AppName = mAppName
  410. End Property
  411.  
  412. Public Property Let AppName(ByVal New_AppName As String)
  413.     mAppName = New_AppName
  414. End Property
  415.  
  416. Public Property Let hicon(ByVal vData As Long)
  417.     mhIcon = vData
  418. End Property
  419.  
  420. Public Property Get hicon() As Long
  421.    hicon = mhIcon
  422. End Property
  423.  
  424. ' Font Properties
  425. Public Property Get Bold() As Boolean
  426.   Bold = mBold
  427. End Property
  428.  
  429. Public Property Let Bold(bBold As Boolean)
  430.    mBold = bBold
  431. End Property
  432.  
  433. Public Property Get FontName() As String
  434.    FontName = mFontName
  435. End Property
  436.  
  437. Public Property Let FontName(sName As String)
  438.    mFontName = sName
  439. End Property
  440.  
  441. Public Property Get FontSize() As Long
  442.   FontSize = mFontSize
  443. End Property
  444.  
  445. Public Property Let FontSize(lSize As Long)
  446.    mFontSize = lSize
  447. End Property
  448.  
  449. Public Property Get Italic() As Boolean
  450.   Italic = mItalic
  451. End Property
  452.  
  453. Public Property Let Italic(BItalic As Boolean)
  454.    mItalic = BItalic
  455. End Property
  456.  
  457. Public Property Get StrikeThru() As Boolean
  458.    StrikeThru = mStrikethru
  459. End Property
  460.  
  461. Public Property Let StrikeThru(bStrikethru As Boolean)
  462.    mStrikethru = bStrikethru
  463. End Property
  464.  
  465. Public Property Get Underline() As Boolean
  466.    Underline = mUnderline
  467. End Property
  468.  
  469. Public Property Let Underline(bUnderline As Boolean)
  470.    mUnderline = bUnderline
  471. End Property
  472.  
  473. ' Open , Save, Folder, Icon
  474.  
  475. Public Property Get DefaultExt() As String
  476.    DefaultExt = mDefaultExt
  477. End Property
  478.  
  479. Public Property Let DefaultExt(sDefExt As String)
  480.    mDefaultExt = sDefExt
  481. End Property
  482.  
  483. Public Property Get filename() As String
  484.    filename = mFileName
  485. End Property
  486.  
  487. Public Property Let filename(sFileName As String)
  488.    mFileName = sFileName
  489. End Property
  490.  
  491. Public Property Get FileTitle() As String
  492.    FileTitle = mFileTitle
  493. End Property
  494.  
  495. Public Property Let FileTitle(sTitle As String)
  496.    mFileTitle = sTitle
  497. End Property
  498.  
  499. Public Property Get Filter() As String
  500.    Filter = mFilter
  501. End Property
  502.  
  503. Public Property Let Filter(sFilter As String)
  504.    mFilter = sFilter
  505. End Property
  506.  
  507. Public Property Get FilterIndex() As Long
  508.    FilterIndex = mFilterIndex
  509. End Property
  510.  
  511. Public Property Let FilterIndex(lIndex As Long)
  512.     mFilterIndex = lIndex
  513. End Property
  514.  
  515. Public Property Get InitDir() As String
  516.    InitDir = mInitDir
  517. End Property
  518.  
  519. Public Property Let InitDir(sDir As String)
  520.     mInitDir = sDir
  521. End Property
  522.  
  523. Public Property Get IconSize() As CdlgEx_IconSize
  524.   If mIconSize <> IconSizeLarge And mIconSize <> IconSizeSmall Then mIconSize = IconSizeLarge
  525.   IconSize = mIconSize
  526. End Property
  527.  
  528. Public Property Let IconSize(nSize As CdlgEx_IconSize)
  529.   If nSize <> IconSizeLarge And nSize <> IconSizeSmall Then nSize = IconSizeLarge
  530.   mIconSize = nSize
  531. End Property
  532. ' Help Properties
  533. Public Property Get HelpCommand() As CdlgExt_HelpCommand
  534.    HelpCommand = mHelpCommand
  535. End Property
  536.  
  537. Public Property Let HelpCommand(lCommand As CdlgExt_HelpCommand)
  538.    mHelpCommand = lCommand
  539. End Property
  540.  
  541. Public Property Get HelpFile() As String
  542.    HelpFile = mHelpFile
  543. End Property
  544.  
  545. Public Property Let HelpFile(sFile As String)
  546.    mHelpFile = sFile
  547. End Property
  548.  
  549. Public Property Get HelpKey() As Long
  550.    HelpKey = mHelpKey
  551. End Property
  552.  
  553. Public Property Let HelpKey(sKey As Long)
  554.    mHelpKey = sKey
  555. End Property
  556.  
  557. 'Color Dialog
  558. Public Property Get rgbResult() As Long
  559.    rgbResult = mRGBResult
  560. End Property
  561.  
  562. Public Property Let rgbResult(lValue As Long)
  563.    mRGBResult = lValue
  564. End Property
  565.  
  566.  
  567.  
  568. 'About Dialog
  569. Public Function ShowAbout()
  570.     If mAppName = "" Then mAppName = Chr$(0)
  571.     SHAbout mhOwner, mAppName, mDialogPrompt, mhIcon
  572. End Function
  573.  
  574. Private Sub InitOFN()
  575.   Dim sTemp As String, i As Integer
  576.   Dim uFlag As Long
  577.   uFlag = mFlags And (&H1 Or &H2 Or &H4 Or &H8 Or &H10 Or &H100 Or &H200 Or &H400 Or &H800 Or &H1000 Or &H2000 Or &H4000 Or &H8000 Or &H40000 Or &H80000 Or &H100000 Or &H200000)
  578.   With OFN
  579.        .lStructSize = Len(OFN)
  580.        .hWndOwner = mhOwner
  581.        .Flags = uFlag
  582.        .lpstrDefExt = mDefaultExt
  583.        sTemp = mInitDir
  584.        If sTemp = "" Then sTemp = App.Path
  585.        .lpstrInitialDir = sTemp
  586.        sTemp = mFileName
  587.        .lpstrFile = sTemp & String$(255 - Len(sTemp), 0)
  588.        .nMaxFile = 255
  589.        .lpstrFileTitle = String$(255, 0)
  590.        .nMaxFileTitle = 255
  591.         sTemp = mFilter
  592.         For i = 1 To Len(sTemp)
  593.             If Mid(sTemp, i, 1) = "|" Then
  594.                Mid(sTemp, i, 1) = vbNullChar
  595.             End If
  596.         Next
  597.         sTemp = sTemp & String$(2, 0)
  598.         .lpstrFilter = sTemp
  599.         .nFilterIndex = mFilterIndex
  600.         .lpstrTitle = mDialogTitle
  601.         .hInstance = App.hInstance
  602.  End With
  603. End Sub
  604. 'Public Sub ShowHelp() 07-03-05
  605. ' 'mHelpKey = &H101
  606. ' RetValue = WinHelp(mhOwner, mHelpFile, mHelpCommand, mHelpKey)
  607. 'End Sub
  608. 'Public Sub ShowColor()
  609. '  Dim CC As CHOOSECOLOR
  610. '  Dim CustomColors() As Byte
  611. '  Dim uFlag As Long
  612. '  ReDim CustomColors(0 To 16 * 4 - 1) As Byte
  613. '  For i = LBound(CustomColors) To UBound(CustomColors)
  614. '     CustomColors(i) = 255 ' white
  615. '  Next i
  616. '  uFlag = mFlags And (&H1 Or &H2 Or &H4 Or &H8)
  617. '  With CC
  618. '       .lStructSize = Len(CC)
  619. '       .hwndOwner = mhOwner
  620. '       .hInstance = App.hInstance
  621. '       .lpCustColors = StrConv(CustomColors, vbUnicode)
  622. '       .Flags = uFlag
  623. '       .rgbResult = mRGBResult
  624. '       RetValue = ChooseColorAPI(CC)
  625. '       If RetValue = 0 Then
  626. '          If mCancelError Then err.Raise (RetValue)
  627. '       Else
  628. '          CustomColors = StrConv(.lpCustColors, vbFromUnicode)
  629. '          mRGBResult = .rgbResult
  630. '       End If
  631. '  End With
  632. 'End Sub
  633. Public Sub ShowFont()
  634.   Dim CF As ChooseFont
  635.   Dim LF As LOGFONT
  636.   Dim TempByteArray() As Byte
  637.   Dim ByteArrayLimit As Long
  638.   Dim OldhDC As Long
  639.   Dim FontToUse As Long
  640.   Dim tbuf As String * 80
  641.   Dim x As Long
  642.   Dim uFlag As Long
  643.   uFlag = mFlags And (&H1 Or &H2 Or &H3 Or &H4 Or &H100 Or &H200 Or &H400 Or &H800 Or &H1000 Or &H2000 Or &H4000 Or &H8000 Or &H10000 Or &H20000 Or &H40000 Or &H80000 Or &H100000 Or &H200000)
  644.   TempByteArray = StrConv(mFontName & vbNullChar, vbFromUnicode)
  645.   ByteArrayLimit = UBound(TempByteArray)
  646.   With LF
  647.      For x = 0 To ByteArrayLimit
  648.         .lfFaceName(x) = TempByteArray(x)
  649.      Next
  650.     .lfHeight = mFontSize / 72 * GetDeviceCaps(GetDC(mhOwner), LOGPIXELSY)
  651.     .lfItalic = mItalic * -1
  652.     .lfUnderline = mUnderline * -1
  653.     .lfStrikeOut = mStrikethru * -1
  654.     If mBold Then .lfWeight = FW_BOLD
  655.   End With
  656.   With CF
  657.       .lStructSize = Len(CF)
  658.       .hWndOwner = mhOwner
  659.       .hdc = GetDC(mhOwner)
  660.       .lpLogFont = lstrcpy(LF, LF)
  661.       If Not uFlag Then
  662.          .Flags = cdlCFScreenFonts
  663.       Else
  664.          .Flags = uFlag Or cdlCFWYSIWYG
  665.       End If
  666.      .Flags = .Flags Or cdlCFEffects Or CF_INITTOLOGFONTSTRUCT
  667.      .rgbColors = mRGBResult
  668.      .lCustData = 0
  669.      .lpfnHook = 0
  670.      .lpTemplateName = 0
  671.      .hInstance = 0
  672.      .lpszStyle = 0
  673.      .nFontType = SCREEN_FONTTYPE
  674.      .nSizeMin = 0
  675.      .nSizeMax = 0
  676.      .iPointSize = mFontSize * 10
  677.     End With
  678.     retvalue = ChooseFont(CF)
  679.     If retvalue = 0 Then
  680.        If mCancelError Then err.Raise (retvalue)
  681.     Else
  682.        With LF
  683.             mItalic = .lfItalic * -1
  684.             mUnderline = .lfUnderline * -1
  685.             mStrikethru = .lfStrikeOut * -1
  686.        End With
  687.        With CF
  688.             mFontSize = .iPointSize \ 10
  689.             mRGBResult = .rgbColors
  690.             If .nFontType And BOLD_FONTTYPE Then
  691.                 mBold = True
  692.             Else
  693.                 mBold = False
  694.             End If
  695.        End With
  696.        FontToUse = CreateFontIndirect(LF)
  697.        If FontToUse = 0 Then Exit Sub
  698.           OldhDC = SelectObject(CF.hdc, FontToUse)
  699.           retvalue = GetTextFace(CF.hdc, 79, tbuf)
  700.           mFontName = Mid$(tbuf, 1, retvalue)
  701.        End If
  702. End Sub
  703.