PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/OperationsProgressDialog/OperationsProgressDialog.ahk

http://github.com/maul-esel/COM-Classes
AutoHotKey | 209 lines | 60 code | 12 blank | 137 comment | 0 complexity | 4ed6710b505b27853390c9b69ffddd4a MD5 | raw file
  1. /*
  2. class: OperationsProgressDialog
  3. wraps the *IOperationsProgressDialog* interface and exposes methods to get, set, and query a progress dialog.
  4. Authors:
  5. - maul.esel (https://github.com/maul-esel)
  6. License:
  7. - *LGPL* (http://www.gnu.org/licenses/lgpl-2.1.txt)
  8. Documentation:
  9. - *class documentation* (http://maul-esel.github.com/COM-Classes/master/OperationsProgressDialog)
  10. - *msdn* (http://msdn.microsoft.com/en-us/library/windows/desktop/bb775368)
  11. Requirements:
  12. AutoHotkey - AHK v2 alpha
  13. OS - Windows 2000 Professional, Windows XP, Windows 2000 Server or higher
  14. Base classes - _CCF_Error_Handler_, Unknown
  15. Constant classes - PROGDLG, PDOPSTATUS, PMODE
  16. */
  17. class OperationsProgressDialog extends Unknown
  18. {
  19. /*
  20. Field: CLSID
  21. This is CLSID_ProgressDialog. It is required to create an instance.
  22. */
  23. static CLSID := "{F8383852-FCD3-11d1-A6B9-006097DF5BD4}"
  24. /*
  25. Field: IID
  26. This is IID_IOperationsProgressDialog. It is required to create an instance.
  27. */
  28. static IID := "{0C9FB851-E5C9-43EB-A370-F0677B13874C}"
  29. /*
  30. Method: StartProgressDialog
  31. Starts the progress dialog.
  32. Parameters:
  33. [opt] UINT flags - a combination fo flags modifying the dialog. You can use the fields of the PROGDLG class for convenience.
  34. [opt] HWND hParent - the handle to the parent window
  35. Returns:
  36. BOOL success - true on success, false otherwise
  37. */
  38. StartProgressDialog(flags := 0, hParent := 0)
  39. {
  40. return this._Error(DllCall(NumGet(this.vt+03*A_PtrSize), "Ptr", this.ptr, "UInt", hParent, "Uint", flags))
  41. }
  42. /*
  43. Method: StopProgressDialog
  44. Stops the progress dialog.
  45. Returns:
  46. BOOL success - true on success, false otherwise
  47. */
  48. StopProgressDialog()
  49. {
  50. return this._Error(DllCall(NumGet(this.vt+04*A_PtrSize), "Ptr", this.ptr))
  51. }
  52. /*
  53. Method: SetOperation
  54. Sets which progress dialog operation is occurring.
  55. Parameters:
  56. UINT operation - the operation to perform. You can use the fields of the SPACTION class for convenience.
  57. Returns:
  58. BOOL success - true on success, false otherwise
  59. */
  60. SetOperation(operation)
  61. {
  62. return this._Error(DllCall(NumGet(this.vt+05*A_PtrSize), "Ptr", this.ptr, "UInt", operation))
  63. }
  64. /*
  65. Method: SetMode
  66. Sets progress dialog operations mode.
  67. Parameters:
  68. UINT mode - the operation mode. You can use the fields of the PMODE class for convenience.
  69. Returns:
  70. BOOL success - true on success, false otherwise
  71. */
  72. SetMode(mode)
  73. {
  74. return this._Error(DllCall(NumGet(this.vt+06*A_PtrSize), "Ptr", this.ptr, "Uint", mode))
  75. }
  76. /*
  77. Method: UpdateProgress
  78. Parameters:
  79. int pointsReached - Current points, used for showing progress in points. (progressbar)
  80. int pointsTotal - Total points, used for showing progress in points.
  81. int sizeReached - Current size in bytes, used for showing progress in bytes.
  82. int sizeTotal - total size in bytes, used for showing progress in bytes.
  83. int itemsReached - Current items, used for showing progress in items.
  84. int itemsTotal - Specifies total items, used for showing progress in items.
  85. Returns:
  86. BOOL success - true on success, false otherwise
  87. */
  88. UpdateProgress(pointsReached, pointsTotal, sizeReached, sizeTotal, itemsReached, itemsTotal)
  89. {
  90. return this._Error(DllCall(NumGet(this.vt+07*A_PtrSize), "Ptr", this.ptr
  91. , "Uint64", pointsReached
  92. , "Uint64", pointsTotal
  93. , "UInt64", sizeReached
  94. , "UInt64", sizeTotal
  95. , "Uint64", itemsReached
  96. , "Uint64", itemsTotal))
  97. }
  98. /*
  99. Method: UpdateLocations
  100. Called to specify the text elements stating the source and target in the current progress dialog.
  101. Parameters:
  102. IShellItem source - the pointer to an IShellItem that represents the source Shell item.
  103. IShellItem target - the pointer to an IShellItem that represents the target Shell item.
  104. [opt] IShellItem item - *Win7 and later:* A pointer to an IShellItem that represents the item currently being operated on by the operation engine.
  105. Returns:
  106. BOOL success - true on success, false otherwise
  107. Remarks:
  108. You can either pass raw pointers or ShellItem instances to this method.
  109. */
  110. UpdateLocations(source, target, item := 0)
  111. {
  112. return this._Error(DllCall(NumGet(this.vt+08*A_PtrSize), "Ptr", this.ptr
  113. , "Ptr", IsObject(source) ? source.ptr : source
  114. , "Ptr", IsObject(target) ? target.ptr : target
  115. , "Ptr", IsObject(item) ? item.ptr : item))
  116. }
  117. /*
  118. Method: ResetTimer
  119. Resets progress dialog timer to 0.
  120. Returns:
  121. BOOL success - true on success, false otherwise
  122. */
  123. ResetTimer()
  124. {
  125. return this._Error(DllCall(NumGet(this.vt+09*A_PtrSize), "Ptr", this.ptr))
  126. }
  127. /*
  128. Method: PauseTimer
  129. Pauses progress dialog timer.
  130. Returns:
  131. BOOL success - true on success, false otherwise
  132. */
  133. PauseTimer()
  134. {
  135. return this._Error(DllCall(NumGet(this.vt+10*A_PtrSize), "Ptr", this.ptr))
  136. }
  137. /*
  138. Method: ResumeTimer
  139. Resumes progress dialog timer.
  140. Returns:
  141. BOOL success - true on success, false otherwise
  142. */
  143. ResumeTimer()
  144. {
  145. return this._Error(DllCall(NumGet(this.vt+11*A_PtrSize), "Ptr", this.ptr))
  146. }
  147. /*
  148. Method: GetMilliseconds
  149. Gets elapsed and remaining time for progress dialog.
  150. Parameters:
  151. byref INT elapsed - the elapsed time in milliseconds
  152. byref INT remaining - the remaining time in milliseconds
  153. Returns:
  154. BOOL success - true on success, false otherwise
  155. */
  156. GetMilliseconds(ByRef elapsed, ByRef remaining)
  157. {
  158. return this._Error(DllCall(NumGet(this.vt+12*A_PtrSize), "Ptr", this.ptr, "UInt64*", elapsed, "UInt64*", remaining))
  159. }
  160. /*
  161. Method: GetOperationStatus
  162. Gets operation status for progress dialog.
  163. Returns:
  164. UINT status - the dialog's status. You can compare it to the members of the PDOPSTATUS class.
  165. Remarks:
  166. - To get information about success and failure of this method, check the instance's Error object.
  167. */
  168. GetOperationStatus()
  169. {
  170. local status
  171. this._Error(DllCall(NumGet(this.vt+13*A_PtrSize), "Ptr", this.ptr, "UInt*", status))
  172. return status
  173. }
  174. }