Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: CMDLG32.ocx Добавлено: 31.01.10 15:24  

Автор вопроса:  muxa555 | Web-сайт: crackfind.com | ICQ: 445608319 
Сделал прогу, радостный такой, все значит работает, сделал ехе файл и перенес его на другой комп. вот тут радость кончилась - при запуске матерится - нет cmdlg32.ocx и все и хоть ты тресни. да, в моей проге используется common dialog. но разьве это повод чтобы прога не катила надругом компе? ХЕЛП!

Ответить

  Ответы Всего ответов: 9  

Номер ответа: 1
Автор ответа:
 AWP



ICQ: 345685652 

Вопросов: 96
Ответов: 1212
 Web-сайт: xawp.narod.ru
 Профиль | | #1
Добавлено: 31.01.10 15:59
скопируй на друго комп файл CMDLG32.ocx в папку c:\windows\system32\ и зарегистрируй в системе.

Ответить

Номер ответа: 2
Автор ответа:
 AWP



ICQ: 345685652 

Вопросов: 96
Ответов: 1212
 Web-сайт: xawp.narod.ru
 Профиль | | #2
Добавлено: 31.01.10 15:59
А вобще да, это повод))

Ответить

Номер ответа: 3
Автор ответа:
 muxa555



ICQ: 445608319 

Вопросов: 3
Ответов: 22
 Web-сайт: crackfind.com
 Профиль | | #3
Добавлено: 31.01.10 18:50
Сибо, так и сделал. Но все равно на другом компе прога глючит...

Ответить

Номер ответа: 4
Автор ответа:
 AWP



ICQ: 345685652 

Вопросов: 96
Ответов: 1212
 Web-сайт: xawp.narod.ru
 Профиль | | #4
Добавлено: 01.02.10 01:01
Ошибки, чё пишет?

Ответить

Номер ответа: 5
Автор ответа:
 muxa555



ICQ: 445608319 

Вопросов: 3
Ответов: 22
 Web-сайт: crackfind.com
 Профиль | | #5
Добавлено: 01.02.10 22:49
не, в принципе глючит.. я например делал так, чтобы история действий в программе удобно записывалась в залоченый текстбокс. на другом компе текстбокс пуст.. ну не суть: уже обошёл.

Ответить

Номер ответа: 6
Автор ответа:
 muxa555



ICQ: 445608319 

Вопросов: 3
Ответов: 22
 Web-сайт: crackfind.com
 Профиль | | #6
Добавлено: 01.02.10 22:51
подскажите каким КОДОМ можно прописать, что эта прога юзит comdlg32.ocx и что он лежит не в system32, а в app.path, например

Ответить

Номер ответа: 7
Автор ответа:
 AWP



ICQ: 345685652 

Вопросов: 96
Ответов: 1212
 Web-сайт: xawp.narod.ru
 Профиль | | #7
Добавлено: 03.02.10 12:07
Его нужно зарегить в папке app.path

А тебе обязательно OCX юзать? Можно API функции использовать и никаких файлов не потребуется

Ответить

Номер ответа: 8
Автор ответа:
 Smith



ICQ: adamis@list.ru 

Вопросов: 153
Ответов: 3632
 Профиль | | #8 Добавлено: 03.02.10 22:14
Это былобы правильно.

Ответить

Номер ответа: 9
Автор ответа:
 Just



Вопросов: 4
Ответов: 330
 Профиль | | #9 Добавлено: 09.02.10 23:19
Заместо ocx можно создать класс в своей проге
  1.  
  2. 'скопировать в класс
  3. 'имя класса: clsCommonDialog
  4.  
  5. Option Explicit
  6.  
  7. 'API function called by ChooseColor method
  8. Private Declare Function ChooseColor Lib "Comdlg32.dll" _
  9.   Alias "ChooseColorA" (pChoosecolor As ChooseColor) As Long
  10.  
  11. 'API funtion called by ChooseFont mehtod
  12. Private Declare Function CHOOSEFONT Lib "Comdlg32.dll" _
  13.   Alias "ChooseFontA" (PChoosefont As CHOOSEFONT) As Long
  14.  
  15. 'API funtion inside ShowHelp method
  16. Private Declare Function WinHelp Lib "USER32" Alias "WinHelpA" _
  17.   (ByVal hWnd As Long, ByVal lpHelpFile As String, _
  18.   ByVal wCommand As Long, ByVal dwData As Long) As Long
  19.   
  20. Private Declare Function WinHelpStr Lib "USER32" Alias "WinHelpA" _
  21.   (ByVal hWnd As Long, ByVal lpHelpFile As String, _
  22.   ByVal wCommand As Long, ByVal dwData As String) As Long
  23.   
  24. 'API function called by ShowOpen method
  25. Private Declare Function GetOpenFileName Lib "Comdlg32.dll" _
  26.   Alias "GetOpenFileNameA" (pOpenFilename As OpenFilename) _
  27.   As Long
  28.   
  29. 'API function called by ShowSave method
  30. Private Declare Function GetSaveFileName Lib "Comdlg32.dll" _
  31.   Alias "GetSaveFileNameA" (pOpenFilename As OpenFilename) _
  32.   As Long
  33.  
  34. 'API function called by ShowPrint Method
  35. Private Declare Function PrintDlg Lib "Comdlg32.dll" _
  36.   Alias "PrintDlgA" (pPrintdlg As PrintDlg) As Long
  37.  
  38. Private Declare Function GlobalLock Lib "kernel32" _
  39.   (ByVal hMem As Long) As Long
  40. Private Declare Function GlobalUnlock Lib "kernel32" _
  41.   (ByVal hMem As Long) As Long
  42.   
  43. 'API function to retrieve extended error information
  44. Private Declare Function CommDlgExtendedError Lib "Comdlg32.dll" _
  45.   () As Long
  46.   
  47. 'API function to retrieve extended error information for WinHelp
  48. Private Declare Function GetLastError Lib "kernel32" () As Long
  49.  
  50. Private Declare Sub CopyMemoryStr Lib "kernel32" Alias "RtlMoveMemory" ( _
  51.   lpvDest As Any, ByVal lpvSource As String, ByVal cbCopy As Long)
  52.  
  53. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
  54.   ByVal lpvDest As Any, ByVal lpvSource As Any, ByVal cbCopy As Long)
  55.  
  56. 'Internal constants
  57. Private Const cMaxFileSize = 256
  58. Private Const cCancelDescription = "Cancel Pressed"
  59. Private Const cUserCanceled = 0
  60. Private Const cUserSelected = 1
  61. Private Const cShowOpen = 1
  62. Private Const cShowSave = 2
  63. Private Const cShowColor = 3
  64. Private Const cShowFont = 4
  65. Private Const cShowPrinter = 5
  66. Private Const cShowHelp = 6
  67.  
  68. 'constants for LOGFONT
  69. Private Const FW_BOLD = 700
  70.  
  71. 'UDT for the ChooseColor function
  72. Private Type ChooseColor
  73.   lStructSize As Long
  74.   hwndOwner As Long
  75.   hInstance As Long
  76.   rgbResult As Long
  77.   lpCustColors As Long
  78.   Flags As Long
  79.   lCustData As Long
  80.   lpfnHook As Long
  81.   lpTemplateName As String
  82. End Type
  83.  
  84. 'UDT for the ChooseFont function
  85. Private Type LOGFONT
  86.         lfHeight As Long
  87.         lfWidth As Long
  88.         lfEscapement As Long
  89.         lfOrientation As Long
  90.         lfWeight As Long
  91.         lfItalic As Byte
  92.         lfUnderline As Byte
  93.         lfStrikeOut As Byte
  94.         lfCharSet As Byte
  95.         lfOutPrecision As Byte
  96.         lfClipPrecision As Byte
  97.         lfQuality As Byte
  98.         lfPitchAndFamily As Byte
  99.         lfFaceName(0 To 31) As Byte
  100. End Type
  101.  
  102. 'UDT for the ChooseFont function
  103. Private Type CHOOSEFONT
  104.   lStructSize As Long
  105.   hwndOwner As Long
  106.   hDC As Long
  107.   lpLogFont As Long
  108.   iPointSize As Long
  109.   Flags As Long
  110.   rgbColors As Long
  111.   lCustData As Long
  112.   lpfnHook As Long
  113.   lpTemplateName As String
  114.   hInstance As Long
  115.   lpszStyle As String
  116.   nFontType As Integer
  117.   MISSING_ALIGNMENT As Integer
  118.   nSizeMin As Long
  119.   nSizeMax As Long
  120. End Type
  121.  
  122. 'UDT for the GetOpenFileName and GetSaveFileName functions
  123. Private Type OpenFilename
  124.   lStructSize As Long
  125.   hwndOwner As Long
  126.   hInstance As Long
  127.   lpstrFilter As String
  128.   lpstrCustomFilter As String
  129.   nMaxCustFilter As Long
  130.   iFilterIndex As Long
  131.   lpstrFile As String
  132.   nMaxFile As Long
  133.   lpstrFileTitle As String
  134.   nMaxFileTitle As Long
  135.   lpstrInitialDir As String
  136.   lpstrTitle As String
  137.   Flags As Long
  138.   nFileOffset As Integer
  139.   nFileExtension As Integer
  140.   lpstrDefExt As String
  141.   lCustData As Long
  142.   lpfnHook As Long
  143.   lpTemplateName As String
  144. End Type
  145.  
  146. 'UDT for the PrintDlg function
  147. Private Type PrintDlg
  148.   lStructSize As Long
  149.   hwndOwner As Long
  150.   hDevMode As Long
  151.   hDevNames As Long
  152.   hDC As Long
  153.   Flags As Long
  154.   nFromPage As Integer
  155.   nToPage As Integer
  156.   nMinPage As Integer
  157.   nMaxPage As Integer
  158.   nCopies As Integer
  159.   hInstance As Long
  160.   lCustData As Long
  161.   lpfnPrintHook As Long
  162.   lpfnSetupHook As Long
  163.   lpPrintTemplateName As String
  164.   lpSetupTemplateName As String
  165.   hPrintTemplate As Long
  166.   hSetupTemplate As Long
  167. End Type
  168.  
  169. 'DEVMODE collation selections
  170. Private Const DMCOLLATE_FALSE = 0
  171. Private Const DMCOLLATE_TRUE = 1
  172.  
  173. Private Type DEVNAMES
  174.   wDriverOffset As Integer
  175.   wDeviceOffset As Integer
  176.   wOutputOffset As Integer
  177.   wDefault As Integer
  178. End Type
  179.  
  180. Private Type DEVMODE
  181.   dmDeviceName(0 To 31) As Byte
  182.   dmSpecVersion As Integer
  183.   dmDriverVersion As Integer
  184.   dmSize As Integer
  185.   dmDriverExtra As Integer
  186.   dmFields As Long
  187.   dmOrientation As Integer
  188.   dmPaperSize As Integer
  189.   dmPaperLength As Integer
  190.   dmPaperWidth As Integer
  191.   dmScale As Integer
  192.   dmCopies As Integer
  193.   dmDefaultSource As Integer
  194.   dmPrintQuality As Integer
  195.   dmColor As Integer
  196.   dmDuplex As Integer
  197.   dmYResolution As Integer
  198.   dmTTOption As Integer
  199.   dmCollate As Integer
  200.   dmFormName(0 To 31) As Byte
  201.   dmUnusedPadding As Integer
  202.   dmBitsPerPel As Integer
  203.   dmPelsWidth As Long
  204.   dmPelsHeight As Long
  205.   dmDisplayFlags As Long
  206.   dmDisplayFrequency As Long
  207.   dmICMMethod As Long
  208.   dmICMIntent As Long
  209.   dmMediaType As Long
  210.   dmDitherType As Long
  211.   dmReserved1 As Long
  212.   dmReserved2 As Long
  213. End Type
  214.  
  215. 'local variable(s) to hold property value(s)
  216. Private mintAction As Integer 'local copy
  217. Private mstrFilter As String 'local copy
  218. Private mstrFileName As String 'local copy
  219. Private mintFilterIndex As Integer 'local copy
  220. Private mblnCancelError As Boolean 'local copy
  221. Private mlngColor As Long 'local copy
  222. Private mlngCopies As Long 'local copy
  223. Private mstrDefaultExt As String 'local copy
  224. Private mstrDialogTitle As String 'local copy
  225. Private mlngFlags As Long 'local copy
  226. Private mblnFontBold As Boolean 'local copy
  227. Private mblnFontItalic As Boolean 'local copy
  228. Private mstrFontName As String 'local copy
  229. Private mlngFontSize As Long 'local copy
  230. Private mblnFontStrikethru As Boolean 'local copy
  231. Private mblnFontUnderline As Boolean 'local copy
  232. Private mlngFromPage As Long 'local copy
  233. Private mlnghWnd As Long 'local copy
  234. Private mlnghDC As Long 'local copy
  235. Private mlngHelpCommand As Long 'local copy
  236. Private mstrHelpFile As String 'local copy
  237. Private mstrHelpKey_Context As String 'local copy
  238. Private mstrInitDir As String 'local copy
  239. Private mlngMax As Long 'local copy
  240. Private mlngMaxFileSize As Long 'local copy
  241. Private mlngMin As Long 'local copy
  242. Private mblnPrinterDefault As Boolean 'local copy
  243. Private mlngToPage As Long 'local copy
  244. Private mstrFileTitle As String 'local copy
  245. Private mlngAPIReturn As Long 'local copy
  246. Private mlngExtendedError As Long 'local copy
  247.  
  248. Public Enum ccdControlContants
  249.   'File Open/Save Dialog Box Flags
  250.   cdlOFNAllowMultiselect = &H200
  251.   cdlOFNCreatePrompt = &H2000
  252.   cdlOFNExplorer = &H80000
  253.   cdlOFNExtensionDifferent = &H400
  254.   cdlOFNFileMustExist = &H1000
  255.   cdlOFNHelpButton = &H10
  256.   cdlOFNHideReadOnly = &H4
  257.   cdlOFNLongNames = &H200000
  258.   cdlOFNNoChangeDir = &H8
  259.   cdlOFNNoDereferenceLinks = &H100000
  260.   cdlOFNNoReadOnlyReturn = &H8000
  261.   cdlOFNNoValidate = &H100
  262.   cdlOFNOverwritePrompt = &H2
  263.   cdlOFNPathMustExist = &H800
  264.   cdlOFNReadOnly = &H1
  265.   cdlOFNShareAware = &H4000
  266.   'Color Dialog Box Flags
  267.   cdlCCFullOpen = &H2
  268.   cdlCCShowHelp = &H8
  269.   cdlCCPreventFullOpen = &H4
  270.   cdlCCRGBInit = &H1
  271.   'Fonts Dialog Box Flags
  272.   cdlCFANSIOnly = &H400
  273.   cdlCFapply = &H200 'Enables the Apply button on the dialog box.
  274.   cdlcfboth = &H3
  275.   cdlCFeffects = &H100 'Specifies that the dialog box enables
  276.   'strikethrough, underline, and color effects.
  277.   cdlCFFixedPitchOnly = &H4000
  278.   cdlCFForceFontExist = &H10000
  279.   cdlCFHelpButton = &H4
  280.   cdlCFLimitSize = &H2000
  281.   cdlCFNoFaceSel = &H80000
  282.   cdlCFNoSimulations = &H1000
  283.   cdlCFNoSizeSel = &H200000
  284.   cdlCFNoStyleSel = &H100000
  285.   cdlCFNoVictorFonts = &H800
  286.   cdlCFPrinterFonts = &H2
  287.   cdlCFScalableOnly = &H20000
  288.   cdlCFSreenFonts = &H1
  289.   cdlCFTTOnly = &H40000
  290.   cdlCFWYSIWYG = &H8000
  291.   'Printer Dialog Box Flags
  292.   cdlPDAllPages = &H0
  293.   cdlPDCollate = &H10
  294.   cdlPDDisablePrintToFile = &H80000
  295.   cdlPDHelpButton = &H800
  296.   cdlPDHidePrintToFile = &H100000
  297.   cdlPDNoPageNums = &H8
  298.   cdlPDNoSelection = &H4
  299.   cdlPDNoWarning = &H80
  300.   cdlPDPageNums = &H2
  301.   cdlPDPrintSetup = &H40
  302.   cdlPDPrintToFile = &H20
  303.   cdlPDReturnDC = &H100
  304.   cdlPDReturnDefault = &H400
  305.   cdlPDReturnIC = &H200
  306.   cdlPDSelection = &H1
  307.   cdlPDUseDevModeCopies = &H40000
  308. End Enum
  309.  
  310. Public Enum cCancel
  311.   'Cancel Constant
  312.   cdlCancel = vbObjectError + 2001
  313. End Enum
  314.  
  315. Public Enum cHelp
  316.   'Help Constants
  317.   cdlHelpCommand = &H102
  318.   cdlHelpContents = &H3
  319.   cdlHelpFinder = &HB
  320.   cdlHelpContext = &H1
  321.   cdlHelpContextPopup = &H8
  322.   cdlHelpForceFile = &H9
  323.   cdlHelpHelpOnHelp = &H4
  324.   cdlHelpIndex = &H3
  325.   cdlHelpKey = &H101
  326.   cdlHelpPartialKey = &H105
  327.   cdlHelpQuit = &H2
  328.   cdlHelpSetContents = &H5
  329.   cdlHelpSetIndex = &H5
  330. End Enum
  331.  
  332. Public Property Get ExtendedError() As Long
  333.   'Read Only - Get the last error message
  334.   ExtendedError = mlngExtendedError
  335. End Property
  336.  
  337. Public Property Get APIReturn() As Long
  338.   'Read Only - Get the action performed by the class
  339.   APIReturn = mlngAPIReturn
  340. End Property
  341.  
  342. Public Property Let FileTitle(ByVal strData As String)
  343.   mstrFileTitle = strData
  344. End Property
  345.  
  346. Public Property Get FileTitle() As String
  347.   FileTitle = mstrFileTitle
  348. End Property
  349.  
  350. Public Property Let ToPage(ByVal lngData As Long)
  351.   mlngToPage = lngData
  352. End Property
  353.  
  354. Public Property Get ToPage() As Long
  355.   ToPage = mlngToPage
  356. End Property
  357.  
  358. Public Property Let PrinterDefault(ByVal intData As Boolean)
  359.   mblnPrinterDefault = intData
  360. End Property
  361.  
  362. Public Property Get PrinterDefault() As Boolean
  363.   PrinterDefault = mblnPrinterDefault
  364. End Property
  365.  
  366. Public Property Let Min(ByVal lngData As Long)
  367.   mlngMin = lngData
  368. End Property
  369.  
  370. Public Property Get Min() As Long
  371.   Min = mlngMin
  372. End Property
  373.  
  374. Public Property Let MaxFileSize(ByVal lngData As Long)
  375.   mlngMaxFileSize = lngData
  376. End Property
  377.  
  378. Public Property Get MaxFileSize() As Long
  379.   MaxFileSize = mlngMaxFileSize
  380. End Property
  381.  
  382. Public Property Let Max(ByVal lngData As Long)
  383.   mlngMax = lngData
  384. End Property
  385.  
  386. Public Property Get Max() As Long
  387.   Max = mlngMax
  388. End Property
  389.  
  390. Public Property Let InitDir(ByVal strData As String)
  391.   mstrInitDir = strData
  392. End Property
  393.  
  394. Public Property Get InitDir() As String
  395.   InitDir = mstrInitDir
  396. End Property
  397.  
  398. Public Property Let HelpKey(ByVal strData As String)
  399.   mstrHelpKey_Context = strData
  400. End Property
  401.  
  402. Public Property Get HelpKey() As String
  403.   HelpKey = mstrHelpKey_Context
  404. End Property
  405.  
  406. Public Property Let HelpFile(ByVal strData As String)
  407.   mstrHelpFile = strData
  408. End Property
  409.  
  410. Public Property Get HelpFile() As String
  411.   HelpFile = mstrHelpFile
  412. End Property
  413.  
  414. Public Property Let HelpContext(ByVal strData As String)
  415.   mstrHelpKey_Context = strData
  416. End Property
  417.  
  418. Public Property Get HelpContext() As String
  419.   HelpContext = mstrHelpKey_Context
  420. End Property
  421.  
  422. Public Property Let HelpCommand(ByVal lngData As cHelp)
  423.   mlngHelpCommand = lngData
  424. End Property
  425.  
  426. Public Property Get HelpCommand() As cHelp
  427.   HelpCommand = mlngHelpCommand
  428. End Property
  429.  
  430. Public Property Let hDC(ByVal lngData As Long)
  431.   mlnghDC = lngData
  432. End Property
  433.  
  434. Public Property Get hDC() As Long
  435.   hDC = mlnghDC
  436. End Property
  437.  
  438. Public Property Let FromPage(ByVal lngData As Long)
  439.   mlngFromPage = lngData
  440. End Property
  441.  
  442. Public Property Get FromPage() As Long
  443.   FromPage = mlngFromPage
  444. End Property
  445.  
  446. Public Property Let FontUnderline(ByVal blnData As Boolean)
  447.   mblnFontUnderline = blnData
  448. End Property
  449.  
  450. Public Property Get FontUnderline() As Boolean
  451.   FontUnderline = mblnFontUnderline
  452. End Property
  453.  
  454. Public Property Let FontStrikethru(ByVal blnData As Boolean)
  455.   mblnFontStrikethru = blnData
  456. End Property
  457.  
  458. Public Property Get FontStrikethru() As Boolean
  459.   FontStrikethru = mblnFontStrikethru
  460. End Property
  461.  
  462. Public Property Let FontSize(ByVal lngData As Long)
  463.   mlngFontSize = lngData
  464. End Property
  465.  
  466. Public Property Get FontSize() As Long
  467.   FontSize = mlngFontSize
  468. End Property
  469.  
  470. Public Property Let FontName(ByVal strData As String)
  471.   mstrFontName = strData
  472. End Property
  473.  
  474. Public Property Get FontName() As String
  475.   FontName = mstrFontName
  476. End Property
  477.  
  478. Public Property Let FontItalic(ByVal blnData As Boolean)
  479.   mblnFontItalic = blnData
  480. End Property
  481.  
  482. Public Property Get FontItalic() As Boolean
  483.   FontItalic = mblnFontItalic
  484. End Property
  485.  
  486. Public Property Let FontBold(ByVal blnData As Boolean)
  487.   mblnFontBold = blnData
  488. End Property
  489.  
  490. Public Property Get FontBold() As Boolean
  491.   FontBold = mblnFontBold
  492. End Property
  493.  
  494. Public Property Let Flags(ByVal lngData As ccdControlContants)
  495.   mlngFlags = lngData
  496. End Property
  497.  
  498. Public Property Get Flags() As ccdControlContants
  499.   Flags = mlngFlags
  500. End Property
  501.  
  502. Public Property Let DialogTitle(ByVal strData As String)
  503.   mstrDialogTitle = strData
  504. End Property
  505.  
  506. Public Property Get DialogTitle() As String
  507.   DialogTitle = mstrDialogTitle
  508. End Property
  509.  
  510. Public Property Let DefaultExt(ByVal strData As String)
  511.   mstrDefaultExt = strData
  512. End Property
  513.  
  514. Public Property Get DefaultExt() As String
  515.   DefaultExt = mstrDefaultExt
  516. End Property
  517.  
  518. Public Property Let Copies(ByVal lngData As Long)
  519.   mlngCopies = lngData
  520. End Property
  521.  
  522. Public Property Get Copies() As Long
  523.   Copies = mlngCopies
  524. End Property
  525.  
  526. Public Property Let Color(ByVal lngData As Long)
  527.   mlngColor = lngData
  528. End Property
  529.  
  530. Public Property Get Color() As Long
  531.   Color = mlngColor
  532. End Property
  533.  
  534. Public Property Let CancelError(ByVal blnData As Boolean)
  535.   mblnCancelError = blnData
  536. End Property
  537.  
  538. Public Property Get CancelError() As Boolean
  539.   CancelError = mblnCancelError
  540. End Property
  541.  
  542. Public Property Let FilterIndex(ByVal intData As Integer)
  543.   mintFilterIndex = intData
  544. End Property
  545.  
  546. Public Property Get FilterIndex() As Integer
  547.   FilterIndex = mintFilterIndex
  548. End Property
  549.  
  550. Public Property Let FileName(ByVal strData As String)
  551.   mstrFileName = strData
  552. End Property
  553.  
  554. Public Property Get FileName() As String
  555.   FileName = mstrFileName
  556. End Property
  557.  
  558. Public Sub ShowSave()
  559.   
  560.   ShowFileDialog (cShowSave)
  561.   
  562. End Sub
  563.  
  564. Public Sub ShowPrinter()
  565.  
  566.   Dim udtPrintDlg As PrintDlg
  567.   Dim dvmode As DEVMODE
  568.   Dim pDevMode As Long
  569.   
  570.   On Error GoTo ShowPrinterError
  571.   
  572.   mintAction = cShowPrinter
  573.   mlngAPIReturn = 0
  574.   mlngExtendedError = 0
  575.   
  576.   'Prepare udtPrintDlg for data
  577.   udtPrintDlg.lStructSize = Len(udtPrintDlg)
  578.   udtPrintDlg.hwndOwner = mlnghWnd
  579.   'hDevMode set to 0 - default
  580.   'hDevNames set to 0 - default
  581.   udtPrintDlg.hDC = mlnghDC
  582.   udtPrintDlg.Flags = mlngFlags
  583.   udtPrintDlg.nFromPage = mlngFromPage
  584.   udtPrintDlg.nToPage = mlngToPage
  585.   udtPrintDlg.nMinPage = mlngMin
  586.   udtPrintDlg.nMaxPage = mlngMax
  587.   udtPrintDlg.nCopies = mlngCopies
  588.   'hInstance set to 0 - default
  589.   'lCustData  set to 0 - default
  590.   'lpfnPrintHook set to 0 - default
  591.   'lpfnSetupHook set to 0 - default
  592.   'lpPrintTemplateName set to 0 - default
  593.   'lpSetupTemplateName set to 0 - default
  594.   'hPrintTemplate set to 0 - default
  595.   'hSetupTemplate set to 0 - default
  596.   
  597.   mlngAPIReturn = PrintDlg(udtPrintDlg)
  598.   
  599.   Select Case mlngAPIReturn
  600.     Case cUserCanceled
  601.       If mblnCancelError = True Then
  602.         'generate an error
  603.         On Error GoTo 0
  604.         Err.Raise Number:=cdlCancel, Description:=cCancelDescription
  605.         Exit Sub
  606.       End If
  607.     Case cUserSelected
  608.       mlngFromPage = udtPrintDlg.nFromPage
  609.       mlngToPage = udtPrintDlg.nToPage
  610.       mlngMin = udtPrintDlg.nMinPage
  611.       mlngMax = udtPrintDlg.nMaxPage
  612.       mlnghDC = udtPrintDlg.hDC
  613.       'Get DEVMODE structure from udtPrintDlg
  614.       pDevMode = GlobalLock(udtPrintDlg.hDevMode)
  615.       CopyMemory VarPtr(dvmode), pDevMode, Len(dvmode)
  616.       Call GlobalUnlock(udtPrintDlg.hDevMode)
  617.       If mlngFlags And cdlPDUseDevModeCopies Then
  618.         mlngCopies = dvmode.dmCopies
  619.       Else
  620.         mlngCopies = udtPrintDlg.nCopies
  621.       End If
  622.       On Error Resume Next
  623.       If mblnPrinterDefault Then
  624.         Printer.Copies = mlngCopies
  625.         Printer.Orientation = dvmode.dmOrientation
  626.         Printer.PaperSize = dvmode.dmPaperSize
  627.         Printer.PrintQuality = dvmode.dmPrintQuality
  628.       End If
  629.     Case Else
  630.       'Call CommDlgExtendedError
  631.       mlngExtendedError = CommDlgExtendedError
  632.   End Select
  633.   
  634.   Exit Sub
  635. ShowPrinterError:
  636.   Exit Sub
  637.   
  638. End Sub
  639.  
  640. Public Sub ShowOpen()
  641.   
  642.   ShowFileDialog (cShowOpen)
  643.   
  644. End Sub
  645.  
  646. Public Sub ShowHelp()
  647.   
  648.   Dim lngData As Long
  649.   Dim strData As String
  650.   Dim lngReturn As Long
  651.   
  652.   On Error GoTo ShowHelpError
  653.   
  654.   mintAction = cShowHelp
  655.   mlngAPIReturn = 0
  656.   mlngExtendedError = 0
  657.   
  658.   'Prepare data for API funtion call
  659.   Select Case mlngHelpCommand
  660.     Case cdlHelpContext, cdlHelpContextPopup, cdlHelpSetContents
  661.       lngData = CLng(mstrHelpKey_Context)
  662.       mlngAPIReturn = WinHelp(mlnghDC, mstrHelpFile, mlngHelpCommand, _
  663.         lngData)
  664.     Case cdlHelpKey, cdlHelpPartialKey, cdlHelpCommand
  665.       mlngAPIReturn = WinHelpStr(mlnghDC, mstrHelpFile, _
  666.         mlngHelpCommand, mstrHelpKey_Context & vbNullChar)
  667.     Case Else
  668.       lngData = 0&
  669.       mlngAPIReturn = WinHelp(mlnghDC, mstrHelpFile, mlngHelpCommand, _
  670.         lngData)
  671.   End Select
  672.   
  673.   'Check for error
  674.   If mlngAPIReturn = 0 Then mlngExtendedError = GetLastError
  675.   
  676.   Exit Sub
  677.   
  678. ShowHelpError:
  679.  
  680.   Exit Sub
  681.       
  682. End Sub
  683.  
  684. Public Sub ShowFont()
  685.   
  686.   Dim udtLogFont As LOGFONT
  687.   Dim udtChooseFont As CHOOSEFONT
  688.   Dim lngReturn As Long
  689.   Const PointsPerTwip = 1440 / 72
  690.   Const CF_InitToLogFontStruct = &H40
  691.   
  692.   On Error GoTo ShowFontError
  693.   
  694.   mintAction = cShowFont
  695.   mlngAPIReturn = 0
  696.   mlngExtendedError = 0
  697.   
  698.   'Prepare the udtLogFont with data
  699.   'lfHeight set to 0 - default
  700.   udtLogFont.lfHeight = -(mlngFontSize * (PointsPerTwip / _
  701.     Screen.TwipsPerPixelY))
  702.   'lfWidth set to 0 - default
  703.   'lfEscapement set to 0 - default
  704.   'lfOrientation set to 0 - default
  705.   If mblnFontBold = True Then
  706.     udtLogFont.lfWeight = FW_BOLD
  707.   End If
  708.   If mblnFontItalic = True Then
  709.     udtLogFont.lfItalic = 1
  710.   End If
  711.   If mblnFontUnderline = True Then
  712.     udtLogFont.lfUnderline = 1
  713.   End If
  714.   If mblnFontStrikethru = True Then
  715.     udtLogFont.lfStrikeOut = 1
  716.   End If
  717.   'lfCharSet set to 0 - default
  718.   'lfOutPrecision set to 0 - default
  719.   'lfClipPrecision set to 0 - default
  720.   'lfQuality set to 0 - default
  721.   'lfPitchAndFamily set to 0 - default
  722.   StrToBytes udtLogFont.lfFaceName, mstrFontName
  723.   
  724.   'Prepare mudtChooseFont with data
  725.   udtChooseFont.lStructSize = Len(udtChooseFont)
  726.   udtChooseFont.hwndOwner = mlnghWnd
  727.   udtChooseFont.hDC = hDC
  728.   
  729.   'Get address of LogFont Structure
  730.   udtChooseFont.lpLogFont = VarPtr(udtLogFont)
  731.   udtChooseFont.iPointSize = mlngFontSize * 10
  732.   mlngFlags = (mlngFlags Or CF_InitToLogFontStruct)
  733.   udtChooseFont.Flags = mlngFlags
  734.   udtChooseFont.rgbColors = mlngColor
  735.   'lCustData set to 0 - default
  736.   'lpfnHook set to 0 - default
  737.   'lpTemplateName set to 0 - default
  738.   'hInstance set to 0 - default
  739.   'lpszStyle set to 0 - default
  740.   'nFontType set to 0 - default
  741.   'MISSING_ALIGNMENT set to 0 - default
  742.   udtChooseFont.nSizeMin = mlngMin
  743.   udtChooseFont.nSizeMax = mlngMax
  744.   
  745.   'Call the API ChooseFont function
  746.   mlngAPIReturn = CHOOSEFONT(udtChooseFont)
  747.   
  748.   Select Case mlngAPIReturn
  749.     Case cUserCanceled    'Cancel button pressed
  750.       If mblnCancelError = True Then
  751.         'generate an error
  752.         On Error GoTo 0
  753.         Err.Raise Number:=cdlCancel, _
  754.           Description:=cCancelDescription
  755.         Exit Sub
  756.       End If
  757.     Case cUserSelected    'User selected a font
  758.       mlngFlags = udtChooseFont.Flags
  759.       mlngColor = udtChooseFont.rgbColors
  760.       If udtLogFont.lfWeight >= FW_BOLD Then
  761.         mblnFontBold = True
  762.       Else
  763.         mblnFontBold = False
  764.       End If
  765.       If udtLogFont.lfItalic > 1 Then
  766.         mblnFontItalic = True
  767.       Else
  768.         mblnFontItalic = False
  769.       End If
  770.       If udtLogFont.lfUnderline = 1 Then
  771.         mblnFontUnderline = True
  772.       Else
  773.         mblnFontUnderline = False
  774.       End If
  775.       If udtLogFont.lfStrikeOut = 1 Then
  776.         mblnFontStrikethru = True
  777.       Else
  778.         mblnFontStrikethru = False
  779.       End If
  780.       mstrFontName = strByteArrayToString(udtLogFont.lfFaceName())
  781.       mlngFontSize = CLng(udtChooseFont.iPointSize / 10)
  782.     Case Else
  783.       mlngExtendedError = CommDlgExtendedError
  784.   End Select
  785.   
  786.   Exit Sub
  787.   
  788. ShowFontError:
  789.  
  790.   Exit Sub
  791.  
  792. End Sub
  793.  
  794. Public Sub ShowColor()
  795.  
  796.   Dim udtChooseColor As ChooseColor
  797.   Dim alngCustomColors(15) As Long
  798.   Dim intn As Integer
  799.   Dim lngReturn As Long
  800.   
  801.   On Error GoTo ShowColorError
  802.   
  803.   mintAction = cShowColor   'Set the Action property to ShowColor
  804.   mlngAPIReturn = 0         'Reset APIRetur property
  805.   mlngExtendedError = 0     'Reset the Extended Error property
  806.   
  807.   'Prepare the udtChooseColor with data
  808.   udtChooseColor.lStructSize = Len(udtChooseColor)
  809.   udtChooseColor.hwndOwner = mlnghWnd
  810.   'hInstance set to 0 - default
  811.   udtChooseColor.rgbResult = mlngColor
  812.   'Set custom color array with white
  813.   For intn = 0 To UBound(alngCustomColors)
  814.     alngCustomColors(intn) = &HFFFFFF
  815.   Next
  816.   'Get address of Custom Color Array
  817.   udtChooseColor.lpCustColors = VarPtr(alngCustomColors(0))
  818.   udtChooseColor.Flags = mlngFlags
  819.   'CustData set to 0 - default
  820.   'lpfnHook set to 0 - default
  821.   'lpTemplateName set to 0 - default
  822.   
  823.   'Call the ChooseColor API function
  824.   mlngAPIReturn = ChooseColor(udtChooseColor)
  825.   
  826.   'Process return
  827.   Select Case mlngAPIReturn
  828.     Case cUserCanceled    'Dialog cancel button pressed
  829.       If mblnCancelError = True Then
  830.         On Error GoTo 0
  831.         Err.Raise Number:=cdlCancel, Description:=cCancelDescription
  832.         Exit Sub
  833.       End If
  834.     Case cUserSelected  'Color selected
  835.       mlngColor = udtChooseColor.rgbResult
  836.     Case Else             'Error
  837.       mlngExtendedError = CommDlgExtendedError
  838.   End Select
  839.     
  840. Exit Sub
  841.  
  842. ShowColorError:
  843.  
  844.   Exit Sub
  845.   
  846. End Sub
  847.  
  848. Public Property Let Filter(ByVal strData As String)
  849.   mstrFilter = strData
  850. End Property
  851.  
  852. Public Property Get Filter() As String
  853.   Filter = mstrFilter
  854. End Property
  855.  
  856. Public Property Let Action(ByVal intData As Integer)
  857.   mintAction = intData
  858. End Property
  859.  
  860. Public Property Get Action() As Integer
  861.   Action = mintAction
  862. End Property
  863.  
  864. Private Function strByteArrayToString(abBytes() As Byte) As String
  865.       
  866.   strByteArrayToString = StrConv(abBytes, vbUnicode)
  867.         
  868. '  'return a string from a byte array
  869. '  Dim lngBytePoint As Long
  870. '  Dim lngByteVal As Long
  871. '  Dim strOut As String
  872. '
  873. '  'init array pointer
  874. '  lngBytePoint = LBound(abBytes)
  875. '
  876. '  'fill sOut with characters in array
  877. '  While lngBytePoint <= UBound(abBytes)
  878. '    lngByteVal = abBytes(lngBytePoint)
  879. '
  880. '    'return sOut and stop if Chr$(0) is encountered
  881. '    If lngByteVal = 0 Then
  882. '      strByteArrayToString = strOut
  883. '      Exit Function
  884. '    Else
  885. '      strOut = strOut & Chr$(lngByteVal)
  886. '    End If
  887. '
  888. '    lngBytePoint = lngBytePoint + 1
  889. '
  890. '  Wend
  891. '
  892. '  'return sOut if Chr$(0) wasn't encountered
  893. '  strByteArrayToString = strOut
  894.     
  895. End Function
  896.  
  897. Private Function strLeftOfNull(ByVal strIn As String)
  898.   
  899.   If InStr(strIn, vbNullChar) Then
  900.     strLeftOfNull = Left$(strIn, InStr(strIn, vbNullChar) - 1)
  901.   Else
  902.     strLeftOfNull = strIn
  903.   End If
  904.     
  905. End Function
  906.  
  907. Private Function strAPIFilter(strIn)
  908.  
  909.   'prepares sIn for use as a filter string in API common dialog functions
  910.   Dim lngChrNdx As Long
  911.   Dim strOneChr As String
  912.   Dim strOutStr As String
  913.   
  914.   'convert any | characters to nulls
  915.   For lngChrNdx = 1 To Len(strIn)
  916.     strOneChr = Mid$(strIn, lngChrNdx, 1)
  917.     If strOneChr = "|" Then
  918.       strOutStr = strOutStr & vbNullChar
  919.     Else
  920.       strOutStr = strOutStr & strOneChr
  921.     End If
  922.   Next
  923.   
  924.   'add a null to the end
  925.   strOutStr = strOutStr & vbNullChar
  926.   
  927.   'return sOutStr
  928.   strAPIFilter = strOutStr
  929.     
  930. End Function
  931.  
  932. Private Sub ShowFileDialog(ByVal mintAction As Integer)
  933.     
  934.   'display the file dialog for ShowOpen or ShowSave
  935.   Dim udtOpenFile As OpenFilename
  936.   Dim lngMaxSize As Long
  937.     
  938.   On Error GoTo ShowFileDialogError
  939.     
  940.   '***    init property buffers
  941.   mintAction = mintAction  'Action property
  942.   mlngAPIReturn = 0  'APIReturn property
  943.   mlngExtendedError = 0  'ExtendedError property
  944.         
  945.   'Prepare mudtOpenFile for data
  946.   udtOpenFile.lStructSize = Len(udtOpenFile)
  947.   udtOpenFile.hwndOwner = mlnghWnd
  948.   'hInstance set to 0 - default
  949.   udtOpenFile.lpstrFilter = strAPIFilter(mstrFilter)
  950.   'lpstrCustomFilter set to 0 - default
  951.   'nMaxCustFilter set to 0 - default
  952.   udtOpenFile.iFilterIndex = CLng(mintFilterIndex)
  953.   If mlngMaxFileSize > 0 Then
  954.     lngMaxSize = mlngMaxFileSize
  955.   Else
  956.     lngMaxSize = cMaxFileSize
  957.   End If
  958.   udtOpenFile.lpstrFile = String(lngMaxSize + 1, 0)
  959.   udtOpenFile.nMaxFile = Len(udtOpenFile.lpstrFile) - 1
  960.   udtOpenFile.lpstrFileTitle = udtOpenFile.lpstrFile
  961.   udtOpenFile.nMaxFileTitle = udtOpenFile.nMaxFile
  962.   udtOpenFile.lpstrInitialDir = mstrInitDir
  963.   udtOpenFile.lpstrTitle = mstrDialogTitle
  964.   udtOpenFile.Flags = mlngFlags
  965.   udtOpenFile.lpstrDefExt = mstrDefaultExt
  966.     
  967.   'Call the GetOpenFileName API function
  968.   Select Case mintAction
  969.     Case cShowOpen
  970.       mlngAPIReturn = GetOpenFileName(udtOpenFile)
  971.     Case cShowSave
  972.       mlngAPIReturn = GetSaveFileName(udtOpenFile)
  973.     Case Else   'unknown action
  974.       Exit Sub
  975.   End Select
  976.       
  977.   '***    handle return from GetOpenFileName API function
  978.   Select Case mlngAPIReturn
  979.     Case cUserCanceled
  980.       If mblnCancelError = True Then
  981.         'generate an error
  982.         On Error GoTo 0
  983.         Err.Raise Number:=cdlCancel, _
  984.           Description:=cCancelDescription
  985.         Exit Sub
  986.       End If
  987.     Case cUserSelected
  988.       mstrFileName = strLeftOfNull(udtOpenFile.lpstrFile)
  989.       mstrFileTitle = strLeftOfNull(udtOpenFile.lpstrFileTitle)
  990.     Case Else   'an error occured
  991.       'call CommDlgExtendedError
  992.       mlngExtendedError = CommDlgExtendedError
  993.   End Select
  994.     
  995. Exit Sub
  996.  
  997. ShowFileDialogError:
  998.     
  999.   Exit Sub
  1000.  
  1001. End Sub
  1002.  
  1003. Sub StrToBytes(ab() As Byte, s As String)
  1004.  
  1005.   Dim cab As Long
  1006.   'Copy to existing array, padding or truncating if necessary
  1007.   cab = UBound(ab) - LBound(ab) + 1
  1008.   If Len(s) < cab Then s = s & String$(cab - Len(s), 0)
  1009.   CopyMemoryStr ab(LBound(ab)), s, LenB(s)
  1010.   
  1011. End Sub
  1012.  
  1013. Public Property Get hWnd() As Long
  1014.   hWnd = mlnghWnd
  1015. End Property
  1016.  
  1017. Public Property Let hWnd(ByVal lnghWnd As Long)
  1018.   mlnghWnd = lnghWnd
  1019. End Property



  1.  
  2. 'в форму
  3.  
  4. dim clsComDlg As clsCommonDialog
  5. Set clsComDlg = New clsCommonDialog
  6.  
  7. Private Sub Form_Load()
  8. With clsComDlg
  9.     .DialogTitle = "Выбрать файл"
  10.     .Filter = "wav-файл (*.wav)|*.wav"
  11.     .FilterIndex = 1
  12.     .hWnd = Me.hWnd
  13.     .ShowOpen
  14.     MsgBox .FileName
  15. End With
  16. End Sub

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам