Source code of Windows XP (NT5)
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.

209 lines
6.1 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. /*-----------------------------------------------------------------------------
  4. / Local functions / data
  5. /----------------------------------------------------------------------------*/
  6. #define MAX_QUERY_STRING_LENGTH 2048
  7. static TCHAR szQueryString[] = TEXT("QueryString");
  8. static COLUMNINFO columnsRawLDAP[] =
  9. {
  10. 0, 20, IDS_CN, 0, c_szName,
  11. 0, 20, IDS_OBJECTCLASS, DSCOLUMNPROP_OBJECTCLASS, NULL,
  12. 0, 60, IDS_DESCRIPTION, 0, c_szDescription,
  13. };
  14. //
  15. // Help ID mappings
  16. //
  17. static DWORD const aFormHelpIDs[] =
  18. {
  19. IDC_LDAP, IDH_LDAP_QUERY,
  20. 0, 0
  21. };
  22. /*-----------------------------------------------------------------------------
  23. / PageProc_RawLDAP
  24. / ----------------
  25. / PageProc for handling the messages for this object.
  26. /
  27. / In:
  28. / pPage -> instance data for this form
  29. / hwnd = window handle for the form dialog
  30. / uMsg, wParam, lParam = message parameters
  31. /
  32. / Out:
  33. / HRESULT (E_NOTIMPL) if not handled
  34. /----------------------------------------------------------------------------*/
  35. HRESULT CALLBACK PageProc_RawLDAP(LPCQPAGE pPage, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  36. {
  37. HRESULT hr = S_OK;
  38. TCHAR szBuffer[MAX_QUERY_STRING_LENGTH];
  39. USES_CONVERSION;
  40. TraceEnter(TRACE_FORMS, "PageProc_RawLDAP");
  41. switch ( uMsg )
  42. {
  43. case CQPM_INITIALIZE:
  44. case CQPM_RELEASE:
  45. break;
  46. case CQPM_ENABLE:
  47. EnableWindow(GetDlgItem(hwnd, IDC_LDAP), (BOOL)wParam);
  48. break;
  49. case CQPM_GETPARAMETERS:
  50. {
  51. LPDSQUERYPARAMS* ppDsQueryParams = (LPDSQUERYPARAMS*)lParam;
  52. // If we already have some query params then lets add to the query string,
  53. // if no then we must construct a new query.
  54. if ( *ppDsQueryParams )
  55. {
  56. if ( GetDlgItemText(hwnd, IDC_LDAP, szBuffer, ARRAYSIZE(szBuffer)) )
  57. {
  58. hr = QueryParamsAddQueryString(ppDsQueryParams, T2W(szBuffer));
  59. FailGracefully(hr, "Failed to append query to existing query string");
  60. }
  61. }
  62. else
  63. {
  64. if ( GetDlgItemText(hwnd, IDC_LDAP, szBuffer, ARRAYSIZE(szBuffer)) )
  65. {
  66. hr = QueryParamsAlloc(ppDsQueryParams, T2W(szBuffer), GLOBAL_HINSTANCE, ARRAYSIZE(columnsRawLDAP), columnsRawLDAP);
  67. FailGracefully(hr, "Failed to build DS argument block");
  68. }
  69. }
  70. break;
  71. }
  72. case CQPM_CLEARFORM:
  73. SetDlgItemText(hwnd, IDC_LDAP, TEXT(""));
  74. break;
  75. case CQPM_PERSIST:
  76. {
  77. BOOL fRead = (BOOL)wParam;
  78. IPersistQuery* pPersistQuery = (IPersistQuery*)lParam;
  79. // Read/Write the current query string from the file, if reading and we cannot
  80. // get the string then no real problem, just ignore it.
  81. if ( fRead )
  82. {
  83. if ( SUCCEEDED(pPersistQuery->ReadString(c_szMsPropertyWell, szQueryString, szBuffer, ARRAYSIZE(szBuffer))) )
  84. {
  85. Trace(TEXT("Query string from file is: %s"), szBuffer);
  86. SetDlgItemText(hwnd, IDC_LDAP, szBuffer);
  87. }
  88. }
  89. else
  90. {
  91. if ( GetDlgItemText(hwnd, IDC_LDAP, szBuffer, ARRAYSIZE(szBuffer)) )
  92. {
  93. Trace(TEXT("Writing query string to file: %s"), szBuffer);
  94. hr = pPersistQuery->WriteString(c_szMsPropertyWell, szQueryString, szBuffer);
  95. FailGracefully(hr, "Failed when writing out raw query string");
  96. }
  97. }
  98. break;
  99. }
  100. case CQPM_HELP:
  101. {
  102. LPHELPINFO pHelpInfo = (LPHELPINFO)lParam;
  103. WinHelp((HWND)pHelpInfo->hItemHandle,
  104. DSQUERY_HELPFILE,
  105. HELP_WM_HELP,
  106. (DWORD_PTR)aFormHelpIDs);
  107. break;
  108. }
  109. case DSQPM_GETCLASSLIST:
  110. // we don't generate any class list
  111. break;
  112. case DSQPM_HELPTOPICS:
  113. {
  114. HWND hwndFrame = (HWND)lParam;
  115. HtmlHelp(hwndFrame, TEXT("omc.chm"), HH_HELP_FINDER, 0);
  116. break;
  117. }
  118. default:
  119. hr = E_NOTIMPL;
  120. break;
  121. }
  122. exit_gracefully:
  123. TraceLeaveResult(hr);
  124. }
  125. /*-----------------------------------------------------------------------------
  126. / DlgProc_RawLDAP
  127. / ---------------
  128. / Handle operations specific to the RAW LDAP query form.
  129. /
  130. / In:
  131. / hwnd, uMsg, wParam, lParam = standard parameters
  132. /
  133. / Out:
  134. / INT_PTR
  135. /----------------------------------------------------------------------------*/
  136. INT_PTR CALLBACK DlgProc_RawLDAP(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  137. {
  138. INT_PTR fResult = 0;
  139. LPCQPAGE pQueryPage;
  140. if ( uMsg == WM_INITDIALOG )
  141. {
  142. pQueryPage = (LPCQPAGE)lParam;
  143. SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)pQueryPage);
  144. Edit_LimitText(GetDlgItem(hwnd, IDC_LDAP), MAX_QUERY_STRING_LENGTH);
  145. }
  146. else
  147. {
  148. pQueryPage = (LPCQPAGE)GetWindowLongPtr(hwnd, DWLP_USER);
  149. switch ( uMsg )
  150. {
  151. case WM_SIZE:
  152. {
  153. HWND hwndLDAP = GetDlgItem(hwnd, IDC_LDAP);
  154. RECT rect;
  155. // size the edit control to cover the entire form, retain the original
  156. // height, but apply the left border to the edit control
  157. GetRealWindowInfo(hwndLDAP, &rect, NULL);
  158. SetWindowPos(hwndLDAP, NULL,
  159. 0, 0,
  160. LOWORD(lParam)-(rect.left*2),
  161. HIWORD(lParam)-rect.top-rect.left,
  162. SWP_NOMOVE|SWP_NOZORDER);
  163. break;
  164. }
  165. case WM_CONTEXTMENU:
  166. {
  167. WinHelp((HWND)wParam, DSQUERY_HELPFILE, HELP_CONTEXTMENU, (DWORD_PTR)aFormHelpIDs);
  168. fResult = TRUE;
  169. break;
  170. }
  171. }
  172. }
  173. return fResult;
  174. }