DYMO-Printer SDK Wrapper for PureBasic
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

732 lines
25 KiB

  1. EnableExplicit
  2. ; DYMO Label Software (DLS) have to be installed.
  3. ; This Include is created for DLS v.8+ (year 2015+).
  4. ; Maybe it works with lower version, but this is untested.
  5. ; Constants
  6. ; ===========================================================
  7. ; For Printers with more than one tray
  8. Enumeration DYMO_Tray
  9. #DYMO_Tray_Unknown = -1
  10. #DYMO_Tray_Left = 0
  11. #DYMO_Tray_Right = 1
  12. #DYMO_Tray_Auto = 2
  13. EndEnumeration
  14. ; for DYMO_SetAddressPOSTNET(POSTNET_Pos)
  15. #DYMO_POSTNET_Pos_None = "NONE"
  16. #DYMO_POSTNET_Pos_Top = "TOP"
  17. #DYMO_POSTNET_Pos_Buttom = "BUTTOM"
  18. ; not really needed, but nice to know
  19. #DYMO_False = #False ; 0
  20. #DYMO_True = ~#DYMO_False ; -1
  21. ; Initialize all needed components or release them
  22. ; ===========================================================
  23. DeclareDLL DYMO_Init()
  24. ; Use this BEFORE any use of DYMO_*() commands.
  25. ; Prevent any use of DYMO_*() procedures if return value is not #True.
  26. ; Return: #True or #False
  27. DeclareDLL DYMO_Release()
  28. ; Release all objects created with DYMO_Init()
  29. ; After using DYMO_Release() stop using any DYMO_*() command.
  30. ; If you want to reuse DYMO_* commands, you can call DYMO_Init() again.
  31. ; Return: void
  32. ; Manage Printer(s) and printing
  33. ; ===========================================================
  34. DeclareDLL DYMO_ExaminePrinters()
  35. ; Examine available DYMO printers
  36. ; Return: Number of available printers
  37. DeclareDLL.s DYMO_NextPrinter()
  38. ; Cycle through the List of DYMO-Printer examined with DYMO_ExaminePrinters()
  39. ; Return: Printer name or #Null$ if no more printers available
  40. DeclareDLL.s DYMO_GetCurrentPrinterName()
  41. ; Get the name of the currently selected printer
  42. ; Return: selected printer name
  43. DeclareDLL DYMO_SelectPrinter(PrinterName.s)
  44. ; Redirects output to the selected printer. PrinterName is of the
  45. ; form "Printer name on Port". Returns TRUE on success, FALSE
  46. ; on error. Example:
  47. ; To Select the <LabelWriter EL60 on COM3>, you would use the
  48. ; command: DYMO_SelectPrinter("DYMO LabelWriter EL60 on COM3:")
  49. ; Return: #DYMO_True or #DYMO_False
  50. DeclareDLL DYMO_IsTwinTurboPrinter(PrinterName.s)
  51. ; Returns TRUE if the specified printer (PrinterName) is a
  52. ; LabelWriter Twin Turbo, FALSE otherwise.
  53. ; Return: #DYMO_True or #DYMO_False
  54. DeclareDLL DYMO_SetPrintMode(HighQuality = #True)
  55. ; When "HighQuality" is set to TRUE (Default value), labels containing barcode(s)
  56. ; will print at high quality mode but the print speed is reduced.
  57. ; Unsetting this mode will cause all labels to print at the fasted print
  58. ; speed.
  59. DeclareDLL DYMO_GetCurrentPaperTray()
  60. ; Further Information: When the currently selected printer is a
  61. ; LabelWriter Twin Turbo, DYMO Label software attempts To
  62. ; associate a paper tray With the currently opened label file. As an
  63. ; example, If the last label printed on the left tray was "Address
  64. ; 30252" And the last label printed on the right tray was "Shipping
  65. ; 30323", then when the user opens a label file that uses the
  66. ; "Address 30252" paper size, DYMO Label software automatically
  67. ; sets the tray selection To left tray.
  68. ; Return: the current active paper tray
  69. ; Possible Return values include:
  70. ; #DYMO_Tray_Unknown = Unknown Tray (program user must specify)
  71. ; #DYMO_Tray_Left = Left Tray (Roll)
  72. ; #DYMO_Tray_Right = Right Tray (Roll)
  73. ; #DYMO_Tray_Auto = Auto Switch
  74. DeclareDLL DYMO_IsPrinterOnline(PrinterName.s)
  75. ; This applies to locally connected printers only. Shared printers
  76. ; always return true. Returns true if the specified printer is online,
  77. ; false if the printer is offline.
  78. ; Return: #DYMO_True or #DYMO_False
  79. DeclareDLL DYMO_StartPrintJob()
  80. DeclareDLL DYMO_StopPrintJob()
  81. ; Wrapping DYMO_PrintLabel() calls within the DYMO_StartPrintJob() and
  82. ; DYMO_EndPrintJob() calls will cause labels to be printed as pages of the
  83. ; same print job.
  84. ; The benefit is seen with reduced the print job.
  85. ;
  86. ; Example:
  87. ; ; this printing loop creates a 10 page print job
  88. ; DYMO_StartPrintJob()
  89. ; For i = 1 to 10
  90. ; ; update some fields on the label
  91. ; DYMO_PrintLabel() ; print one label
  92. ; Next
  93. ; DYMO_StopPrintJob();
  94. ;
  95. ; this code above will print labels much faster than the code below: 
  96. ;
  97. ; ; this printing loop creates 10 different one page print jobs
  98. ; For i = 1 to 10
  99. ; ; update some fields on the label
  100. ; DYMO_PrintLabel() ; print one label
  101. ; Next
  102. ;
  103. ; Return: void
  104. DeclareDLL DYMO_PrintLabel(Copies = 1, Tray = #DYMO_Tray_Unknown, ShowDialog = #False)
  105. ; Prints the current label. "Copies" is the number of copies to print.
  106. ; "ShowDialog" controls the display of the print-progress dialog. If
  107. ; TRUE, then the dialog is displayed. Returns TRUE on success,
  108. ; FALSE on error.
  109. ; Note: When the currently selected printer is a LabelWriter Twin Turbo, this command defaults to
  110. ; use the left roll.
  111. ; Possible values For the "Tray" parameter include:
  112. ; #DYMO_Tray_Left = Left Roll
  113. ; #DYMO_Tray_Right = Right Roll
  114. ; #DYMO_Tray_Auto = Auto Switch - This puts the printer in a mode where it starts to
  115. ; print from the last printed roll and automatically switch over to the
  116. ; other roll when the starting roll runs out of paper. It continues to
  117. ; toggle back and forth between rolls as long as the user refills rolls
  118. ; once they become empty. This mode of printing is useful when the
  119. ; user is printing a large number of labels.
  120. ; Return: #DYMO_True or #DYMO_False
  121. ; Automatic creation of print-jobs
  122. ; ===========================================================
  123. DeclareDLL DYMO_SmartPasteFromClipboard()
  124. ; Parses text data in the Clipboard into records and prints a label for
  125. ; each record.
  126. ; Return: #DYMO_True if the operation was successful,
  127. ; #DYMO_False if the operation failed.
  128. DeclareDLL DYMO_SmartPasteFromFile(File.s)
  129. ; Parses comma or tab delimited data in a file into records and prints
  130. ; a label For each record.
  131. ; Return: #DYMO_True if the operation was successful,
  132. ; #DYMO_False if the operation failed.
  133. DeclareDLL DYMO_SmartPasteFromString(Text.s)
  134. ; Parses text data in "Text" into records and prints a label for each
  135. ; record.
  136. ; Return: #DYMO_True if the operation was successful,
  137. ; #DYMO_False if the operation failed.
  138. ; Manage .label files
  139. ; ===========================================================
  140. DeclareDLL DYMO_OpenMemory(*Buffer, BufferSize)
  141. ; Reads a label file from a buffer (vs. from a file or URL). This is
  142. ; useful If you intend to manage the binary data yourself. The
  143. ; buffer must be filled with the binary Data of the label file.
  144. ; Return: #DYMO_True if the label file was Read from the buffer correctly.
  145. ; #DYMO_False if the buffer is invalid.
  146. DeclareDLL DYMO_SaveMemory()
  147. ; Returns a pointer, which is actually containing
  148. ; the binary data of the label file currently open in DYMO Label
  149. ; software.
  150. ; You can use MemorySize() tu get the size of the buffer.
  151. ; If you not longer need the data use FreeMemory()
  152. ; Return: *Buffer
  153. DeclareDLL DYMO_OpenURL(URL.s)
  154. ; Opens a label file using an URL. The URL can start with http, https,
  155. ; ftp, or file, etc.
  156. ; Return: #DYMO_True if the file was opened successfully,
  157. ; #DYMO_False if the file does not exist.
  158. DeclareDLL DYMO_OpenLabel(File.s, ShowDialogBoxIfFail = #False)
  159. ; Opens a label file. Returns TRUE on success, FALSE on error.
  160. ; *Functional Difference Alert:
  161. ; The function will try to open the specified label file name With the .label extension first, even If
  162. ; the parameter specifies a different file extension.
  163. ; For example, If your application calls:
  164. ; DYMO_OpenLabel("mylabel.lwl")
  165. ; The function will try to look for the file in the following order:
  166. ; mylabel.label
  167. ; mylabel.lwl
  168. ; mylabel.lwt
  169. ; * The reason for this behavior has to do with how the implementation handles both ".lwl" and
  170. ; ".label" file formats. The implementation converts ".lwl" format into ".label" format internally
  171. ; before performing any actions on a label file. What this means is that when a label that was
  172. ; opened as ".lwl" will be saved as a ".label" file if the DYMO_SaveLabel() method is called.
  173. ; So if an SDK application opens a ".lwl" label file, modifies it, then saves the file. The file would
  174. ; be saved as a ".label" file. When the application returns to open the same ".lwl" file expecting to
  175. ; see the modifications, the DYMO_OpenLabel() procedure would need to open the ".label" file for the
  176. ; modification to be seen.
  177. ; If "ShowDIalogBoxIfFail" is set to TRUE and the specified file name is not found, opens the
  178. ; Label File Open dialog box.
  179. ; Return: #DYMO_True if the file was opened successfully,
  180. ; #DYMO_False if the file does not exist.
  181. DeclareDLL DYMO_SaveLabel(File.s = #Null$)
  182. ; Saves the current label. Returns TRUE on success, FALSE on
  183. ; error. If a "File" is given, saves the current label under a new name.
  184. ; *Functional Difference Alert:
  185. ; The function will save the specified label file name in the .label file extension, even if the
  186. ; parameter specifies a different file extension.
  187. ; For example, If your application calls:
  188. ; DYMO_SaveLabel("SomeFile.lwl")
  189. ; the function will save the file As "SomeFile.label". The label file is in the new DYMO Label v.8
  190. ; .label file format.
  191. ; Manage Most Recently Used (MRU) .label files
  192. ; ===========================================================
  193. DeclareDLL DYMO_MRU_GetFileCount()
  194. ; Return: the number of files in the MRU label file list.
  195. DeclareDLL DYMO_MRU_OpenFile(Index)
  196. ; Returns a label file name from the MRU label files List. The "Index"
  197. ; parameter identifies which file name in the MRU to return. The
  198. ; index is zero-based and the file name DOES NOT include the file
  199. ; path or extension. Example: "SomeFile"
  200. DeclareDLL.s DYMO_MRU_GetFileName(Index)
  201. DeclareDLL DYMO_MRU_ExamineFiles()
  202. ; Examine available MRU files
  203. ; Return: Number of available Files
  204. DeclareDLL.s DYMO_MRU_NextFile()
  205. ; Cycle through the MRU-List examined with DYMO_MRU_ExamineFiles()
  206. ; Return: Filename or #Null$ if no more available
  207. ; Proxy-settings (for commands with URL)
  208. ; ===========================================================
  209. DeclareDLL DYMO_ProxySetup(Protocol.s, ServerName.s, Port.l, ProxyBypass.s, UserName.s, Password.s)
  210. ; Allows customized proxy settings (different from IE’s Default
  211. ; proxy settings). All URL related function calls in the SDK will
  212. ; adhere to these proxy settings.
  213. DeclareDLL DYMO_ProxyClearSettings()
  214. ; Clears all proxy settings and revert back to using IE’s default
  215. ; proxy settings.
  216. DeclareDLL DYMO_ProxyBypass(Set = #True) ; #False = default
  217. ; Setting the property to TRUE will cause all URL related SDK
  218. ; functions To bypass any proxy settings, including IE’s Default
  219. ; proxy settings.
  220. ; Setting the property to FALSE (the Default value) means all URL
  221. ; related SDK functions will use either IE’s Default proxy setting or
  222. ; the user specified proxy settings
  223. ; Manage currently loaded .label and modify objects
  224. ; ===========================================================
  225. DeclareDLL DYMO_ExamineObjects(VariableOnly = #True)
  226. ; Examine available objects in the current loaded label. If "VariableOnly" is set to
  227. ; TRUE then only variable Objects are examined.
  228. ; Return: Number of Objects
  229. DeclareDLL.s DYMO_NextObject()
  230. ; Cycle through the objects examined with DYMO_ExamineObjectes()
  231. ; Return: ObjectName or #Null$ if no more available
  232. DeclareDLL DYMO_GetAddressFieldCount()
  233. ; This procedure returns the number of address objects on the current
  234. ; label. Used to determine possible values for the index parameter of
  235. ; the DYMO_SetAddressPOSTNET() and DYMO_SetAddress functions.
  236. DeclareDLL.s DYMO_GetText(Object.s)
  237. ; Given an "Object" name returns the contents of the object.
  238. ; This operation only applies to address, barcode and text objects.
  239. DeclareDLL DYMO_SetAddress(Address.s, Index = 1)
  240. ; Given an "Index" of an address object, places the text in the object.
  241. ; The index is normally 1, but for designs with more than one
  242. ; address object, the index can be greater than one to select other
  243. ; address objects.
  244. ; Return: #DYMO_True on success or #DYMO_False on error
  245. DeclareDLL DYMO_SetField(Object.s, Text.s)
  246. ; Given an object name, and some text, changes the text of the object
  247. ; to have the new text. This operation only applies to address,
  248. ; barcode, and text objects.
  249. ; Return: #DYMO_True on success or #DYMO_False on error
  250. DeclareDLL DYMO_SetAddressPOSTNET(POSTNET_Pos.s, Index = 1)
  251. ; Given an index of an address object, changes the POSTNET
  252. ; barcode setting for the object. The index is normally 1, but for
  253. ; designs with more than one address object, the index can be greater
  254. ; than one to select other address objects.
  255. ; Position can be #DYMO_POSTNET_Pos_None,
  256. ; #DYMO_POSTNET_Pos_Top or #DYMO_POSTNET_Pos_Buttom
  257. ; Return: void
  258. DeclareDLL DYMO_PasteFromClipboard(Object.s)
  259. ; Paste text from the clipboard to an object by the given
  260. ; "Object" name.
  261. ; Return: #DYMO_True on success or #DYMO_False on error
  262. DeclareDLL DYMO_SetImageFile(Object.s, File.s)
  263. ; Load an image file to a graphic object by the given "Object" name.
  264. ; Return: #DYMO_True on success or #DYMO_False on error
  265. DeclareDLL DYMO_SetImageURL(Object.s, URL.s)
  266. ; Allows specifying URL as the image source for an image object on
  267. ; the label.
  268. ; Return: #DYMO_True on success or #DYMO_False on error
  269. DeclareDLL DYMO_PasteImageFromClipboard(Object.s)
  270. ; Paste image from the clipboard to an object by the given
  271. ; "Object" name.
  272. ; Return: #DYMO_True on success or #DYMO_False on error
  273. ; Internally used Procedures
  274. ; ===========================================================
  275. Declare INTERNAL_DYMO_Variant2Buffer(*Var.VARIANT);Return: *Mem Pointer (use FreeMemory() / MemorySize())
  276. Declare INTERNAL_DYMO_Buffer2Variant(*Buffer, BufferSize);Return: *Variant, use VariantClear_() AND ClearStructure() !!
  277. ; some tests for the include
  278. ; ===========================================================
  279. CompilerIf Defined(INCLUDE_DYMO, #PB_Constant) ; if DYMO / DYMO_DLL is already included
  280. CompilerError "<" + #PB_Compiler_Filename + "> DYMO already included !!"
  281. CompilerElse
  282. #INCLUDE_DYMO = #True
  283. CompilerEndIf
  284. CompilerIf Defined(INCLUDE_COMATE, #PB_Constant) = #False ; if COMatePLUS is not included
  285. XIncludeFile "COMatePLUS/COMatePLUS_Residents.pbi"
  286. XIncludeFile "COMatePLUS/COMatePLUS.pbi"
  287. ;CompilerWarning "<" + #PB_Compiler_Filename + ~"> if you want to include other COMatePLUS Version, you have to include \"COMatePLUS.pbi\""
  288. CompilerEndIf
  289. CompilerIf #PB_Compiler_Unicode = #False
  290. CompilerError "<" + #PB_Compiler_Filename + "> Needs Unicode!!"
  291. CompilerEndIf
  292. ; Structures
  293. ; ===========================================================
  294. Structure DYMO_Struct_COM
  295. AddIn.COMateObject
  296. Labels.COMateObject
  297. EndStructure
  298. Structure DYMO_Struct_RetVar
  299. NextPrinter.s
  300. GetCurrentPrinterName.s
  301. MRU_NextFile.s
  302. MRU_GetFileName.s
  303. NextObject.s
  304. GetText.s
  305. EndStructure
  306. Structure DYMO_Struct
  307. COM.DYMO_Struct_COM
  308. List Printers.s()
  309. List MRU_Files.s()
  310. List Objects.s()
  311. Initialized.i
  312. RetVar.DYMO_Struct_RetVar
  313. EndStructure
  314. ; Procedures
  315. ; ===========================================================
  316. ProcedureDLL DYMO_Init()
  317. Global DYMO.DYMO_Struct
  318. ; create needed COMate objects
  319. If Not DYMO\Initialized
  320. DYMO\COM\AddIn = COMate_CreateObject("Dymo.DymoAddIn")
  321. DYMO\COM\Labels = COMate_CreateObject("Dymo.DymoLabels")
  322. EndIf
  323. If DYMO\COM\AddIn And DYMO\COM\Labels
  324. DYMO\Initialized = #True
  325. EndIf
  326. ProcedureReturn DYMO\Initialized
  327. EndProcedure
  328. ProcedureDLL DYMO_Release()
  329. ; release COMate objects
  330. If DYMO\Initialized
  331. If DYMO\COM\AddIn
  332. DYMO\COM\Labels\Release()
  333. EndIf
  334. If DYMO\COM\Labels
  335. DYMO\COM\AddIn\Release()
  336. EndIf
  337. DYMO\Initialized = #False
  338. EndIf
  339. ClearList(DYMO\MRU_Files())
  340. ClearList(DYMO\Objects())
  341. ClearList(DYMO\Printers())
  342. EndProcedure
  343. ProcedureDLL DYMO_ExaminePrinters()
  344. Protected Temp.s, i
  345. ClearList(DYMO\Printers())
  346. ; get string vom dls
  347. Temp.s = DYMO\COM\AddIn\GetStringProperty("GetDymoPrinters()")
  348. ; split string and fill list
  349. For i = 0 To CountString(Temp, "|")
  350. AddElement(DYMO\Printers())
  351. DYMO\Printers() = StringField(Temp, i + 1, "|")
  352. Next
  353. ResetList(DYMO\Printers())
  354. ProcedureReturn ListSize(DYMO\Printers())
  355. EndProcedure
  356. ProcedureDLL.s DYMO_NextPrinter()
  357. DYMO\RetVar\NextPrinter = #Null$
  358. If NextElement(DYMO\Printers())
  359. DYMO\RetVar\NextPrinter = DYMO\Printers()
  360. EndIf
  361. ProcedureReturn DYMO\RetVar\NextPrinter
  362. EndProcedure
  363. ProcedureDLL DYMO_SelectPrinter(PrinterName.s)
  364. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("SelectPrinter('" + PrinterName + "')")
  365. EndProcedure
  366. ProcedureDLL DYMO_IsTwinTurboPrinter(PrinterName.s)
  367. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("IsTwinTurboPrinter('" + PrinterName + "')")
  368. EndProcedure
  369. ProcedureDLL DYMO_GetCurrentPaperTray()
  370. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("GetCurrentPaperTray()");
  371. EndProcedure
  372. ProcedureDLL.s DYMO_GetCurrentPrinterName()
  373. DYMO\RetVar\GetCurrentPrinterName = DYMO\COM\AddIn\GetStringProperty("GetCurrentPrinterName()")
  374. ProcedureReturn DYMO\RetVar\GetCurrentPrinterName
  375. EndProcedure
  376. ProcedureDLL DYMO_StartPrintJob()
  377. DYMO\COM\AddIn\Invoke("StartPrintJob()")
  378. EndProcedure
  379. ProcedureDLL DYMO_StopPrintJob()
  380. DYMO\COM\AddIn\Invoke("EndPrintJob()")
  381. EndProcedure
  382. ProcedureDLL DYMO_OpenLabel(File.s, ShowDialogBoxIfFail = #False)
  383. If ShowDialogBoxIfFail
  384. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("Open2('" + File + "')")
  385. Else
  386. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("Open('" + File + "')")
  387. EndIf
  388. EndProcedure
  389. ProcedureDLL DYMO_SaveLabel(File.s = #Null$)
  390. If File = #Null$
  391. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("Save()")
  392. Else
  393. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("SaveAs('" + File + "')")
  394. EndIf
  395. EndProcedure
  396. ProcedureDLL DYMO_PrintLabel(Copies = 1, Tray = #DYMO_Tray_Unknown, ShowDialog = #False)
  397. Select Tray
  398. Case #DYMO_Tray_Left, #DYMO_Tray_Right, #DYMO_Tray_Auto
  399. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("Print2(" + Str(Copies) + "," + Str(ShowDialog) + "," + Str(Tray) + ")")
  400. Default
  401. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("Print(" + Str(Copies) + "," + Str(ShowDialog) + ")")
  402. EndSelect
  403. EndProcedure
  404. ProcedureDLL DYMO_IsPrinterOnline(PrinterName.s)
  405. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("IsPrinterOnline('" + PrinterName + "')")
  406. EndProcedure
  407. ProcedureDLL DYMO_OpenMemory(*Buffer, BufferSize)
  408. Protected *Var.VARIANT
  409. Protected Ret = #False
  410. ; Create Variant bufffer and copy data
  411. *Var = INTERNAL_DYMO_Buffer2Variant(*Buffer, BufferSize)
  412. If *Var
  413. Ret = DYMO\COM\AddIn\GetIntegerProperty("OpenStream(" + Str(*Var) + " AS VARIANT BYREF)")
  414. VariantClear_(*Var)
  415. ClearStructure(*Var, VARIANT)
  416. EndIf
  417. ProcedureReturn Ret
  418. EndProcedure
  419. ProcedureDLL DYMO_SaveMemory()
  420. Protected *Var.VARIANT
  421. Protected *Ret = #Null
  422. ; get return *variant from property
  423. *Var = DYMO\COM\AddIn\GetVariantProperty("SaveStream()")
  424. If *Var
  425. *Ret = INTERNAL_DYMO_Variant2Buffer(*Var) ; allocate some memory and copy data
  426. VariantClear_(*Var)
  427. EndIf
  428. ProcedureReturn *Ret
  429. EndProcedure
  430. ProcedureDLL DYMO_OpenURL(URL.s)
  431. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("OpenURL('" + URL + "')")
  432. EndProcedure
  433. ProcedureDLL DYMO_MRU_ExamineFiles()
  434. Protected Temp.s, i
  435. ClearList(DYMO\MRU_Files())
  436. ; get string from dls
  437. Temp.s = DYMO\COM\AddIn\GetStringProperty("GetMRULabelFiles()")
  438. ; split string and fill list
  439. For i = 0 To CountString(Temp, "|")
  440. AddElement(DYMO\MRU_Files())
  441. DYMO\MRU_Files() = StringField(Temp, i + 1, "|")
  442. Next
  443. ResetList(DYMO\MRU_Files())
  444. ProcedureReturn ListSize(DYMO\MRU_Files())
  445. EndProcedure
  446. ProcedureDLL.s DYMO_MRU_NextFile()
  447. DYMO\RetVar\MRU_NextFile = #Null$
  448. If NextElement(DYMO\MRU_Files())
  449. DYMO\RetVar\MRU_NextFile = DYMO\MRU_Files()
  450. EndIf
  451. ProcedureReturn DYMO\RetVar\MRU_NextFile
  452. EndProcedure
  453. ProcedureDLL DYMO_MRU_GetFileCount()
  454. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("GetMRULabelFileCount()")
  455. EndProcedure
  456. ProcedureDLL.s DYMO_MRU_GetFileName(Index)
  457. DYMO\RetVar\MRU_GetFileName = DYMO\COM\AddIn\GetStringProperty("GetMRULabelFileName(" + Str(Index) + ")")
  458. ProcedureReturn DYMO\RetVar\MRU_GetFileName
  459. EndProcedure
  460. ProcedureDLL DYMO_MRU_OpenFile(Index)
  461. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("OpenMRULabelFile(" + Str(Index) + ")")
  462. EndProcedure
  463. ProcedureDLL DYMO_SetPrintMode(HighQuality = #True)
  464. If HighQuality
  465. DYMO\COM\AddIn\Invoke("SetGraphicsAndBarcodePrintMode(#True)")
  466. Else
  467. DYMO\COM\AddIn\Invoke("SetGraphicsAndBarcodePrintMode(#False)")
  468. EndIf
  469. EndProcedure
  470. ProcedureDLL DYMO_SmartPasteFromClipboard()
  471. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("SmartPasteFromClipboard()")
  472. EndProcedure
  473. ProcedureDLL DYMO_SmartPasteFromFile(File.s)
  474. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("SmartPasteFromFile('" + File + "')")
  475. EndProcedure
  476. ProcedureDLL DYMO_SmartPasteFromString(Text.s)
  477. ProcedureReturn DYMO\COM\AddIn\GetIntegerProperty("SmartPasteFromString('" + Text + "')")
  478. EndProcedure
  479. ProcedureDLL DYMO_ProxySetup(Protocol.s, ServerName.s, Port.l, ProxyBypass.s, UserName.s, Password.s)
  480. DYMO\COM\AddIn\Invoke("SetupProxySettings('" +
  481. Protocol + "','" +
  482. ServerName + "'," +
  483. Str(Port) + ",'" +
  484. ProxyBypass + "','" +
  485. UserName + "','" +
  486. Password + "')")
  487. EndProcedure
  488. ProcedureDLL DYMO_ProxyClearSettings()
  489. DYMO\COM\AddIn\Invoke("ClearProxySettings()")
  490. EndProcedure
  491. ProcedureDLL DYMO_ProxyBypass(Set = #True) ; #False = default
  492. If Set
  493. DYMO\COM\AddIn\SetProperty("proxyBypass = #True")
  494. Else
  495. DYMO\COM\AddIn\SetProperty("proxyBypass = #False")
  496. EndIf
  497. EndProcedure
  498. ProcedureDLL DYMO_ExamineObjects(VariableOnly = #True)
  499. Protected Temp.s, i
  500. ClearList(DYMO\Objects())
  501. ; get string of objects
  502. If VariableOnly
  503. Temp.s = DYMO\COM\Labels\GetStringProperty("GetObjectNames(#True)")
  504. Else
  505. Temp.s = DYMO\COM\Labels\GetStringProperty("GetObjectNames(#False)")
  506. EndIf
  507. ; split string and fill list
  508. For i = 0 To CountString(Temp, "|")
  509. AddElement(DYMO\Objects())
  510. DYMO\Objects() = StringField(Temp, i + 1, "|")
  511. Next
  512. ResetList(DYMO\Objects())
  513. ProcedureReturn ListSize(DYMO\Objects())
  514. EndProcedure
  515. ProcedureDLL.s DYMO_NextObject()
  516. DYMO\RetVar\NextObject = #Null$
  517. If NextElement(DYMO\Objects())
  518. DYMO\RetVar\NextObject = DYMO\Objects()
  519. EndIf
  520. ProcedureReturn DYMO\RetVar\NextObject
  521. EndProcedure
  522. ProcedureDLL.s DYMO_GetText(Object.s)
  523. DYMO\RetVar\GetText = DYMO\COM\Labels\GetStringProperty("GetText('" + Object + "')")
  524. ProcedureReturn DYMO\RetVar\GetText
  525. EndProcedure
  526. ProcedureDLL DYMO_SetAddress(Address.s, Index = 1)
  527. ProcedureReturn DYMO\COM\Labels\GetIntegerProperty("SetAddress(" + Str(Index) + ",'" + Address + "')")
  528. EndProcedure
  529. ProcedureDLL DYMO_SetField(Object.s, Text.s)
  530. ProcedureReturn DYMO\COM\Labels\GetIntegerProperty("SetField('" + Object + "','" + Text + "')")
  531. EndProcedure
  532. ProcedureDLL DYMO_GetAddressFieldCount()
  533. ProcedureReturn DYMO\COM\Labels\GetIntegerProperty("AddressFieldCount()")
  534. EndProcedure
  535. ProcedureDLL DYMO_SetAddressPOSTNET(POSTNET_Pos.s, Index = 1)
  536. DYMO\COM\Labels\Invoke("POSTNET(" + Str(Index) + ",'" + POSTNET_Pos + "')")
  537. EndProcedure
  538. ProcedureDLL DYMO_SetImageFile(Object.s, File.s)
  539. ProcedureReturn DYMO\COM\Labels\GetIntegerProperty("SetImageFile('" + Object + "','" + File + "')")
  540. EndProcedure
  541. ProcedureDLL DYMO_SetImageURL(Object.s, URL.s)
  542. ProcedureReturn DYMO\COM\Labels\GetIntegerProperty("SetImageURL('" + Object + "','" + URL + "',#NUllString)")
  543. EndProcedure
  544. ProcedureDLL DYMO_PasteFromClipboard(Object.s)
  545. ProcedureReturn DYMO\COM\Labels\GetIntegerProperty("PasteFromClipboard('" + Object + "')")
  546. EndProcedure
  547. ProcedureDLL DYMO_PasteImageFromClipboard(Object.s)
  548. ProcedureReturn DYMO\COM\Labels\GetIntegerProperty("PasteImageFromClipboard('" + Object + "')")
  549. EndProcedure
  550. Procedure INTERNAL_DYMO_Variant2Buffer(*Var.VARIANT)
  551. Protected Size, *Ret = #Null, *SafeArray.SAFEARRAY
  552. If *Var And *Var\vt = #VT_ARRAY|#VT_UI1 And *Var\parray
  553. *SafeArray = *Var\parray
  554. Size = *SafeArray\rgsabound[0]\cElements - *SafeArray\rgsabound[0]\lLbound
  555. If Size
  556. *Ret = AllocateMemory(Size)
  557. If *Ret
  558. If SafeArrayLock_(*SafeArray) = #S_OK
  559. CopyMemory(*SafeArray\pvData, *Ret, Size)
  560. SafeArrayUnlock_(*SafeArray)
  561. Else
  562. FreeMemory(*Ret)
  563. *Ret = #Null
  564. EndIf
  565. EndIf
  566. EndIf
  567. EndIf
  568. ProcedureReturn *Ret
  569. EndProcedure
  570. Procedure INTERNAL_DYMO_Buffer2Variant(*Buffer, BufferSize)
  571. Protected *SafeArray.SAFEARRAY, SafeArrayBound.SAFEARRAYBOUND
  572. Protected *Ret_Variant.VARIANT = AllocateStructure(VARIANT)
  573. If *Ret_Variant And *Buffer And BufferSize > 0
  574. VariantClear_(*Ret_Variant)
  575. SafeArrayBound\lLbound = 0
  576. SafeArrayBound\cElements = BufferSize
  577. *SafeArray = SafeArrayCreate_(#VT_UI1, 1, SafeArrayBound)
  578. If *SafeArray
  579. If SafeArrayLock_(*SafeArray) = #S_OK
  580. CopyMemory(*Buffer, *SafeArray\pvData, BufferSize)
  581. *Ret_Variant\vt = #VT_ARRAY|#VT_UI1
  582. *Ret_Variant\parray = *SafeArray
  583. SafeArrayUnlock_(*SafeArray)
  584. EndIf
  585. EndIf
  586. EndIf
  587. ProcedureReturn *Ret_Variant
  588. EndProcedure
  589. DisableExplicit
  590. ; CursorPosition = 1
  591. ; Folding = AAAAAAAA-
  592. ; EnableXP
  593. ; CompileSourceDirectory
  594. ; EnableCompileCount = 0
  595. ; EnableBuildCount = 0
  596. ; EnableExeConstant
  597. ; EnableUnicode

Impressum | Datenschutz