jwacmnquery.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. {******************************************************************************}
  2. { }
  3. { ICommonQuery API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: cmnquery.h, released November 2001. The original Pascal}
  9. { code is: CmnQuery.pas, released March 2002. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaCmnQuery;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "cmnquery.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. ActiveX, // IPersist todo objidl, ocidl
  51. JwaWinUser, JwaWinType;
  52. const
  53. IID_IQueryForm: TGUID = (D1:$8cfcee30; D2:$39bd; D3:$11d0; D4:($b8, $d1, $0, $a0, $24, $ab, $2d, $bb));
  54. {$EXTERNALSYM IID_IQueryForm}
  55. IID_IPersistQuery: TGUID = (D1:$1a3114b8; D2:$a62e; D3:$11d0; D4:($a6, $c5, $0, $a0, $c9, $06, $af, $45));
  56. {$EXTERNALSYM IID_IPersistQuery}
  57. CLSID_CommonQuery: TGUID = (D1:$83bc5ec0; D2:$6f2a; D3:$11d0; D4:($a1, $c4, $0, $aa, $00, $c1, $6e, $65));
  58. {$EXTERNALSYM CLSID_CommonQuery}
  59. IID_ICommonQuery: TGUID = (D1:$ab50dec0; D2:$6f1d; D3:$11d0; D4:($a1, $c4, $0, $aa, $00, $c1, $6e, $65));
  60. {$EXTERNALSYM IID_ICommonQuery}
  61. //-----------------------------------------------------------------------------
  62. // IQueryForm
  63. //-----------------------------------------------------------------------------
  64. //
  65. // A query form object is registered under the query handlers CLSID,
  66. // a list is stored in the registry:
  67. //
  68. // HKCR\CLSID\{CLSID query handler}\Forms
  69. //
  70. // For each form object there are server values which can be defined:
  71. //
  72. // Flags = flags for the form object:
  73. // QUERYFORM_CHANGESFORMLIST
  74. // QUERYFORM_CHANGESOPTFORMLIST
  75. //
  76. // CLSID = string containing the CLSID of the InProc server to invoke
  77. // to get the IQueryFormObject.
  78. //
  79. // Forms = a sub key containing the CLSIDs for the forms registered
  80. // by IQueryForm::AddForms (or modified by ::AddPages), if
  81. // the flags are 0, then we scan this list looking for a match
  82. // for the default form specified.
  83. //
  84. QUERYFORM_CHANGESFORMLIST = $000000001;
  85. {$EXTERNALSYM QUERYFORM_CHANGESFORMLIST}
  86. QUERYFORM_CHANGESOPTFORMLIST = $000000002;
  87. {$EXTERNALSYM QUERYFORM_CHANGESOPTFORMLIST}
  88. //
  89. // Query Forms
  90. // ===========
  91. // Query forms are registered and have query pages added to them, a form without
  92. // pages is not displayed. Each form has a unique CLSID to allow it to be
  93. // selected by invoking the query dialog.
  94. //
  95. CQFF_NOGLOBALPAGES = $0000001; // = 1 => doesn't have global pages added
  96. {$EXTERNALSYM CQFF_NOGLOBALPAGES}
  97. CQFF_ISOPTIONAL = $0000002; // = 1 => form is hidden, unless optional forms requested
  98. {$EXTERNALSYM CQFF_ISOPTIONAL}
  99. type
  100. CQFORM = record
  101. cbStruct: DWORD;
  102. dwFlags: DWORD;
  103. clsid: CLSID;
  104. hIcon: HICON;
  105. pszTitle: LPCWSTR;
  106. end;
  107. {$EXTERNALSYM CQFORM}
  108. LPCQFORM = ^CQFORM;
  109. {$EXTERNALSYM LPCQFORM}
  110. TCQForm = CQFORM;
  111. PCQForm = LPCQFORM;
  112. LPCQADDFORMSPROC = function(lParam: LPARAM; pForm: LPCQFORM): HRESULT; stdcall;
  113. {$EXTERNALSYM LPCQADDFORMSPROC}
  114. //
  115. // Query Form Pages
  116. // ================
  117. // When a query form has been registered the caller can then add pages to it,
  118. // any form can have pages appended.
  119. //
  120. _cqpage = record
  121. cbStruct: DWORD;
  122. dwFlags: DWORD;
  123. pPageProc: Pointer{LPCQPAGEPROC};
  124. hInstance: HINSTANCE;
  125. idPageName: Integer;
  126. idPageTemplate: Integer;
  127. pDlgProc: DLGPROC;
  128. lParam: LPARAM;
  129. end;
  130. {$EXTERNALSYM _cqpage}
  131. CQPAGE = _cqpage;
  132. {$EXTERNALSYM CQPAGE}
  133. LPCQPAGE = ^CQPAGE;
  134. {$EXTERNALSYM LPCQPAGE}
  135. TCQPage = CQPAGE;
  136. PCQPage = LPCQPAGE;
  137. LPCQADDPAGESPROC = function(lParam: LPARAM; const clsidForm: CLSID; pPage: LPCQPAGE): HRESULT; stdcall;
  138. {$EXTERNALSYM LPCQADDPAGESPROC}
  139. LPCQPAGEPROC = function(pPage: LPCQPAGE; hwnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): HRESULT; stdcall;
  140. {$EXTERNALSYM LPCQPAGEPROC}
  141. //
  142. // IQueryForm interfaces
  143. //
  144. IQueryForm = interface(IUnknown)
  145. ['{8cfcee30-39bd-11d0-b8d1-00a024ab2dbb}']
  146. function Initialize(hkForm: HKEY): HRESULT; stdcall;
  147. function AddForms(pAddFormsProc: LPCQADDPAGESPROC; lParam: LPARAM): HRESULT; stdcall;
  148. function AddPages(pAddPagesProc: LPCQADDPAGESPROC; lParam: LPARAM): HRESULT; stdcall;
  149. end;
  150. {$EXTERNALSYM IQueryForm}
  151. //
  152. // Messages for pages
  153. //
  154. const
  155. CQPM_INITIALIZE = $00000001;
  156. {$EXTERNALSYM CQPM_INITIALIZE}
  157. CQPM_RELEASE = $00000002;
  158. {$EXTERNALSYM CQPM_RELEASE}
  159. CQPM_ENABLE = $00000003; // wParam = TRUE/FALSE (enable, disable), lParam = 0
  160. {$EXTERNALSYM CQPM_ENABLE}
  161. CQPM_GETPARAMETERS = $00000005; // wParam = 0, lParam = -> receives the LocalAlloc
  162. {$EXTERNALSYM CQPM_GETPARAMETERS}
  163. CQPM_CLEARFORM = $00000006; // wParam, lParam = 0
  164. {$EXTERNALSYM CQPM_CLEARFORM}
  165. CQPM_PERSIST = $00000007; // wParam = fRead, lParam -> IPersistQuery
  166. {$EXTERNALSYM CQPM_PERSIST}
  167. CQPM_HELP = $00000008; // wParam = 0, lParam -> LPHELPINFO
  168. {$EXTERNALSYM CQPM_HELP}
  169. CQPM_SETDEFAULTPARAMETERS = $00000009; // wParam = 0, lParam -> OPENQUERYWINDOW
  170. {$EXTERNALSYM CQPM_SETDEFAULTPARAMETERS}
  171. CQPM_HANDLERSPECIFIC = $10000000;
  172. {$EXTERNALSYM CQPM_HANDLERSPECIFIC}
  173. //-----------------------------------------------------------------------------
  174. // IPersistQuery
  175. //-----------------------------------------------------------------------------
  176. // IPersistQuery interface
  177. type
  178. IPersistQuery = interface(IPersist)
  179. ['{1a3114b8-a62e-11d0-a6c5-00a0c906af45}']
  180. function WriteString(pSection, pValueName, pValue: LPCWSTR): HRESULT; stdcall;
  181. function ReadString(pSection, pValueName, pBuffer: LPWSTR; cchBuffer: Integer): HRESULT; stdcall;
  182. function WriteInt(pSection, pValueName: LPCWSTR; value: Integer): HRESULT; stdcall;
  183. function ReadInt(pSection, pValueName: LPCWSTR; pValue: LPINT): HRESULT; stdcall;
  184. function WriteStruct(pSection, pValueName: LPCWSTR; pStruct: LPVOID; cbStruct: DWORD): HRESULT; stdcall;
  185. function ReadStruct(pSection, pValueName: LPCWSTR; pStruct: LPVOID; cbStruct: DWORD): HRESULT; stdcall;
  186. function Clear: HRESULT; stdcall;
  187. end;
  188. {$EXTERNALSYM IPersistQuery}
  189. //-----------------------------------------------------------------------------
  190. // ICommonQuery
  191. //-----------------------------------------------------------------------------
  192. const
  193. OQWF_OKCANCEL = $00000001; // = 1 => Provide OK/Cancel buttons
  194. {$EXTERNALSYM OQWF_OKCANCEL}
  195. OQWF_DEFAULTFORM = $00000002; // = 1 => clsidDefaultQueryForm is valid
  196. {$EXTERNALSYM OQWF_DEFAULTFORM}
  197. OQWF_SINGLESELECT = $00000004; // = 1 => view to have single selection (depends on viewer)
  198. {$EXTERNALSYM OQWF_SINGLESELECT}
  199. OQWF_LOADQUERY = $00000008; // = 1 => use the IPersistQuery to load the given query
  200. {$EXTERNALSYM OQWF_LOADQUERY}
  201. OQWF_REMOVESCOPES = $00000010; // = 1 => remove scope picker from dialog
  202. {$EXTERNALSYM OQWF_REMOVESCOPES}
  203. OQWF_REMOVEFORMS = $00000020; // = 1 => remove form picker from dialog
  204. {$EXTERNALSYM OQWF_REMOVEFORMS}
  205. OQWF_ISSUEONOPEN = $00000040; // = 1 => issue query on opening the dialog
  206. {$EXTERNALSYM OQWF_ISSUEONOPEN}
  207. OQWF_SHOWOPTIONAL = $00000080; // = 1 => list optional forms by default
  208. {$EXTERNALSYM OQWF_SHOWOPTIONAL}
  209. OQWF_SAVEQUERYONOK = $00000200; // = 1 => use the IPersistQuery to write the query on close
  210. {$EXTERNALSYM OQWF_SAVEQUERYONOK}
  211. OQWF_HIDEMENUS = $00000400; // = 1 => no menu bar displayed
  212. {$EXTERNALSYM OQWF_HIDEMENUS}
  213. OQWF_HIDESEARCHUI = $00000800; // = 1 => dialog is filter, therefore start, stop, new search etc
  214. {$EXTERNALSYM OQWF_HIDESEARCHUI}
  215. OQWF_PARAMISPROPERTYBAG = DWORD($80000000); // = 1 => the form parameters ptr is an IPropertyBag (ppbFormParameters)
  216. {$EXTERNALSYM OQWF_PARAMISPROPERTYBAG}
  217. type
  218. OPENQUERYWINDOW = record
  219. cbStruct: DWORD; // structure size
  220. dwFlags: DWORD; // flags (OQFW_*)
  221. clsidHandler: CLSID; // clsid of handler we are using
  222. pHandlerParameters: LPVOID; // handler specific structure for initialization
  223. clsidDefaultForm: CLSID; // default form to be selected (if OQF_DEFAULTFORM == 1 )
  224. pPersistQuery: IPersistQuery; // IPersistQuery used for loading queries
  225. //mvb IPropertyBag is an interface which needs finalization and therefor can't be present in a variant record
  226. //case Integer of
  227. // 0: (pFormParameters: Pointer);
  228. // 1: (ppbFormParameters: IPropertyBag);
  229. case Integer of
  230. 0: (pFormParameters: Pointer);
  231. 1: (ppbFormParameters: Pointer);
  232. end;
  233. {$EXTERNALSYM OPENQUERYWINDOW}
  234. LPOPENQUERYWINDOW = ^OPENQUERYWINDOW;
  235. {$EXTERNALSYM LPOPENQUERYWINDOW}
  236. TOpenQueryWindow = OPENQUERYWINDOW;
  237. POpenQueryWindow = LPOPENQUERYWINDOW;
  238. // ICommonQuery
  239. ICommonQuery = interface(IUnknown)
  240. ['{ab50dec0-6f1d-11d0-a1c4-00aa00c16e65}']
  241. function OpenQueryWindow(hwndParent: HWND; pQueryWnd: LPOPENQUERYWINDOW; out ppDataObject: IDataObject): HRESULT; stdcall;
  242. end;
  243. {$EXTERNALSYM ICommonQuery}
  244. implementation
  245. end.