jwacmnquery.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. // $Id: JwaCmnQuery.pas,v 1.8 2005/09/03 13:12:10 marquardt Exp $
  43. unit JwaCmnQuery;
  44. {$WEAKPACKAGEUNIT}
  45. {$I jediapilib.inc}
  46. interface
  47. uses
  48. JwaActiveX, // IPersist todo objidl, ocidl
  49. JwaWindows;
  50. {$HPPEMIT ''}
  51. {$HPPEMIT '#include "cmnquery.h"'}
  52. {$HPPEMIT ''}
  53. const
  54. IID_IQueryForm: TGUID = (D1:$8cfcee30; D2:$39bd; D3:$11d0; D4:($b8, $d1, $0, $a0, $24, $ab, $2d, $bb));
  55. {$EXTERNALSYM IID_IQueryForm}
  56. IID_IPersistQuery: TGUID = (D1:$1a3114b8; D2:$a62e; D3:$11d0; D4:($a6, $c5, $0, $a0, $c9, $06, $af, $45));
  57. {$EXTERNALSYM IID_IPersistQuery}
  58. CLSID_CommonQuery: TGUID = (D1:$83bc5ec0; D2:$6f2a; D3:$11d0; D4:($a1, $c4, $0, $aa, $00, $c1, $6e, $65));
  59. {$EXTERNALSYM CLSID_CommonQuery}
  60. IID_ICommonQuery: TGUID = (D1:$ab50dec0; D2:$6f1d; D3:$11d0; D4:($a1, $c4, $0, $aa, $00, $c1, $6e, $65));
  61. {$EXTERNALSYM IID_ICommonQuery}
  62. //-----------------------------------------------------------------------------
  63. // IQueryForm
  64. //-----------------------------------------------------------------------------
  65. //
  66. // A query form object is registered under the query handlers CLSID,
  67. // a list is stored in the registry:
  68. //
  69. // HKCR\CLSID\{CLSID query handler}\Forms
  70. //
  71. // For each form object there are server values which can be defined:
  72. //
  73. // Flags = flags for the form object:
  74. // QUERYFORM_CHANGESFORMLIST
  75. // QUERYFORM_CHANGESOPTFORMLIST
  76. //
  77. // CLSID = string containing the CLSID of the InProc server to invoke
  78. // to get the IQueryFormObject.
  79. //
  80. // Forms = a sub key containing the CLSIDs for the forms registered
  81. // by IQueryForm::AddForms (or modified by ::AddPages), if
  82. // the flags are 0, then we scan this list looking for a match
  83. // for the default form specified.
  84. //
  85. QUERYFORM_CHANGESFORMLIST = $000000001;
  86. {$EXTERNALSYM QUERYFORM_CHANGESFORMLIST}
  87. QUERYFORM_CHANGESOPTFORMLIST = $000000002;
  88. {$EXTERNALSYM QUERYFORM_CHANGESOPTFORMLIST}
  89. //
  90. // Query Forms
  91. // ===========
  92. // Query forms are registered and have query pages added to them, a form without
  93. // pages is not displayed. Each form has a unique CLSID to allow it to be
  94. // selected by invoking the query dialog.
  95. //
  96. CQFF_NOGLOBALPAGES = $0000001; // = 1 => doesn't have global pages added
  97. {$EXTERNALSYM CQFF_NOGLOBALPAGES}
  98. CQFF_ISOPTIONAL = $0000002; // = 1 => form is hidden, unless optional forms requested
  99. {$EXTERNALSYM CQFF_ISOPTIONAL}
  100. type
  101. CQFORM = record
  102. cbStruct: DWORD;
  103. dwFlags: DWORD;
  104. clsid: CLSID;
  105. hIcon: HICON;
  106. pszTitle: LPCWSTR;
  107. end;
  108. {$EXTERNALSYM CQFORM}
  109. LPCQFORM = ^CQFORM;
  110. {$EXTERNALSYM LPCQFORM}
  111. TCQForm = CQFORM;
  112. PCQForm = LPCQFORM;
  113. LPCQADDFORMSPROC = function(lParam: LPARAM; pForm: LPCQFORM): HRESULT; stdcall;
  114. {$EXTERNALSYM LPCQADDFORMSPROC}
  115. //
  116. // Query Form Pages
  117. // ================
  118. // When a query form has been registered the caller can then add pages to it,
  119. // any form can have pages appended.
  120. //
  121. _cqpage = record
  122. cbStruct: DWORD;
  123. dwFlags: DWORD;
  124. pPageProc: Pointer{LPCQPAGEPROC};
  125. hInstance: HINST;
  126. idPageName: Integer;
  127. idPageTemplate: Integer;
  128. pDlgProc: DLGPROC;
  129. lParam: LPARAM;
  130. end;
  131. {$EXTERNALSYM _cqpage}
  132. CQPAGE = _cqpage;
  133. {$EXTERNALSYM CQPAGE}
  134. LPCQPAGE = ^CQPAGE;
  135. {$EXTERNALSYM LPCQPAGE}
  136. TCQPage = CQPAGE;
  137. PCQPage = LPCQPAGE;
  138. LPCQADDPAGESPROC = function(lParam: LPARAM; const clsidForm: CLSID; pPage: LPCQPAGE): HRESULT; stdcall;
  139. {$EXTERNALSYM LPCQADDPAGESPROC}
  140. LPCQPAGEPROC = function(pPage: LPCQPAGE; hwnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): HRESULT; stdcall;
  141. {$EXTERNALSYM LPCQPAGEPROC}
  142. //
  143. // IQueryForm interfaces
  144. //
  145. IQueryForm = interface(IUnknown)
  146. ['{8cfcee30-39bd-11d0-b8d1-00a024ab2dbb}']
  147. function Initialize(hkForm: HKEY): HRESULT; stdcall;
  148. function AddForms(pAddFormsProc: LPCQADDPAGESPROC; lParam: LPARAM): HRESULT; stdcall;
  149. function AddPages(pAddPagesProc: LPCQADDPAGESPROC; lParam: LPARAM): HRESULT; stdcall;
  150. end;
  151. {$EXTERNALSYM IQueryForm}
  152. //
  153. // Messages for pages
  154. //
  155. const
  156. CQPM_INITIALIZE = $00000001;
  157. {$EXTERNALSYM CQPM_INITIALIZE}
  158. CQPM_RELEASE = $00000002;
  159. {$EXTERNALSYM CQPM_RELEASE}
  160. CQPM_ENABLE = $00000003; // wParam = TRUE/FALSE (enable, disable), lParam = 0
  161. {$EXTERNALSYM CQPM_ENABLE}
  162. CQPM_GETPARAMETERS = $00000005; // wParam = 0, lParam = -> receives the LocalAlloc
  163. {$EXTERNALSYM CQPM_GETPARAMETERS}
  164. CQPM_CLEARFORM = $00000006; // wParam, lParam = 0
  165. {$EXTERNALSYM CQPM_CLEARFORM}
  166. CQPM_PERSIST = $00000007; // wParam = fRead, lParam -> IPersistQuery
  167. {$EXTERNALSYM CQPM_PERSIST}
  168. CQPM_HELP = $00000008; // wParam = 0, lParam -> LPHELPINFO
  169. {$EXTERNALSYM CQPM_HELP}
  170. CQPM_SETDEFAULTPARAMETERS = $00000009; // wParam = 0, lParam -> OPENQUERYWINDOW
  171. {$EXTERNALSYM CQPM_SETDEFAULTPARAMETERS}
  172. CQPM_HANDLERSPECIFIC = $10000000;
  173. {$EXTERNALSYM CQPM_HANDLERSPECIFIC}
  174. //-----------------------------------------------------------------------------
  175. // IPersistQuery
  176. //-----------------------------------------------------------------------------
  177. // IPersistQuery interface
  178. type
  179. IPersistQuery = interface(IPersist)
  180. ['{1a3114b8-a62e-11d0-a6c5-00a0c906af45}']
  181. function WriteString(pSection, pValueName, pValue: LPCWSTR): HRESULT; stdcall;
  182. function ReadString(pSection, pValueName, pBuffer: LPWSTR; cchBuffer: Integer): HRESULT; stdcall;
  183. function WriteInt(pSection, pValueName: LPCWSTR; value: Integer): HRESULT; stdcall;
  184. function ReadInt(pSection, pValueName: LPCWSTR; pValue: LPINT): HRESULT; stdcall;
  185. function WriteStruct(pSection, pValueName: LPCWSTR; pStruct: LPVOID; cbStruct: DWORD): HRESULT; stdcall;
  186. function ReadStruct(pSection, pValueName: LPCWSTR; pStruct: LPVOID; cbStruct: DWORD): HRESULT; stdcall;
  187. function Clear: HRESULT; stdcall;
  188. end;
  189. {$EXTERNALSYM IPersistQuery}
  190. //-----------------------------------------------------------------------------
  191. // ICommonQuery
  192. //-----------------------------------------------------------------------------
  193. const
  194. OQWF_OKCANCEL = $00000001; // = 1 => Provide OK/Cancel buttons
  195. {$EXTERNALSYM OQWF_OKCANCEL}
  196. OQWF_DEFAULTFORM = $00000002; // = 1 => clsidDefaultQueryForm is valid
  197. {$EXTERNALSYM OQWF_DEFAULTFORM}
  198. OQWF_SINGLESELECT = $00000004; // = 1 => view to have single selection (depends on viewer)
  199. {$EXTERNALSYM OQWF_SINGLESELECT}
  200. OQWF_LOADQUERY = $00000008; // = 1 => use the IPersistQuery to load the given query
  201. {$EXTERNALSYM OQWF_LOADQUERY}
  202. OQWF_REMOVESCOPES = $00000010; // = 1 => remove scope picker from dialog
  203. {$EXTERNALSYM OQWF_REMOVESCOPES}
  204. OQWF_REMOVEFORMS = $00000020; // = 1 => remove form picker from dialog
  205. {$EXTERNALSYM OQWF_REMOVEFORMS}
  206. OQWF_ISSUEONOPEN = $00000040; // = 1 => issue query on opening the dialog
  207. {$EXTERNALSYM OQWF_ISSUEONOPEN}
  208. OQWF_SHOWOPTIONAL = $00000080; // = 1 => list optional forms by default
  209. {$EXTERNALSYM OQWF_SHOWOPTIONAL}
  210. OQWF_SAVEQUERYONOK = $00000200; // = 1 => use the IPersistQuery to write the query on close
  211. {$EXTERNALSYM OQWF_SAVEQUERYONOK}
  212. OQWF_HIDEMENUS = $00000400; // = 1 => no menu bar displayed
  213. {$EXTERNALSYM OQWF_HIDEMENUS}
  214. OQWF_HIDESEARCHUI = $00000800; // = 1 => dialog is filter, therefore start, stop, new search etc
  215. {$EXTERNALSYM OQWF_HIDESEARCHUI}
  216. OQWF_PARAMISPROPERTYBAG = DWORD($80000000); // = 1 => the form parameters ptr is an IPropertyBag (ppbFormParameters)
  217. {$EXTERNALSYM OQWF_PARAMISPROPERTYBAG}
  218. type
  219. OPENQUERYWINDOW = record
  220. cbStruct: DWORD; // structure size
  221. dwFlags: DWORD; // flags (OQFW_*)
  222. clsidHandler: CLSID; // clsid of handler we are using
  223. pHandlerParameters: LPVOID; // handler specific structure for initialization
  224. clsidDefaultForm: CLSID; // default form to be selected (if OQF_DEFAULTFORM == 1 )
  225. pPersistQuery: IPersistQuery; // IPersistQuery used for loading queries
  226. //mvb IPropertyBag is an interface which needs finalization and therefor can't be present in a variant record
  227. //case Integer of
  228. // 0: (pFormParameters: Pointer);
  229. // 1: (ppbFormParameters: IPropertyBag);
  230. case Integer of
  231. 0: (pFormParameters: Pointer);
  232. 1: (ppbFormParameters: Pointer);
  233. end;
  234. {$EXTERNALSYM OPENQUERYWINDOW}
  235. LPOPENQUERYWINDOW = ^OPENQUERYWINDOW;
  236. {$EXTERNALSYM LPOPENQUERYWINDOW}
  237. TOpenQueryWindow = OPENQUERYWINDOW;
  238. POpenQueryWindow = LPOPENQUERYWINDOW;
  239. // ICommonQuery
  240. ICommonQuery = interface(IUnknown)
  241. ['{ab50dec0-6f1d-11d0-a1c4-00aa00c16e65}']
  242. function OpenQueryWindow(hwndParent: HWND; pQueryWnd: LPOPENQUERYWINDOW; out ppDataObject: IDataObject): HRESULT; stdcall;
  243. end;
  244. {$EXTERNALSYM ICommonQuery}
  245. implementation
  246. end.