Leaked source code of windows server 2003
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.

205 lines
5.3 KiB

  1. /**************************** Module Header ********************************\
  2. * Module Name: combodir.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Directory Combo Box Routines
  7. *
  8. * History:
  9. * ??-???-???? ?????? Ported from Win 3.0 sources
  10. * 01-Feb-1991 mikeke Added Revalidation code
  11. \***************************************************************************/
  12. #define CTLMGR
  13. #define LSTRING
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. /***************************************************************************\
  17. * xxxCBDir
  18. *
  19. * Supports the CB_DIR message which adds a list of files from the
  20. * current directory to the combo box.
  21. *
  22. * History:
  23. \***************************************************************************/
  24. int xxxCBDir(
  25. PCBOX pcbox,
  26. UINT attrib,
  27. LPWSTR pFileName)
  28. {
  29. PLBIV plb;
  30. int errorValue;
  31. TL tlpwnd;
  32. CheckLock(pcbox->spwnd);
  33. UserAssert(pcbox->spwndList);
  34. plb = ((PLBWND)pcbox->spwndList)->pLBIV;
  35. ThreadLock(plb->spwnd, &tlpwnd);
  36. errorValue = xxxLbDir(plb, attrib, pFileName);
  37. ThreadUnlock(&tlpwnd);
  38. switch (errorValue) {
  39. case LB_ERR:
  40. return CB_ERR;
  41. break;
  42. case LB_ERRSPACE:
  43. return CB_ERRSPACE;
  44. break;
  45. default:
  46. return errorValue;
  47. break;
  48. }
  49. }
  50. /***************************************************************************\
  51. * DlgDirSelectComboBoxEx
  52. *
  53. * Retrieves the current selection from the listbox of a combobox.
  54. * It assumes that the combo box was filled by xxxDlgDirListComboBox()
  55. * and that the selection is a drive letter, a file, or a directory name.
  56. *
  57. * History:
  58. * 12-05-90 IanJa converted to internal version
  59. \***************************************************************************/
  60. FUNCLOG4(LOG_GENERAL, int, DUMMYCALLINGTYPE, DlgDirSelectComboBoxExA, HWND, hwndDlg, LPSTR, pszOut, int, cchOut, int, idComboBox)
  61. int DlgDirSelectComboBoxExA(
  62. HWND hwndDlg,
  63. LPSTR pszOut,
  64. int cchOut,
  65. int idComboBox)
  66. {
  67. LPWSTR lpwsz;
  68. BOOL fRet;
  69. lpwsz = (LPWSTR)UserLocalAlloc(HEAP_ZERO_MEMORY, cchOut * sizeof(WCHAR));
  70. if (!lpwsz) {
  71. return FALSE;
  72. }
  73. fRet = DlgDirSelectComboBoxExW(hwndDlg, lpwsz, cchOut, idComboBox);
  74. WCSToMB(lpwsz, -1, &pszOut, cchOut, FALSE);
  75. UserLocalFree(lpwsz);
  76. return fRet;
  77. }
  78. FUNCLOG4(LOG_GENERAL, int, DUMMYCALLINGTYPE, DlgDirSelectComboBoxExW, HWND, hwndDlg, LPWSTR, pwszOut, int, cchOut, int, idComboBox)
  79. int DlgDirSelectComboBoxExW(
  80. HWND hwndDlg,
  81. LPWSTR pwszOut,
  82. int cchOut,
  83. int idComboBox)
  84. {
  85. PWND pwndDlg;
  86. PWND pwndComboBox;
  87. PCBOX pcbox;
  88. pwndDlg = ValidateHwnd(hwndDlg);
  89. if (pwndDlg == NULL)
  90. return FALSE;
  91. pwndComboBox = _GetDlgItem(pwndDlg, idComboBox);
  92. if (pwndComboBox == NULL) {
  93. RIPERR0(ERROR_CONTROL_ID_NOT_FOUND, RIP_VERBOSE, "");
  94. return 0;
  95. }
  96. pcbox = ((PCOMBOWND)pwndComboBox)->pcbox;
  97. if (pcbox == NULL) {
  98. RIPERR0(ERROR_WINDOW_NOT_COMBOBOX, RIP_VERBOSE, "");
  99. return 0;
  100. }
  101. return DlgDirSelectHelper(pwszOut, cchOut, HWq(pcbox->spwndList));
  102. }
  103. /***************************************************************************\
  104. * xxxDlgDirListComboBox
  105. *
  106. * History:
  107. * 12-05-90 IanJa converted to internal version
  108. \***************************************************************************/
  109. FUNCLOG5(LOG_GENERAL, int, DUMMYCALLINGTYPE, DlgDirListComboBoxA, HWND, hwndDlg, LPSTR, lpszPathSpecClient, int, idComboBox, int, idStaticPath, UINT, attrib)
  110. int DlgDirListComboBoxA(
  111. HWND hwndDlg,
  112. LPSTR lpszPathSpecClient,
  113. int idComboBox,
  114. int idStaticPath,
  115. UINT attrib)
  116. {
  117. LPWSTR lpszPathSpec;
  118. TL tlpwndDlg;
  119. PWND pwndDlg;
  120. BOOL fRet;
  121. pwndDlg = ValidateHwnd(hwndDlg);
  122. if (pwndDlg == NULL)
  123. return FALSE;
  124. lpszPathSpec = NULL;
  125. if (lpszPathSpecClient) {
  126. if (!MBToWCS(lpszPathSpecClient, -1, &lpszPathSpec, -1, TRUE))
  127. return FALSE;
  128. }
  129. ThreadLock(pwndDlg, &tlpwndDlg);
  130. fRet = xxxDlgDirListHelper(pwndDlg, lpszPathSpec, lpszPathSpecClient,
  131. idComboBox, idStaticPath, attrib, FALSE);
  132. ThreadUnlock(&tlpwndDlg);
  133. if (lpszPathSpec) {
  134. if (fRet) {
  135. /*
  136. * Non-zero retval means some text to copy out. Copy out up to
  137. * the nul terminator (buffer will be big enough).
  138. */
  139. WCSToMB(lpszPathSpec, -1, &lpszPathSpecClient, MAXLONG, FALSE);
  140. }
  141. UserLocalFree(lpszPathSpec);
  142. }
  143. return fRet;
  144. }
  145. FUNCLOG5(LOG_GENERAL, int, DUMMYCALLINGTYPE, DlgDirListComboBoxW, HWND, hwndDlg, LPWSTR, lpszPathSpecClient, int, idComboBox, int, idStaticPath, UINT, attrib)
  146. int DlgDirListComboBoxW(
  147. HWND hwndDlg,
  148. LPWSTR lpszPathSpecClient,
  149. int idComboBox,
  150. int idStaticPath,
  151. UINT attrib)
  152. {
  153. LPWSTR lpszPathSpec;
  154. PWND pwndDlg;
  155. TL tlpwndDlg;
  156. BOOL fRet;
  157. pwndDlg = ValidateHwnd(hwndDlg);
  158. if (pwndDlg == NULL)
  159. return FALSE;
  160. lpszPathSpec = lpszPathSpecClient;
  161. ThreadLock(pwndDlg, &tlpwndDlg);
  162. fRet = xxxDlgDirListHelper(pwndDlg, lpszPathSpec, (LPBYTE)lpszPathSpecClient,
  163. idComboBox, idStaticPath, attrib, FALSE);
  164. ThreadUnlock(&tlpwndDlg);
  165. return fRet;
  166. }