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.

402 lines
12 KiB

  1. /*-------------------------------------------------------------------
  2. | driprop.c - Driver level Properties Sheet.
  3. |--------------------------------------------------------------------*/
  4. #include "precomp.h"
  5. static void set_field(HWND hDlg, WORD id);
  6. static void get_field(HWND hDlg, WORD id);
  7. static void context_menu(void);
  8. static Driver_Config *adv_org_wi = NULL; // original info, use to detect changes
  9. /*----------------------------------------------------------
  10. AdvDriverSheet - Dlg window procedure for add on Advanced sheet.
  11. |-------------------------------------------------------------*/
  12. BOOL WINAPI AdvDriverSheet(
  13. IN HWND hDlg,
  14. IN UINT uMessage,
  15. IN WPARAM wParam,
  16. IN LPARAM lParam)
  17. {
  18. OUR_INFO *OurProps = (OUR_INFO *)GetWindowLong(hDlg, DWL_USER);
  19. switch(uMessage)
  20. {
  21. case WM_INITDIALOG :
  22. OurProps = (OUR_INFO *)((LPPROPSHEETPAGE)lParam)->lParam;
  23. SetWindowLong(hDlg, DWL_USER, (LONG)OurProps);
  24. #ifdef NT50
  25. glob_hwnd = hDlg;
  26. #endif
  27. if (adv_org_wi == NULL)
  28. adv_org_wi = (Driver_Config *) calloc(1,sizeof(Driver_Config));
  29. memcpy(adv_org_wi, wi, sizeof(*wi)); // save copy of original
  30. set_field(hDlg, IDC_VERBOSE);
  31. set_field(hDlg, IDC_GLOBAL485);
  32. set_field(hDlg, IDC_CBOX_SCAN_RATE);
  33. #ifdef NT50
  34. #if ALLOW_NO_PNP_PORTS
  35. set_field(hDlg, IDC_PNP_PORTS);
  36. #else
  37. // hide this option for now.
  38. ShowWindow(GetDlgItem(hDlg, IDC_PNP_PORTS), SW_HIDE);
  39. #endif
  40. #endif
  41. return TRUE; // No need for us to set the focus.
  42. case PSM_QUERYSIBLINGS :
  43. {
  44. switch (HIWORD(wParam))
  45. {
  46. case QUERYSIB_GET_OUR_PROPS :
  47. // grab updated info from controls(don't have any)
  48. get_field(hDlg, IDC_VERBOSE);
  49. get_field(hDlg, IDC_GLOBAL485);
  50. get_field(hDlg, IDC_CBOX_SCAN_RATE);
  51. #ifdef NT50
  52. #if ALLOW_NO_PNP_PORTS
  53. get_field(hDlg, IDC_PNP_PORTS);
  54. #endif
  55. #endif
  56. SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
  57. return TRUE;
  58. break;
  59. default :
  60. return FALSE;
  61. }
  62. }
  63. case WM_COMMAND:
  64. switch (LOWORD(wParam))
  65. {
  66. case IDB_DEF:
  67. wi->VerboseLog = 0;
  68. wi->ScanRate = 0;
  69. wi->GlobalRS485 = 0;
  70. #ifdef NT50
  71. wi->NoPnpPorts = 0;
  72. #endif
  73. set_field(hDlg, IDC_VERBOSE);
  74. set_field(hDlg, IDC_GLOBAL485);
  75. set_field(hDlg, IDC_CBOX_SCAN_RATE);
  76. #ifdef NT50
  77. #if ALLOW_NO_PNP_PORTS
  78. set_field(hDlg, IDC_PNP_PORTS);
  79. #endif
  80. #endif
  81. break;
  82. case IDM_ADVANCED_MODEM_INF:
  83. //mess(&wi->ip, "1.) modem inf");
  84. update_modem_inf(1);
  85. break;
  86. case IDM_PM: // Try out the add pm group dde stuff
  87. setup_make_progman_group(0);
  88. break;
  89. }
  90. return FALSE;
  91. case WM_PAINT:
  92. //
  93. return FALSE;
  94. case WM_CONTEXTMENU: // right-click
  95. context_menu();
  96. break;
  97. case WM_HELP: // question mark thing
  98. our_context_help(lParam);
  99. return FALSE;
  100. case WM_NOTIFY :
  101. switch (((NMHDR *)lParam)->code)
  102. {
  103. case PSN_KILLACTIVE :
  104. // we're losing focus to another page...
  105. // make sure we update the Global485 variable here.
  106. get_field(hDlg, IDC_GLOBAL485);
  107. SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
  108. return FALSE; // allow focus change
  109. break;
  110. case PSN_HELP :
  111. our_help(&wi->ip, WIN_NT);
  112. break;
  113. case PSN_QUERYCANCEL :
  114. // request that the other sheets gather up any changes.
  115. PropSheet_QuerySiblings(GetParent(hDlg),
  116. (WPARAM) (QUERYSIB_GET_OUR_PROPS << 16),
  117. 0);
  118. if (allow_exit(1)) // request cancel
  119. {
  120. // the DWL_MSGRESULT field must be *FALSE* to tell QueryCancel
  121. // that an exit is acceptable. The function result must be
  122. // *TRUE* to acknowledge that we handled the message.
  123. SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); // allow cancel
  124. return TRUE;
  125. }
  126. else
  127. {
  128. // the DWL_MSGRESULT field must be *TRUE* to tell QueryCancel
  129. // that we don't want an exit. The function result must be
  130. // *TRUE* to acknowledge that we handled the message.
  131. SetWindowLong(hDlg, DWL_MSGRESULT, TRUE); // don't allow cancel
  132. return TRUE;
  133. }
  134. break;
  135. case PSN_APPLY :
  136. // request that the other sheets gather up any changes.
  137. PropSheet_QuerySiblings(GetParent(hDlg),
  138. (WPARAM) (QUERYSIB_GET_OUR_PROPS << 16),
  139. 0);
  140. if (!wi->DriverExitDone)
  141. {
  142. // now see if anything changed that needs saving
  143. if (allow_exit(0)) // request ok to save and exit
  144. {
  145. wi->DriverExitDone = 1; // prevents other pages doing this
  146. // do the install/save of config params if not canceling..
  147. #ifdef NT50
  148. our_nt50_exit(); // ok, quit
  149. #else
  150. our_exit(); // nt40 exit
  151. #endif
  152. SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
  153. //wi->SaveOnExit = 1;
  154. }
  155. else
  156. {
  157. SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  158. }
  159. }
  160. return TRUE;
  161. default :
  162. return FALSE;
  163. } // switch ->code
  164. break; // case wmnotify
  165. default :
  166. // return FALSE;
  167. break;
  168. } // switch(uMessage)
  169. return FALSE;
  170. }
  171. /*----------------------------------------------------------------------------
  172. | scr_to_cur - Our window screen pos to windows absolute cursor position.
  173. |-----------------------------------------------------------------------------*/
  174. static void scr_to_cur(HWND hwnd, POINT *pt)
  175. {
  176. RECT rec;
  177. int cx, cy;
  178. GetWindowRect(hwnd, &rec);
  179. cx = GetSystemMetrics(SM_CXFRAME);
  180. cy = GetSystemMetrics(SM_CYCAPTION) + (cx-1);
  181. pt->x += (rec.left + cx);
  182. pt->y += ( rec.top + cy);
  183. }
  184. /*----------------------------------------------------------
  185. context_menu -
  186. |------------------------------------------------------------*/
  187. static void context_menu(void)
  188. {
  189. HMENU hpop_menu;
  190. POINT scr_pt;
  191. int stat;
  192. scr_pt.x = 200;
  193. scr_pt.y = 200;
  194. hpop_menu = CreatePopupMenu();
  195. if (hpop_menu == NULL)
  196. {
  197. mess(&wi->ip, "Error from CreatePopMenu");
  198. return;
  199. }
  200. #ifndef NT50
  201. AppendMenu(hpop_menu, 0, IDM_ADVANCED_MODEM_INF, "Update RAS modem.inf");
  202. #endif
  203. AppendMenu(hpop_menu, 0, 0x11, "Run Wcom Test Terminal");
  204. AppendMenu(hpop_menu, 0, 0x12, "Run Portman Program");
  205. AppendMenu(hpop_menu, 0, 0x10, "Run Peer tracer");
  206. if (setup_utils_exist())
  207. {
  208. AppendMenu(hpop_menu, 0, IDM_PM, "Add Program Manager Menu Selections");
  209. }
  210. //scr_to_cur(glob_hwnd, &scr_pt);
  211. GetCursorPos(&scr_pt);
  212. #if 0
  213. stat = TrackPopupMenu(hpop_menu,
  214. 0, /* flags */
  215. //TPM_NONOTIFY, /* flags */
  216. scr_pt.x, scr_pt.y, /* x,y */
  217. 0, /* 0 reserved */
  218. glob_hwnd,
  219. NULL);
  220. #endif
  221. stat = TrackPopupMenuEx(hpop_menu,
  222. TPM_NONOTIFY | TPM_RETURNCMD, /* flags */
  223. scr_pt.x, scr_pt.y, /* x,y */
  224. //0, /* 0 reserved */
  225. glob_hwnd,
  226. NULL);
  227. if (stat == IDM_ADVANCED_MODEM_INF)
  228. {
  229. update_modem_inf(1);
  230. }
  231. else if (stat == IDM_PM)
  232. {
  233. stat = make_progman_group(progman_list_nt, wi->ip.dest_dir);
  234. }
  235. else if (stat == 0x10)
  236. {
  237. GetSystemDirectory(gtmpstr,144);
  238. strcat(gtmpstr, "\\");
  239. strcat(gtmpstr, OurAppDir);
  240. SetCurrentDirectory(gtmpstr);
  241. strcat(gtmpstr, "\\peer.exe");
  242. WinExec(gtmpstr, SW_RESTORE);
  243. }
  244. else if (stat == 0x11)
  245. {
  246. GetSystemDirectory(gtmpstr,144);
  247. strcat(gtmpstr, "\\");
  248. strcat(gtmpstr, OurAppDir);
  249. SetCurrentDirectory(gtmpstr);
  250. strcat(gtmpstr, "\\wcom32.exe");
  251. WinExec(gtmpstr, SW_RESTORE);
  252. }
  253. else if (stat == 0x12)
  254. {
  255. GetSystemDirectory(gtmpstr,144);
  256. strcat(gtmpstr, "\\");
  257. strcat(gtmpstr, OurAppDir);
  258. SetCurrentDirectory(gtmpstr);
  259. strcat(gtmpstr, "\\portmon.exe");
  260. WinExec(gtmpstr, SW_RESTORE);
  261. }
  262. DestroyMenu(hpop_menu);
  263. }
  264. /*----------------------------------------------------------
  265. get_field -
  266. |------------------------------------------------------------*/
  267. static void get_field(HWND hDlg, WORD id)
  268. {
  269. char tmpstr[60];
  270. UINT stat;
  271. INT val;
  272. //if (our_device_index >= wi->NumDevices)
  273. // our_device_index = 0;
  274. //pc = &wi->dev[our_device_index].ports[our_port_index];
  275. switch(id)
  276. {
  277. case IDC_VERBOSE :
  278. //------------------ fill in "verbose event logging" option
  279. if (IsDlgButtonChecked(hDlg, id))
  280. wi->VerboseLog = 1;
  281. else wi->VerboseLog = 0;
  282. break;
  283. case IDC_PNP_PORTS :
  284. #if ALLOW_NO_PNP_PORTS
  285. // don't allow them to change this here for now...
  286. if (IsDlgButtonChecked(hDlg, id))
  287. wi->NoPnpPorts = 1;
  288. else wi->NoPnpPorts = 0;
  289. #endif
  290. break;
  291. case IDC_GLOBAL485 :
  292. if (IsDlgButtonChecked(hDlg, id))
  293. wi->GlobalRS485 = 1;
  294. else
  295. wi->GlobalRS485 = 0;
  296. break;
  297. case IDC_CBOX_SCAN_RATE :
  298. //------------------------- check scan_rate edit field
  299. GetDlgItemText(hDlg, id, tmpstr, 59);
  300. stat= sscanf(tmpstr,"%d",&val);
  301. if ((stat == 1) && (val >= 0))
  302. {
  303. wi->ScanRate = (int) val;
  304. //wsprintf(tmpstr, "scan:%d", wi->ScanRate);
  305. //P_TRACE(tmpstr);
  306. }
  307. break;
  308. }
  309. }
  310. /*----------------------------------------------------------
  311. set_field -
  312. |------------------------------------------------------------*/
  313. static void set_field(HWND hDlg, WORD id)
  314. {
  315. HWND hwnd;
  316. char tmpstr[80];
  317. //if (our_device_index >= wi->NumDevices)
  318. // our_device_index = 0;
  319. //pc = &wi->dev[our_device_index].ports[our_port_index];
  320. switch(id)
  321. {
  322. case IDC_VERBOSE :
  323. //------------------ fill in "verbose log" option
  324. SendDlgItemMessage(hDlg, id, BM_SETCHECK, wi->VerboseLog, 0);
  325. break;
  326. case IDC_GLOBAL485 :
  327. //------------------ fill in "global rs485" option
  328. SendDlgItemMessage(hDlg, id, BM_SETCHECK, wi->GlobalRS485, 0);
  329. break;
  330. #if ALLOW_NO_PNP_PORTS
  331. case IDC_PNP_PORTS :
  332. SendDlgItemMessage(hDlg, id, BM_SETCHECK, wi->NoPnpPorts, 0);
  333. break;
  334. #endif
  335. case IDC_CBOX_SCAN_RATE :
  336. hwnd = GetDlgItem(hDlg, IDC_CBOX_SCAN_RATE);
  337. SendMessage(hwnd, CB_RESETCONTENT, 0, 0);
  338. SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)(char far *) "1");
  339. SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)(char far *) "2");
  340. SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)(char far *) "4");
  341. SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)(char far *) RcStr(MSGSTR+21));
  342. SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)(char far *) "20");
  343. if (wi->ScanRate < 0) wi->ScanRate = 0;
  344. if ((wi->ScanRate == 0) || (wi->ScanRate == 10))
  345. lstrcpy(tmpstr,RcStr(MSGSTR+21));
  346. else wsprintf(tmpstr,"%d",wi->ScanRate);
  347. SetDlgItemText(hDlg, IDC_CBOX_SCAN_RATE, tmpstr);
  348. break;
  349. }
  350. }