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.

533 lines
16 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. m_iMaxMB = (int)ceil((double)ms.dwTotalPhys / (1024.0 * 1024.0));
  87. // Set the controls of the dialog based on the line we're editing.
  88. SetDlgControlsToString();
  89. SetDlgControlState();
  90. return 1; // Let the system set the focus
  91. }
  92. LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  93. {
  94. SetStringToDlgControls();
  95. #ifdef DEBUG
  96. ::AfxMessageBox(m_strWorkingLine);
  97. #endif
  98. EndDialog(wID);
  99. return 0;
  100. }
  101. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  102. {
  103. EndDialog(wID);
  104. return 0;
  105. }
  106. //-------------------------------------------------------------------------
  107. // Set the states of the controls in the dialog (based on the values in
  108. // the other controls).
  109. //-------------------------------------------------------------------------
  110. void SetDlgControlState()
  111. {
  112. BOOL fMaxMem = (BST_CHECKED == IsDlgButtonChecked(IDC_BIAMAXMEM));
  113. ::EnableWindow(GetDlgItem(IDC_EDITMAXMEM), fMaxMem);
  114. ::EnableWindow(GetDlgItem(IDC_SPINMAXMEM), fMaxMem);
  115. BOOL fNumProc = (BST_CHECKED == IsDlgButtonChecked(IDC_BIANUMPROC));
  116. ::EnableWindow(GetDlgItem(IDC_COMBOPROCS), fNumProc);
  117. BOOL fDebug = (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUG));
  118. ::EnableWindow(GetDlgItem(IDC_BIADEBUGPORT), fDebug);
  119. BOOL fDebugPort = (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUGPORT));
  120. ::EnableWindow(GetDlgItem(IDC_COMBOCOMPORT), fDebug && fDebugPort);
  121. TCHAR szTemp[MAX_PATH];
  122. BOOL fFirewire = FALSE;
  123. BOOL fCOMPort = FALSE;
  124. if (GetDlgItemText(IDC_COMBOCOMPORT, szTemp, MAX_PATH))
  125. {
  126. if (_tcscmp(szTemp, _T("1394")) == 0)
  127. fFirewire = TRUE;
  128. else if (szTemp[0] == _T('C'))
  129. fCOMPort = TRUE;
  130. }
  131. ::EnableWindow(GetDlgItem(IDC_BIABAUDRATE), fDebug && fDebugPort && fCOMPort);
  132. ::EnableWindow(GetDlgItem(IDC_BIACHANNEL), fDebug && fDebugPort && fFirewire);
  133. BOOL fDebugRate = (BST_CHECKED == IsDlgButtonChecked(IDC_BIABAUDRATE));
  134. ::EnableWindow(GetDlgItem(IDC_COMBOBAUD), fDebug && fDebugRate && !fFirewire);
  135. BOOL fDebugChannel = (BST_CHECKED == IsDlgButtonChecked(IDC_BIACHANNEL));
  136. ::EnableWindow(GetDlgItem(IDC_EDITCHANNEL), fDebug && fDebugChannel && fFirewire);
  137. ::EnableWindow(GetDlgItem(IDC_SPINCHANNEL), fDebug && fDebugChannel && fFirewire);
  138. }
  139. //-------------------------------------------------------------------------
  140. // Sets the value of a combo box to the value in a string.
  141. //-------------------------------------------------------------------------
  142. void SetComboBox(LPCTSTR szLine, LPCTSTR szFlag, LPCTSTR szValidChars, UINT uiCB)
  143. {
  144. CString strLine(szLine);
  145. int i = strLine.Find(szFlag);
  146. if (i != -1)
  147. {
  148. CString strWorking(strLine.Mid(i));
  149. strWorking.TrimLeft(szFlag);
  150. strWorking.TrimLeft(_T(" ="));
  151. strWorking = strWorking.SpanIncluding(szValidChars);
  152. if (CB_ERR == ::SendMessage(GetDlgItem(uiCB), CB_SELECTSTRING, -1, (LPARAM)(LPCTSTR)strWorking))
  153. {
  154. LRESULT lIndex = ::SendMessage(GetDlgItem(uiCB), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)strWorking);
  155. if (lIndex != CB_ERR)
  156. ::SendMessage(GetDlgItem(uiCB), CB_SETCURSEL, (WPARAM)lIndex, 0);
  157. }
  158. }
  159. }
  160. //-------------------------------------------------------------------------
  161. // Set contents of the controls to reflect the contents of
  162. // m_strWorkingLine.
  163. //-------------------------------------------------------------------------
  164. void SetDlgControlsToString()
  165. {
  166. CString strLine(m_strWorkingLine);
  167. strLine.MakeLower();
  168. CheckDlgButton(IDC_BIAMAXMEM, (strLine.Find(_T("/maxmem")) != -1));
  169. CheckDlgButton(IDC_BIANUMPROC, (strLine.Find(_T("/numproc")) != -1));
  170. CheckDlgButton(IDC_BIAPCILOCK, (strLine.Find(_T("/pcilock")) != -1));
  171. CheckDlgButton(IDC_BIADEBUG, (strLine.Find(_T("/debug")) != -1));
  172. CheckDlgButton(IDC_BIADEBUGPORT, (strLine.Find(_T("/debugport")) != -1));
  173. CheckDlgButton(IDC_BIABAUDRATE, (strLine.Find(_T("/baudrate")) != -1));
  174. CheckDlgButton(IDC_BIACHANNEL, (strLine.Find(_T("/channel")) != -1));
  175. CString strWorking;
  176. int i = strLine.Find(_T("/maxmem"));
  177. if (i != -1)
  178. {
  179. strWorking = strLine.Mid(i);
  180. strWorking.TrimLeft(_T("/maxmem ="));
  181. strWorking = strWorking.SpanIncluding(_T("0123456789"));
  182. SetDlgItemText(IDC_EDITMAXMEM, strWorking);
  183. }
  184. i = strLine.Find(_T("/channel"));
  185. if (i != -1)
  186. {
  187. strWorking = strLine.Mid(i);
  188. strWorking.TrimLeft(_T("/channel ="));
  189. strWorking = strWorking.SpanIncluding(_T("0123456789"));
  190. SetDlgItemText(IDC_EDITCHANNEL, strWorking);
  191. }
  192. SetComboBox(strLine, _T("/numproc"), _T("0123456789"), IDC_COMBOPROCS);
  193. SetComboBox(strLine, _T("/baudrate"), _T("0123456789"), IDC_COMBOBAUD);
  194. SetComboBox(strLine, _T("/debugport"), _T("com1234:"), IDC_COMBOCOMPORT);
  195. }
  196. //-------------------------------------------------------------------------
  197. // Funtions to add or remove a flag from the working string.
  198. //-------------------------------------------------------------------------
  199. void AddFlag(LPCTSTR szFlag)
  200. {
  201. CString strFlag(szFlag);
  202. // TBD - might be a better way to do this.
  203. CString strRemove = strFlag.SpanExcluding(_T("="));
  204. RemoveFlag(strRemove);
  205. if (m_strWorkingLine.IsEmpty())
  206. m_strWorkingLine = strFlag;
  207. else
  208. {
  209. m_strWorkingLine.TrimRight();
  210. m_strWorkingLine += CString(_T(" ")) + strFlag;
  211. }
  212. }
  213. void RemoveFlag(LPCTSTR szFlag)
  214. {
  215. CString strWorking(m_strWorkingLine);
  216. strWorking.MakeLower();
  217. int iTrimLeft = strWorking.Find(szFlag);
  218. if (iTrimLeft == -1)
  219. return;
  220. CString strNewLine(_T(""));
  221. if (iTrimLeft > 0)
  222. strNewLine = m_strWorkingLine.Left(iTrimLeft);
  223. int iTrimRight = strWorking.Find(_T("/"), iTrimLeft + 1);
  224. if (iTrimRight != -1)
  225. strNewLine += m_strWorkingLine.Mid(iTrimRight);
  226. m_strWorkingLine = strNewLine;
  227. }
  228. //-------------------------------------------------------------------------
  229. // Set contents of m_strWorkingLine to reflec the dialog controls.
  230. //-------------------------------------------------------------------------
  231. void SetStringToDlgControls()
  232. {
  233. CString strFlag;
  234. TCHAR szTemp[MAX_PATH];
  235. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIAMAXMEM) && GetDlgItemText(IDC_EDITMAXMEM, szTemp, MAX_PATH))
  236. {
  237. long lRequestedValue = _ttol(szTemp);
  238. long lAllowedValue = VerifyMaxMem(lRequestedValue);
  239. if (lRequestedValue != lAllowedValue)
  240. {
  241. wsprintf(szTemp, _T("%d"), lAllowedValue);
  242. SetDlgItemText(IDC_EDITMAXMEM, szTemp);
  243. }
  244. strFlag.Format(_T("/maxmem=%s"), szTemp);
  245. AddFlag(strFlag);
  246. }
  247. else
  248. RemoveFlag(_T("/maxmem"));
  249. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIANUMPROC) && GetDlgItemText(IDC_COMBOPROCS, szTemp, MAX_PATH))
  250. {
  251. strFlag.Format(_T("/numproc=%s"), szTemp);
  252. AddFlag(strFlag);
  253. }
  254. else
  255. RemoveFlag(_T("/numproc"));
  256. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIAPCILOCK))
  257. AddFlag(_T("/pcilock"));
  258. else
  259. RemoveFlag(_T("/pcilock"));
  260. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUG))
  261. {
  262. AddFlag(_T("/debug"));
  263. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUGPORT) && GetDlgItemText(IDC_COMBOCOMPORT, szTemp, MAX_PATH))
  264. {
  265. strFlag.Format(_T("/debugport=%s"), szTemp);
  266. AddFlag(strFlag);
  267. }
  268. else
  269. RemoveFlag(_T("/debugport"));
  270. if (::IsWindowEnabled(GetDlgItem(IDC_BIABAUDRATE)) && BST_CHECKED == IsDlgButtonChecked(IDC_BIABAUDRATE) && GetDlgItemText(IDC_COMBOBAUD, szTemp, MAX_PATH))
  271. {
  272. strFlag.Format(_T("/baudrate=%s"), szTemp);
  273. AddFlag(strFlag);
  274. }
  275. else
  276. RemoveFlag(_T("/baudrate"));
  277. if (::IsWindowEnabled(GetDlgItem(IDC_BIACHANNEL)) && BST_CHECKED == IsDlgButtonChecked(IDC_BIACHANNEL) && GetDlgItemText(IDC_EDITCHANNEL, szTemp, MAX_PATH))
  278. {
  279. long lRequestedValue = _ttol(szTemp);
  280. long lAllowedValue = VerifyChannel(lRequestedValue);
  281. if (lRequestedValue != lAllowedValue)
  282. {
  283. wsprintf(szTemp, _T("%d"), lAllowedValue);
  284. SetDlgItemText(IDC_EDITCHANNEL, szTemp);
  285. }
  286. strFlag.Format(_T("/channel=%s"), szTemp);
  287. AddFlag(strFlag);
  288. }
  289. else
  290. RemoveFlag(_T("/channel"));
  291. }
  292. else
  293. {
  294. RemoveFlag(_T("/debug"));
  295. RemoveFlag(_T("/debugport"));
  296. RemoveFlag(_T("/baudrate"));
  297. RemoveFlag(_T("/channel"));
  298. }
  299. }
  300. private:
  301. CString m_strWorkingLine; // the line from the INI file we are modifying
  302. int m_iMaxMB; // max value for /MAXMEM
  303. LRESULT OnClickedBaudRateCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  304. {
  305. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIABAUDRATE))
  306. if (CB_ERR == ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_GETCURSEL, 0, 0))
  307. ::SendMessage(GetDlgItem(IDC_COMBOBAUD), CB_SETCURSEL, 0, 0);
  308. SetDlgControlState();
  309. return 0;
  310. }
  311. LRESULT OnClickedDebugCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  312. {
  313. SetDlgControlState();
  314. return 0;
  315. }
  316. LRESULT OnClickedDebugPortCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  317. {
  318. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIADEBUGPORT))
  319. if (CB_ERR == ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_GETCURSEL, 0, 0))
  320. ::SendMessage(GetDlgItem(IDC_COMBOCOMPORT), CB_SETCURSEL, 0, 0);
  321. SetDlgControlState();
  322. return 0;
  323. }
  324. LRESULT OnClickedMaxMemCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  325. {
  326. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIAMAXMEM))
  327. {
  328. TCHAR szTemp[MAX_PATH];
  329. if (!GetDlgItemText(IDC_EDITMAXMEM, szTemp, MAX_PATH) || szTemp[0] == _T('\0'))
  330. {
  331. CString strMinValue;
  332. strMinValue.Format(_T("%d"), m_iMaxMB);
  333. SetDlgItemText(IDC_EDITMAXMEM, strMinValue);
  334. }
  335. }
  336. SetDlgControlState();
  337. return 0;
  338. }
  339. LRESULT OnClickedNumProcCheck(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  340. {
  341. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIANUMPROC))
  342. if (CB_ERR == ::SendMessage(GetDlgItem(IDC_COMBOPROCS), CB_GETCURSEL, 0, 0))
  343. ::SendMessage(GetDlgItem(IDC_COMBOPROCS), CB_SETCURSEL, 0, 0);
  344. SetDlgControlState();
  345. return 0;
  346. }
  347. long VerifyMaxMem(long lMem)
  348. {
  349. if (lMem < MINBOOTMB)
  350. lMem = MINBOOTMB;
  351. if (lMem > m_iMaxMB)
  352. lMem = m_iMaxMB;
  353. return lMem;
  354. }
  355. LRESULT OnDeltaSpinMaxMem(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  356. {
  357. LPNMUPDOWN pnmud = (LPNMUPDOWN)pnmh;
  358. TCHAR szTemp[MAX_PATH];
  359. long lNewVal = m_iMaxMB;
  360. if (GetDlgItemText(IDC_EDITMAXMEM, szTemp, MAX_PATH))
  361. lNewVal = VerifyMaxMem(_ttol(szTemp) - pnmud->iDelta);
  362. wsprintf(szTemp, _T("%d"), lNewVal);
  363. SetDlgItemText(IDC_EDITMAXMEM, szTemp);
  364. return 0;
  365. }
  366. LRESULT OnKillFocusEditMaxMem(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  367. {
  368. TCHAR szTemp[MAX_PATH];
  369. if (GetDlgItemText(IDC_EDITMAXMEM, szTemp, MAX_PATH))
  370. {
  371. long lCurrentVal = _ttol(szTemp);
  372. long lAllowedVal = VerifyMaxMem(lCurrentVal);
  373. if (lCurrentVal != lAllowedVal)
  374. {
  375. wsprintf(szTemp, _T("%d"), lAllowedVal);
  376. SetDlgItemText(IDC_EDITMAXMEM, szTemp);
  377. }
  378. }
  379. return 0;
  380. }
  381. LRESULT OnSelChangeComboComPort(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  382. {
  383. SetDlgControlState();
  384. return 0;
  385. }
  386. LRESULT OnClickedBIAChannel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  387. {
  388. if (BST_CHECKED == IsDlgButtonChecked(IDC_BIACHANNEL))
  389. {
  390. TCHAR szTemp[MAX_PATH];
  391. if (!GetDlgItemText(IDC_EDITCHANNEL, szTemp, MAX_PATH) || szTemp[0] == _T('\0'))
  392. SetDlgItemText(IDC_EDITCHANNEL, _T("1"));
  393. }
  394. SetDlgControlState();
  395. return 0;
  396. }
  397. long VerifyChannel(long lChannel)
  398. {
  399. if (lChannel < MIN_1394_CHANNEL)
  400. lChannel = MIN_1394_CHANNEL;
  401. if (lChannel > MAX_1394_CHANNEL)
  402. lChannel = MAX_1394_CHANNEL;
  403. return lChannel;
  404. }
  405. LRESULT OnDeltaSpinChannel(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  406. {
  407. LPNMUPDOWN pnmud = (LPNMUPDOWN)pnmh;
  408. TCHAR szTemp[MAX_PATH];
  409. long lNewVal = m_iMaxMB;
  410. if (GetDlgItemText(IDC_EDITCHANNEL, szTemp, MAX_PATH))
  411. lNewVal = VerifyChannel(_ttol(szTemp) - pnmud->iDelta);
  412. wsprintf(szTemp, _T("%d"), lNewVal);
  413. SetDlgItemText(IDC_EDITCHANNEL, szTemp);
  414. return 0;
  415. }
  416. LRESULT OnKillFocusChannel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  417. {
  418. TCHAR szTemp[MAX_PATH];
  419. if (GetDlgItemText(IDC_EDITCHANNEL, szTemp, MAX_PATH))
  420. {
  421. long lCurrentVal = _ttol(szTemp);
  422. long lAllowedVal = VerifyChannel(lCurrentVal);
  423. if (lCurrentVal != lAllowedVal)
  424. {
  425. wsprintf(szTemp, _T("%d"), lAllowedVal);
  426. SetDlgItemText(IDC_EDITCHANNEL, szTemp);
  427. }
  428. }
  429. return 0;
  430. }
  431. };
  432. #endif //__BOOTINIADVANCEDDLG_H_