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.

265 lines
6.8 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. dlgproc
  5. Abstract:
  6. The dialog procedures for the different tabs in the main dialog.
  7. Author:
  8. Steve Firebaugh (stevefir) 31-Dec-1995
  9. Revision History:
  10. --*/
  11. #include <windows.h>
  12. #include <commdlg.h>
  13. #include <winsock2.h>
  14. #include <nspapi.h>
  15. #include "globals.h"
  16. //
  17. // Keep a dirty bit for the ordering of the service providers. Set it if
  18. // the order changes, clear it if we push apply.
  19. //
  20. int gDirty = FALSE;
  21. INT_PTR CALLBACK SortDlgProc(HWND hwnd,
  22. UINT message,
  23. WPARAM wParam,
  24. LPARAM ppsp)
  25. /*++
  26. This is the main dialog proc for the window that lists all of the service
  27. providers and lets the user push them up and down.
  28. Uses GLOBAL: gNumRows
  29. --*/
  30. {
  31. int iSelection;
  32. switch (message) {
  33. case WM_INITDIALOG:
  34. CatReadRegistry (hwnd);
  35. SendMessage (GetDlgItem (hwnd, DID_LISTCTL), LB_SETCURSEL, 0, 0);
  36. return FALSE;
  37. break;
  38. case WM_NOTIFY: {
  39. NMHDR * pnmhdr;
  40. pnmhdr = (NMHDR *) ppsp;
  41. if (pnmhdr->code == PSN_APPLY) {
  42. if (gDirty)
  43. if ( IDYES == MessageBox (hwnd,
  44. TEXT("This operation may change the behavior of the networking components on your system.\nDo you wish to continue?"),
  45. TEXT("Warning:"),
  46. MB_ICONWARNING | MB_YESNO)) {
  47. CatDoWriteEntries (hwnd);
  48. gDirty = FALSE;
  49. }
  50. }
  51. } break;
  52. case WM_COMMAND:
  53. switch (LOWORD (wParam)) {
  54. //
  55. // On the up & down buttons, screen out the no-ops (up on top row,
  56. // or down on bottom), reorder the catalog entries, and set the
  57. // dirty bit.
  58. //
  59. case DID_UP: {
  60. iSelection = (int)SendMessage (HWNDLISTCTL, LB_GETCURSEL, 0, 0);
  61. if (iSelection == 0) return FALSE;
  62. CatDoUpDown (hwnd, LOWORD (wParam));
  63. SendMessage (GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
  64. gDirty = TRUE;
  65. } break;
  66. case DID_DOWN: {
  67. iSelection = (int)SendMessage (HWNDLISTCTL, LB_GETCURSEL, 0, 0);
  68. if (iSelection == (gNumRows-1)) return FALSE;
  69. CatDoUpDown (hwnd, LOWORD (wParam));
  70. SendMessage (GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
  71. gDirty = TRUE;
  72. } break;
  73. //
  74. // If the listbox is double clicked, re-send the message as if it
  75. // was a more-info button press. If it is a selection change, then
  76. // set the state of the buttons appropriately.
  77. //
  78. case DID_LISTCTL:
  79. if (HIWORD (wParam) == LBN_DBLCLK)
  80. SendMessage (hwnd, WM_COMMAND, DID_MORE, 0);
  81. else if (HIWORD (wParam) == LBN_SELCHANGE) {
  82. // here we can enable/disable buttons...
  83. // not implemented yet
  84. }
  85. break;
  86. //
  87. // If they request more information, figure out which item is selected,
  88. // then map that to an index value from the initial ordering. Finally
  89. // popup a dialog that will show the information from the catalog at
  90. // that index.
  91. //
  92. case DID_MORE: {
  93. int iIndex;
  94. int notUsed;
  95. TCHAR szBuffer[MAX_STR];
  96. iSelection = (int)SendMessage (HWNDLISTCTL, LB_GETCURSEL, 0, 0);
  97. if (iSelection != LB_ERR) {
  98. //
  99. // Dig the chosen string out of the listbox, find the original
  100. // index hidden in it, and popup the more information dialog
  101. // for the appropriate entry.
  102. //
  103. SendMessage (HWNDLISTCTL, LB_GETTEXT, iSelection, (LPARAM) szBuffer);
  104. ASSERT (CatGetIndex (szBuffer, &iIndex, &notUsed),
  105. TEXT("SortDlgProc, CatGetIndex failed."));
  106. DialogBoxParam (ghInst,
  107. TEXT("MoreInfoDlg"),
  108. hwnd,
  109. MoreInfoDlgProc,
  110. iIndex);
  111. }
  112. } break;
  113. }
  114. break; // WM_COMMAND
  115. } // end switch
  116. return FALSE;
  117. }
  118. INT_PTR CALLBACK MoreInfoDlgProc(HWND hwnd,
  119. UINT message,
  120. WPARAM wParam,
  121. LPARAM lParam)
  122. /*++
  123. This is the window proc for the simple "more info" dialog. All that we
  124. do here is fill our listbox with interesting info on wm_initdialog, and
  125. then wait to be dismissed.
  126. --*/
  127. {
  128. switch (message) {
  129. case WM_INITDIALOG:
  130. CatDoMoreInfo (hwnd, (int) lParam);
  131. break;
  132. case WM_COMMAND:
  133. if (wParam == IDCANCEL)
  134. EndDialog (hwnd, FALSE);
  135. if (wParam == IDOK)
  136. EndDialog (hwnd, TRUE);
  137. break;
  138. case WM_SYSCOMMAND:
  139. if (wParam == SC_CLOSE)
  140. EndDialog (hwnd, TRUE);
  141. break;
  142. } // end switch
  143. return FALSE;
  144. }
  145. INT_PTR CALLBACK RNRDlgProc(HWND hwnd,
  146. UINT message,
  147. WPARAM wParam,
  148. LPARAM lParam)
  149. /*++
  150. For this version, simply list the installed providers.
  151. --*/
  152. {
  153. switch (message) {
  154. case WM_INITDIALOG: {
  155. //
  156. // at init time, query all of the installed name space providers
  157. // and put their identifier in the listbox. Notice. that this
  158. // function assumes WSAStartup has already been called.
  159. //
  160. #define MAX_NAMESPACE 100 // hack, arbitrary value, should be dynamic
  161. WSANAMESPACE_INFO arnspBuf[MAX_NAMESPACE];
  162. DWORD dwBufLen;
  163. int i, r;
  164. int iTab = 50;
  165. SendMessage (HWNDLISTCTL, LB_SETTABSTOPS, 1, (LPARAM) &iTab);
  166. //
  167. // Call the WinSock2 name space enumeration function with enough
  168. // free space such that we expect to get all of the information.
  169. //
  170. dwBufLen = sizeof (arnspBuf);
  171. r = WSAEnumNameSpaceProviders(&dwBufLen, arnspBuf);
  172. if ( r == SOCKET_ERROR) {
  173. DBGOUT((TEXT("WSAEnumNameSpaceProviders failed w/ %d\n"), WSAGetLastError()));
  174. return (INT_PTR)-1;
  175. }
  176. //
  177. // WSAEnumNameSpaceProviders succeeded so write results to listbox
  178. //
  179. for (i = 0; i< r; i++) {
  180. ADDSTRING(arnspBuf[i].lpszIdentifier);
  181. }
  182. } break;
  183. } // end switch
  184. return FALSE;
  185. }