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.

538 lines
17 KiB

  1. // bootadv.h : Declaration of the CBootIniAdvancedDlg
  2. #ifndef __BOOTINIADVANCEDDLG_H_
  3. #define __BOOTINIADVANCEDDLG_H_
  4. #include "resource.h" // main symbols
  5. #include <atlhost.h>
  6. #include <math.h>
  7. #define MINBOOTMB 64 // from SkIn (from MSDN, 8MB is the minimum for /MAXMEM)
  8. #define MIN_1394_CHANNEL 1
  9. #define MAX_1394_CHANNEL 62
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CBootIniAdvancedDlg
  12. class CBootIniAdvancedDlg :
  13. public CAxDialogImpl<CBootIniAdvancedDlg>
  14. {
  15. public:
  16. CBootIniAdvancedDlg()
  17. {
  18. }
  19. ~CBootIniAdvancedDlg()
  20. {
  21. }
  22. enum { IDD = IDD_BOOTINIADVANCEDDLG };
  23. BEGIN_MSG_MAP(CBootIniAdvancedDlg)
  24. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  25. COMMAND_ID_HANDLER(IDOK, OnOK)
  26. COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
  27. COMMAND_HANDLER(IDC_BIABAUDRATE, BN_CLICKED, OnClickedBaudRateCheck)
  28. COMMAND_HANDLER(IDC_BIADEBUG, BN_CLICKED, OnClickedDebugCheck)
  29. COMMAND_HANDLER(IDC_BIADEBUGPORT, BN_CLICKED, OnClickedDebugPortCheck)
  30. COMMAND_HANDLER(IDC_BIAMAXMEM, BN_CLICKED, OnClickedMaxMemCheck)
  31. COMMAND_HANDLER(IDC_BIANUMPROC, BN_CLICKED, OnClickedNumProcCheck)
  32. NOTIFY_HANDLER(IDC_SPINMAXMEM, UDN_DELTAPOS, OnDeltaSpinMaxMem)
  33. COMMAND_HANDLER(IDC_EDITMAXMEM, EN_KILLFOCUS, OnKillFocusEditMaxMem)
  34. COMMAND_HANDLER(IDC_COMBOCOMPORT, CBN_SELCHANGE, OnSelChangeComboComPort)
  35. COMMAND_HANDLER(IDC_BIACHANNEL, BN_CLICKED, OnClickedBIAChannel)
  36. NOTIFY_HANDLER(IDC_SPINCHANNEL, UDN_DELTAPOS, OnDeltaSpinChannel)
  37. COMMAND_HANDLER(IDC_EDITCHANNEL, EN_KILLFOCUS, OnKillFocusChannel)
  38. END_MSG_MAP()
  39. // Handler prototypes:
  40. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  41. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  42. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  43. //-------------------------------------------------------------------------
  44. // Launch the advanced option dialog for the specified boot.ini line.
  45. // Modifies the string passed in if appropriate, returns TRUE if the user
  46. // made modifications, FALSE otherwise.
  47. //-------------------------------------------------------------------------
  48. BOOL ShowAdvancedOptions(CString & strIniLine)
  49. {
  50. m_strWorkingLine = strIniLine;
  51. BOOL fReturn = (DoModal() == IDOK);
  52. if (fReturn)
  53. strIniLine = m_strWorkingLine;
  54. return fReturn;
  55. }
  56. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  57. {
  58. // Initialize the drop down list for the number of processors available.
  59. SYSTEM_INFO si;
  60. ::GetSystemInfo(&si);
  61. CString strItem;
  62. for (DWORD dwProc = 1; dwProc <= si.dwNumberOfProcessors; dwProc++)
  63. {
  64. strItem.Format(_T("%d"), dwProc);
  65. ::SendMessage(GetDlgItem(IDC_COMBOPROCS), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)strItem);
  66. }
  67. // Initialize the drop down list for the number of COM ports available.
  68. ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_ADDSTRING, 0, (LPARAM)_T("COM1:"));
  69. ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_ADDSTRING, 0, (LPARAM)_T("COM2:"));
  70. ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_ADDSTRING, 0, (LPARAM)_T("COM3:"));
  71. ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_ADDSTRING, 0, (LPARAM)_T("COM4:"));
  72. ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_ADDSTRING, 0, (LPARAM)_T("1394"));
  73. // Initialize the drop down list for the available baud rates.
  74. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("300"));
  75. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("1200"));
  76. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("2400"));
  77. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("4800"));
  78. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("9600"));
  79. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("19200"));
  80. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("38400"));
  81. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("57600"));
  82. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_ADDSTRING, 0, (LPARAM)_T("115200"));
  83. // Get the maximum value for the /MAXMEM spinner.
  84. MEMORYSTATUS ms;
  85. GlobalMemoryStatus(&ms);
  86. // We should round the memory value up to the next 4MB boundary (455761) since
  87. // many machines report a little less than the full amount of RAM. Old line:
  88. //
  89. // m_iMaxMB = (int)ceil((double)ms.dwTotalPhys / (1024.0 * 1024.0));
  90. m_iMaxMB = ((int)ceil((double)ms.dwTotalPhys / (1024.0 * 1024.0 * 4.0)) * 4);
  91. // Set the controls of the dialog based on the line we're editing.
  92. SetDlgControlsToString();
  93. SetDlgControlState();
  94. return 1; // Let the system set the focus
  95. }
  96. LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  97. {
  98. SetStringToDlgControls();
  99. #ifdef DEBUG
  100. ::AfxMessageBox(m_strWorkingLine);
  101. #endif
  102. EndDialog(wID);
  103. return 0;
  104. }
  105. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  106. {
  107. EndDialog(wID);
  108. return 0;
  109. }
  110. //-------------------------------------------------------------------------
  111. // Set the states of the controls in the dialog (based on the values in
  112. // the other controls).
  113. //-------------------------------------------------------------------------
  114. void SetDlgControlState()
  115. {
  116. BOOL fMaxMem = (BST_CHECKED == IsDlgButtonChecked(IDC_BIAMAXMEM));
  117. ::EnableWindow(GetDlgItem(IDC_EDITMAXMEM), fMaxMem);
  118. ::EnableWindow(GetDlgItem(IDC_SPINMAXMEM), fMaxMem);
  119. BOOL fNumProc = (BST_CHECKED == IsDlgButtonChecked(IDC_BIANUMPROC));
  120. ::EnableWindow(GetDlgItem(IDC_COMBOPROCS), fNumProc);
  121. BOOL fDebug = (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUG));
  122. ::EnableWindow(GetDlgItem(IDC_BIADEBUGPORT), fDebug);
  123. BOOL fDebugPort = (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUGPORT));
  124. ::EnableWindow(GetDlgItem(IDC_COMBOCOMPORT), fDebug && fDebugPort);
  125. TCHAR szTemp[MAX_PATH];
  126. BOOL fFirewire = FALSE;
  127. BOOL fCOMPort = FALSE;
  128. if (GetDlgItemText(IDC_COMBOCOMPORT, szTemp, MAX_PATH))
  129. {
  130. if (_tcscmp(szTemp, _T("1394")) == 0)
  131. fFirewire = TRUE;
  132. else if (szTemp[0] == _T('C'))
  133. fCOMPort = TRUE;
  134. }
  135. ::EnableWindow(GetDlgItem(IDC_BIABAUDRATE), fDebug && fDebugPort && fCOMPort);
  136. ::EnableWindow(GetDlgItem(IDC_BIACHANNEL), fDebug && fDebugPort && fFirewire);
  137. BOOL fDebugRate = (BST_CHECKED == IsDlgButtonChecked(IDC_BIABAUDRATE));
  138. ::EnableWindow(GetDlgItem(IDC_COMBOBAUD), fDebug && fDebugRate && !fFirewire);
  139. BOOL fDebugChannel = (BST_CHECKED == IsDlgButtonChecked(IDC_BIACHANNEL));
  140. ::EnableWindow(GetDlgItem(IDC_EDITCHANNEL), fDebug && fDebugPort && fDebugChannel && fFirewire);
  141. ::EnableWindow(GetDlgItem(IDC_SPINCHANNEL), fDebug && fDebugPort && fDebugChannel && fFirewire);
  142. }
  143. //-------------------------------------------------------------------------
  144. // Sets the value of a combo box to the value in a string.
  145. //-------------------------------------------------------------------------
  146. void SetComboBox(LPCTSTR szLine, LPCTSTR szFlag, LPCTSTR szValidChars, UINT uiCB)
  147. {
  148. CString strLine(szLine);
  149. int i = strLine.Find(szFlag);
  150. if (i != -1)
  151. {
  152. CString strWorking(strLine.Mid(i));
  153. strWorking.TrimLeft(szFlag);
  154. strWorking.TrimLeft(_T(" ="));
  155. strWorking = strWorking.SpanIncluding(szValidChars);
  156. if (CB_ERR == ::SendMessage(GetDlgItem(uiCB), CB_SELECTSTRING, -1, (LPARAM)(LPCTSTR)strWorking))
  157. {
  158. LRESULT lIndex = ::SendMessage(GetDlgItem(uiCB), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)strWorking);
  159. if (lIndex != CB_ERR)
  160. ::SendMessage(GetDlgItem(uiCB), CB_SETCURSEL, (WPARAM)lIndex, 0);
  161. }
  162. }
  163. }
  164. //-------------------------------------------------------------------------
  165. // Set contents of the controls to reflect the contents of
  166. // m_strWorkingLine.
  167. //-------------------------------------------------------------------------
  168. void SetDlgControlsToString()
  169. {
  170. CString strLine(m_strWorkingLine);
  171. strLine.MakeLower();
  172. CheckDlgButton(IDC_BIAMAXMEM, (strLine.Find(_T("/maxmem")) != -1));
  173. CheckDlgButton(IDC_BIANUMPROC, (strLine.Find(_T("/numproc")) != -1));
  174. CheckDlgButton(IDC_BIAPCILOCK, (strLine.Find(_T("/pcilock")) != -1));
  175. CheckDlgButton(IDC_BIADEBUG, (strLine.Find(_T("/debug")) != -1));
  176. CheckDlgButton(IDC_BIADEBUGPORT, (strLine.Find(_T("/debugport")) != -1));
  177. CheckDlgButton(IDC_BIABAUDRATE, (strLine.Find(_T("/baudrate")) != -1));
  178. CheckDlgButton(IDC_BIACHANNEL, (strLine.Find(_T("/channel")) != -1));
  179. CString strWorking;
  180. int i = strLine.Find(_T("/maxmem"));
  181. if (i != -1)
  182. {
  183. strWorking = strLine.Mid(i);
  184. strWorking.TrimLeft(_T("/maxmem ="));
  185. strWorking = strWorking.SpanIncluding(_T("0123456789"));
  186. SetDlgItemText(IDC_EDITMAXMEM, strWorking);
  187. }
  188. i = strLine.Find(_T("/channel"));
  189. if (i != -1)
  190. {
  191. strWorking = strLine.Mid(i);
  192. strWorking.TrimLeft(_T("/channel ="));
  193. strWorking = strWorking.SpanIncluding(_T("0123456789"));
  194. SetDlgItemText(IDC_EDITCHANNEL, strWorking);
  195. }
  196. SetComboBox(strLine, _T("/numproc"), _T("0123456789"), IDC_COMBOPROCS);
  197. SetComboBox(strLine, _T("/baudrate"), _T("0123456789"), IDC_COMBOBAUD);
  198. SetComboBox(strLine, _T("/debugport"), _T("com1234:"), IDC_COMBOCOMPORT);
  199. }
  200. //-------------------------------------------------------------------------
  201. // Funtions to add or remove a flag from the working string.
  202. //-------------------------------------------------------------------------
  203. void AddFlag(LPCTSTR szFlag)
  204. {
  205. CString strFlag(szFlag);
  206. // TBD - might be a better way to do this.
  207. CString strRemove = strFlag.SpanExcluding(_T("="));
  208. RemoveFlag(strRemove);
  209. if (m_strWorkingLine.IsEmpty())
  210. m_strWorkingLine = strFlag;
  211. else
  212. {
  213. m_strWorkingLine.TrimRight();
  214. m_strWorkingLine += CString(_T(" ")) + strFlag;
  215. }
  216. }
  217. void RemoveFlag(LPCTSTR szFlag)
  218. {
  219. CString strWorking(m_strWorkingLine);
  220. strWorking.MakeLower();
  221. int iTrimLeft = strWorking.Find(szFlag);
  222. if (iTrimLeft == -1)
  223. return;
  224. CString strNewLine(_T(""));
  225. if (iTrimLeft > 0)
  226. strNewLine = m_strWorkingLine.Left(iTrimLeft);
  227. int iTrimRight = strWorking.Find(_T("/"), iTrimLeft + 1);
  228. if (iTrimRight != -1)
  229. strNewLine += m_strWorkingLine.Mid(iTrimRight);
  230. m_strWorkingLine = strNewLine;
  231. }
  232. //-------------------------------------------------------------------------
  233. // Set contents of m_strWorkingLine to reflec the dialog controls.
  234. //-------------------------------------------------------------------------
  235. void SetStringToDlgControls()
  236. {
  237. CString strFlag;
  238. TCHAR szTemp[MAX_PATH];
  239. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIAMAXMEM) && GetDlgItemText(IDC_EDITMAXMEM, szTemp, MAX_PATH))
  240. {
  241. long lRequestedValue = _ttol(szTemp);
  242. long lAllowedValue = VerifyMaxMem(lRequestedValue);
  243. if (lRequestedValue != lAllowedValue)
  244. {
  245. wsprintf(szTemp, _T("%d"), lAllowedValue);
  246. SetDlgItemText(IDC_EDITMAXMEM, szTemp);
  247. }
  248. strFlag.Format(_T("/maxmem=%s"), szTemp);
  249. AddFlag(strFlag);
  250. }
  251. else
  252. RemoveFlag(_T("/maxmem"));
  253. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIANUMPROC) && GetDlgItemText(IDC_COMBOPROCS, szTemp, MAX_PATH))
  254. {
  255. strFlag.Format(_T("/numproc=%s"), szTemp);
  256. AddFlag(strFlag);
  257. }
  258. else
  259. RemoveFlag(_T("/numproc"));
  260. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIAPCILOCK))
  261. AddFlag(_T("/pcilock"));
  262. else
  263. RemoveFlag(_T("/pcilock"));
  264. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUG))
  265. {
  266. AddFlag(_T("/debug"));
  267. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUGPORT) && GetDlgItemText(IDC_COMBOCOMPORT, szTemp, MAX_PATH))
  268. {
  269. strFlag.Format(_T("/debugport=%s"), szTemp);
  270. AddFlag(strFlag);
  271. }
  272. else
  273. RemoveFlag(_T("/debugport"));
  274. if (::IsWindowEnabled(GetDlgItem(IDC_BIABAUDRATE)) && BST_CHECKED == IsDlgButtonChecked(IDC_BIABAUDRATE) && GetDlgItemText(IDC_COMBOBAUD, szTemp, MAX_PATH))
  275. {
  276. strFlag.Format(_T("/baudrate=%s"), szTemp);
  277. AddFlag(strFlag);
  278. }
  279. else
  280. RemoveFlag(_T("/baudrate"));
  281. if (::IsWindowEnabled(GetDlgItem(IDC_BIACHANNEL)) && BST_CHECKED == IsDlgButtonChecked(IDC_BIACHANNEL) && GetDlgItemText(IDC_EDITCHANNEL, szTemp, MAX_PATH))
  282. {
  283. long lRequestedValue = _ttol(szTemp);
  284. long lAllowedValue = VerifyChannel(lRequestedValue);
  285. if (lRequestedValue != lAllowedValue)
  286. {
  287. wsprintf(szTemp, _T("%d"), lAllowedValue);
  288. SetDlgItemText(IDC_EDITCHANNEL, szTemp);
  289. }
  290. strFlag.Format(_T("/channel=%s"), szTemp);
  291. AddFlag(strFlag);
  292. }
  293. else
  294. RemoveFlag(_T("/channel"));
  295. }
  296. else
  297. {
  298. RemoveFlag(_T("/debug"));
  299. RemoveFlag(_T("/debugport"));
  300. RemoveFlag(_T("/baudrate"));
  301. RemoveFlag(_T("/channel"));
  302. }
  303. }
  304. private:
  305. CString m_strWorkingLine; // the line from the INI file we are modifying
  306. int m_iMaxMB; // max value for /MAXMEM
  307. LRESULT OnClickedBaudRateCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  308. {
  309. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIABAUDRATE))
  310. if (CB_ERR == ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_GETCURSEL, 0, 0))
  311. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_SETCURSEL, 0, 0);
  312. SetDlgControlState();
  313. return 0;
  314. }
  315. LRESULT OnClickedDebugCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  316. {
  317. SetDlgControlState();
  318. return 0;
  319. }
  320. LRESULT OnClickedDebugPortCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  321. {
  322. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUGPORT))
  323. if (CB_ERR == ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_GETCURSEL, 0, 0))
  324. ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_SETCURSEL, 0, 0);
  325. SetDlgControlState();
  326. return 0;
  327. }
  328. LRESULT OnClickedMaxMemCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  329. {
  330. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIAMAXMEM))
  331. {
  332. TCHAR szTemp[MAX_PATH];
  333. if (!GetDlgItemText(IDC_EDITMAXMEM, szTemp, MAX_PATH) || szTemp[0] == _T('\0'))
  334. {
  335. CString strMinValue;
  336. strMinValue.Format(_T("%d"), m_iMaxMB);
  337. SetDlgItemText(IDC_EDITMAXMEM, strMinValue);
  338. }
  339. }
  340. SetDlgControlState();
  341. return 0;
  342. }
  343. LRESULT OnClickedNumProcCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  344. {
  345. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIANUMPROC))
  346. if (CB_ERR == ::SendMessage(GetDlgItem(IDC_COMBOPROCS), CB_GETCURSEL, 0, 0))
  347. ::SendMessage(GetDlgItem(IDC_COMBOPROCS), CB_SETCURSEL, 0, 0);
  348. SetDlgControlState();
  349. return 0;
  350. }
  351. long VerifyMaxMem(long lMem)
  352. {
  353. if (lMem < MINBOOTMB)
  354. lMem = MINBOOTMB;
  355. if (lMem > m_iMaxMB)
  356. lMem = m_iMaxMB;
  357. return lMem;
  358. }
  359. LRESULT OnDeltaSpinMaxMem(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  360. {
  361. LPNMUPDOWN pnmud = (LPNMUPDOWN)pnmh;
  362. TCHAR szTemp[MAX_PATH];
  363. long lNewVal = m_iMaxMB;
  364. if (GetDlgItemText(IDC_EDITMAXMEM, szTemp, MAX_PATH))
  365. lNewVal = VerifyMaxMem(_ttol(szTemp) - pnmud->iDelta);
  366. wsprintf(szTemp, _T("%d"), lNewVal);
  367. SetDlgItemText(IDC_EDITMAXMEM, szTemp);
  368. return 0;
  369. }
  370. LRESULT OnKillFocusEditMaxMem(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  371. {
  372. TCHAR szTemp[MAX_PATH];
  373. if (GetDlgItemText(IDC_EDITMAXMEM, szTemp, MAX_PATH))
  374. {
  375. long lCurrentVal = _ttol(szTemp);
  376. long lAllowedVal = VerifyMaxMem(lCurrentVal);
  377. if (lCurrentVal != lAllowedVal)
  378. {
  379. wsprintf(szTemp, _T("%d"), lAllowedVal);
  380. SetDlgItemText(IDC_EDITMAXMEM, szTemp);
  381. }
  382. }
  383. return 0;
  384. }
  385. LRESULT OnSelChangeComboComPort(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  386. {
  387. SetDlgControlState();
  388. return 0;
  389. }
  390. LRESULT OnClickedBIAChannel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  391. {
  392. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIACHANNEL))
  393. {
  394. TCHAR szTemp[MAX_PATH];
  395. if (!GetDlgItemText(IDC_EDITCHANNEL, szTemp, MAX_PATH) || szTemp[0] == _T('\0'))
  396. SetDlgItemText(IDC_EDITCHANNEL, _T("1"));
  397. }
  398. SetDlgControlState();
  399. return 0;
  400. }
  401. long VerifyChannel(long lChannel)
  402. {
  403. if (lChannel < MIN_1394_CHANNEL)
  404. lChannel = MIN_1394_CHANNEL;
  405. if (lChannel > MAX_1394_CHANNEL)
  406. lChannel = MAX_1394_CHANNEL;
  407. return lChannel;
  408. }
  409. LRESULT OnDeltaSpinChannel(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  410. {
  411. LPNMUPDOWN pnmud = (LPNMUPDOWN)pnmh;
  412. TCHAR szTemp[MAX_PATH];
  413. long lNewVal = m_iMaxMB;
  414. if (GetDlgItemText(IDC_EDITCHANNEL, szTemp, MAX_PATH))
  415. lNewVal = VerifyChannel(_ttol(szTemp) - pnmud->iDelta);
  416. wsprintf(szTemp, _T("%d"), lNewVal);
  417. SetDlgItemText(IDC_EDITCHANNEL, szTemp);
  418. return 0;
  419. }
  420. LRESULT OnKillFocusChannel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  421. {
  422. TCHAR szTemp[MAX_PATH];
  423. if (GetDlgItemText(IDC_EDITCHANNEL, szTemp, MAX_PATH))
  424. {
  425. long lCurrentVal = _ttol(szTemp);
  426. long lAllowedVal = VerifyChannel(lCurrentVal);
  427. if (lCurrentVal != lAllowedVal)
  428. {
  429. wsprintf(szTemp, _T("%d"), lAllowedVal);
  430. SetDlgItemText(IDC_EDITCHANNEL, szTemp);
  431. }
  432. }
  433. return 0;
  434. }
  435. };
  436. #endif //__BOOTINIADVANCEDDLG_H_