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.

823 lines
22 KiB

  1. /***************************************************************************/
  2. /** Microsoft Windows **/
  3. /** Copyright(c) Microsoft Corp., 1991, 1992 **/
  4. /***************************************************************************/
  5. /****************************************************************************
  6. dlg.cpp
  7. Aug 92, JimH
  8. May 93, JimH chico port
  9. Dialog classes are defined here.
  10. CScoreDlg shows current score sheet
  11. CQuoteDlg quote dialog
  12. CWelcomeDlg welcome to Hearts, wanna be gamemeister?
  13. COptionsDlg set options
  14. CLocateDlg locate dealer
  15. ****************************************************************************/
  16. #include "hearts.h"
  17. #include "resource.h"
  18. #include "main.h"
  19. #include "debug.h"
  20. #include "helpnum.h"
  21. #include "stdlib.h"
  22. #include <nddeapi.h>
  23. typedef int (CALLBACK* FPROC)(); // a FARPROC that returns int
  24. // NDDE typedefs for ShareGetInfo and ShareSetInfo (SGI and SSI)
  25. typedef UINT (WINAPI *SGIPROC)(LPSTR, LPCSTR, UINT, LPBYTE, DWORD, LPDWORD, LPWORD);
  26. typedef UINT (WINAPI *SSIPROC)(LPSTR, LPCSTR, UINT, LPBYTE, DWORD, WORD);
  27. // declare statics
  28. int CScoreDlg::nHandsPlayed = 0;
  29. int CScoreDlg::score[MAXPLAYER][MAXHANDS+1];
  30. BOOL CScoreDlg::bGameOver = FALSE;
  31. BEGIN_MESSAGE_MAP( CScoreDlg, CModalDialog )
  32. ON_WM_PAINT()
  33. END_MESSAGE_MAP()
  34. /****************************************************************************
  35. CScoreDlg constructors
  36. The first constructor takes only one argument, the pointer to the class
  37. of the parent window. It is used to display the current score at
  38. arbitrary points in the game, ie when the user requests it.
  39. The second also updates the static score array with new information.
  40. ****************************************************************************/
  41. CScoreDlg::CScoreDlg(CWnd *pParent) : CModalDialog(DLG_SCORE, pParent),
  42. m_myid(-1)
  43. {
  44. }
  45. CScoreDlg::CScoreDlg(CWnd *pParent, int s[MAXPLAYER], int id) :
  46. CModalDialog(DLG_SCORE, pParent), m_myid(id)
  47. {
  48. if (nHandsPlayed == MAXHANDS)
  49. {
  50. for (int hand = 1; hand < MAXHANDS; hand++)
  51. for (int player = 0; player < MAXPLAYER; player++)
  52. score[player][hand-1] = score[player][hand];
  53. nHandsPlayed--;
  54. }
  55. // add latest scores to list
  56. for (int player = 0; player < MAXPLAYER; player++)
  57. score[player][nHandsPlayed] = s[player];
  58. nHandsPlayed++;
  59. }
  60. /****************************************************************************
  61. CScoreDlg::OnInitDialog
  62. ****************************************************************************/
  63. BOOL CScoreDlg::OnInitDialog()
  64. {
  65. RECT rcDlg, rcMain;
  66. GetParent()->GetClientRect(&rcMain);
  67. GetParent()->ClientToScreen(&rcMain);
  68. rcMain.bottom -= ::nStatusHeight;
  69. GetWindowRect(&rcDlg);
  70. int dxDlg = rcDlg.right - rcDlg.left;
  71. int dxMain = rcMain.right - rcMain.left;
  72. int x = rcMain.left + ((dxMain - dxDlg) / 2);
  73. int dyDlg = rcDlg.bottom - rcDlg.top;
  74. int dyMain = rcMain.bottom - rcMain.top;
  75. int y = rcMain.top + ((dyMain - dyDlg) / 2);
  76. SetWindowPos(NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
  77. SetText(); // set title bar text
  78. return TRUE;
  79. }
  80. /****************************************************************************
  81. CScoreDlg::SetText -- set title bar text
  82. ****************************************************************************/
  83. void CScoreDlg::SetText()
  84. {
  85. CString s, s2;
  86. s.LoadString(IDS_SCORESHEET);
  87. if (nHandsPlayed != 0)
  88. {
  89. int place = 0;
  90. for (int i = 1; i < MAXPLAYER; i++)
  91. if (score[i][nHandsPlayed-1] < score[0][nHandsPlayed-1])
  92. place++;
  93. s2.LoadString(IDS_PLACE1 + place);
  94. s += " -- ";
  95. s += s2;
  96. }
  97. SetWindowText(s);
  98. }
  99. /****************************************************************************
  100. CScoreDlg::OnPaint
  101. The score text is not drawn with text controls because the strikeout
  102. text is needed for some parts of the score. Instead, the paint message
  103. is hooked here.
  104. ****************************************************************************/
  105. void CScoreDlg::OnPaint()
  106. {
  107. BYTE charset = 0;
  108. int fontsize = 0;
  109. CString fontname, charsetstr, fontsizestr;
  110. fontname.LoadString(IDS_FONTFACE);
  111. charsetstr.LoadString(IDS_CHARSET);
  112. fontsizestr.LoadString(IDS_FONTSIZE);
  113. charset = (BYTE)_ttoi((const TCHAR *)charsetstr);
  114. fontsize = _ttoi((const TCHAR *)fontsizestr);
  115. // Nobody has best score if game hasn't started yet
  116. int nBestScore = (nHandsPlayed == 0 ? 0 : 30000);
  117. int nWorstScore = 0;
  118. if (nHandsPlayed > 0)
  119. {
  120. for (int pos = 0; pos < MAXPLAYER; pos++)
  121. {
  122. if (score[pos][nHandsPlayed-1] < nBestScore)
  123. {
  124. nBestScore = score[pos][nHandsPlayed-1];
  125. }
  126. if (score[pos][nHandsPlayed-1] > nWorstScore)
  127. {
  128. nWorstScore = score[pos][nHandsPlayed-1];
  129. }
  130. }
  131. }
  132. // If the game is over, display appropriate text in title bar
  133. if (nWorstScore >= 100)
  134. {
  135. CString title;
  136. if (score[0][nHandsPlayed-1] == nBestScore)
  137. title.LoadString(IDS_GAMEOVERWIN);
  138. else
  139. title.LoadString(IDS_GAMEOVER);
  140. SetWindowText(title);
  141. bGameOver = TRUE;
  142. }
  143. CPaintDC dc(this);
  144. CRect rect;
  145. GetClientRect(&rect);
  146. // Divide the dialog up into columns for displaying scores
  147. rect.right -= 5; // 5 pixels on left, overlap on right
  148. int nWidth = rect.right / 5;
  149. rect.bottom -= 10; // 5 pixels on top and bottom
  150. int nHeight = rect.bottom;
  151. CString text, s;
  152. dc.SetBkMode(TRANSPARENT);
  153. // If game is over, change the appearance of the dialog so people
  154. // notice it. The section below adds the icon under the OK button.
  155. if (bGameOver)
  156. {
  157. HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(),
  158. MAKEINTRESOURCE(AFX_IDI_STD_FRAME));
  159. int x = (nWidth * 4) + ((nWidth - 32) / 2);
  160. int y = 75;
  161. dc.DrawIcon(x, y, hIcon);
  162. // CRect rectIcon(x-10, y-10, x+32+10, y+32+10);
  163. // FrameRect(rectIcon);
  164. }
  165. // create Helv 8 bold font, and Helv 8 bold strikeout font
  166. CFont font, strikefont;
  167. font.CreateFont(fontsize, 0, 0, 0, 700, 0, 0, 0, charset, 0, 0, 0, 0, fontname);
  168. strikefont.CreateFont(fontsize, 0, 0, 0, 700, 0, 0, 1, charset, 0, 0, 0, 0, fontname);
  169. CFont *oldfont = dc.SelectObject(&font);
  170. for (int pos = 0; pos < MAXPLAYER; pos++)
  171. {
  172. int red = 127; // ega needed special processing here
  173. if (nHandsPlayed > 0)
  174. if (score[pos][nHandsPlayed-1] == nBestScore)
  175. dc.SetTextColor(bGameOver ? RGB(red, 0, 0) : RGB(0, 0, 255));
  176. text = ((CMainWindow *)::pMainWnd)->GetPlayerName(pos);
  177. // The line below allows overlapping of names at top of score dlg.
  178. // To disallow overlapping, use:
  179. // rect.SetRect(5 + (nWidth*pos), 5, 5 + (nWidth*(pos+1)), nHeight);
  180. rect.SetRect((nWidth*pos) - 5, 5, 15 + (nWidth*(pos+1)), nHeight);
  181. int nTextHeight = dc.DrawText(text, -1, &rect, DT_CENTER | DT_NOPREFIX);
  182. rect.top += nTextHeight;
  183. dc.SelectObject(&strikefont);
  184. text.Empty();
  185. for (int hand = 0; hand < (nHandsPlayed - 1); hand++)
  186. {
  187. wsprintf(s.GetBuffer(20), TEXT("%d\r\n"), score[pos][hand]);
  188. s.ReleaseBuffer();
  189. text += s;
  190. }
  191. dc.DrawText(text, -1, &rect, DT_CENTER);
  192. rect.top += (nTextHeight * (nHandsPlayed - 1));
  193. dc.SelectObject(&font);
  194. if (nHandsPlayed > 0)
  195. {
  196. wsprintf(text.GetBuffer(20), TEXT("%d"), score[pos][nHandsPlayed-1]);
  197. text.ReleaseBuffer();
  198. }
  199. dc.DrawText(text, -1, &rect, DT_CENTER);
  200. dc.SetTextColor(0);
  201. }
  202. dc.SelectObject(oldfont);
  203. }
  204. /****************************************************************************
  205. CQuoteDlg
  206. ****************************************************************************/
  207. BEGIN_MESSAGE_MAP( CQuoteDlg, CModalDialog )
  208. ON_WM_PAINT()
  209. END_MESSAGE_MAP()
  210. /****************************************************************************
  211. CQuoteDlg constructor
  212. ****************************************************************************/
  213. CQuoteDlg::CQuoteDlg(CWnd *pParent) : CModalDialog(DLG_QUOTE, pParent)
  214. {
  215. }
  216. /****************************************************************************
  217. CQuoteDlg::OnPaint
  218. This used to draw an icon and a 3d frame. Now it just draws the icon.
  219. ****************************************************************************/
  220. void CQuoteDlg::OnPaint()
  221. {
  222. CPaintDC dc(this);
  223. #ifdef USE_MIRRORING
  224. SetLayout(dc.m_hDC, 0);
  225. SetLayout(dc.m_hAttribDC, 0);
  226. #endif
  227. HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(),
  228. MAKEINTRESOURCE(AFX_IDI_STD_FRAME));
  229. int x = 24;
  230. int y = 24;
  231. dc.DrawIcon(x, y, hIcon);
  232. // CRect rectIcon(x-10, y-10, x+32+10, y+32+10);
  233. // FrameRect(rectIcon);
  234. }
  235. /****************************************************************************
  236. CWelcomeDlg
  237. ****************************************************************************/
  238. BEGIN_MESSAGE_MAP( CWelcomeDlg, CModalDialog )
  239. ON_BN_CLICKED(IDC_WELCOMEHELP, OnHelp)
  240. END_MESSAGE_MAP()
  241. /****************************************************************************
  242. CWelcomeDlg constructor
  243. ****************************************************************************/
  244. CWelcomeDlg::CWelcomeDlg(CWnd *pParent) : CModalDialog(DLG_WELCOME, pParent),
  245. m_bNetDdeActive(UNKNOWN), m_bGameMeister(FALSE)
  246. {
  247. RegEntry Reg(szRegPath);
  248. TCHAR *pm_myname = m_myname.GetBuffer(MAXNAMELENGTH+1);
  249. Reg.GetString(regvalName, pm_myname, MAXNAMELENGTH+1);
  250. m_myname.ReleaseBuffer();
  251. }
  252. /****************************************************************************
  253. CWelcomeDlg::OnInitDialog()
  254. Restore settings from .ini file
  255. ****************************************************************************/
  256. BOOL CWelcomeDlg::OnInitDialog()
  257. {
  258. #ifdef USENETDDE
  259. if (IsNetDdeActive())
  260. {
  261. RegEntry Reg(szRegPath);
  262. if (Reg.GetNumber(regvalRole, FALSE))
  263. ((CButton *)GetDlgItem(IDC_MEISTER))->SetCheck(TRUE);
  264. else
  265. ((CButton *)GetDlgItem(IDC_JOIN))->SetCheck(TRUE);
  266. }
  267. else
  268. {
  269. ((CWnd *)GetDlgItem(IDC_GROUP))->EnableWindow(FALSE);
  270. ((CWnd *)GetDlgItem(IDC_JOIN))->EnableWindow(FALSE);
  271. ((CWnd *)GetDlgItem(IDC_MEISTER))->EnableWindow(FALSE);
  272. }
  273. #endif
  274. CEdit *editname = (CEdit *)GetDlgItem(IDC_YOURNAME);
  275. editname->SetWindowText(m_myname);
  276. editname->LimitText(MAXNAMELENGTH);
  277. return TRUE;
  278. }
  279. /****************************************************************************
  280. CWelcomeDlg::OnOK()
  281. Don't allow empty name. Store data in .ini file.
  282. ****************************************************************************/
  283. void CWelcomeDlg::OnOK()
  284. {
  285. GetDlgItemText(IDC_YOURNAME, m_myname.GetBuffer(MAXNAMELENGTH+1),
  286. MAXNAMELENGTH+1);
  287. m_myname.ReleaseBuffer();
  288. if (m_myname.IsEmpty())
  289. {
  290. ((CEdit *)GetDlgItem(IDC_YOURNAME))->SetFocus();
  291. return;
  292. }
  293. if (IsNetDdeActive())
  294. m_bGameMeister = ((CButton *)GetDlgItem(IDC_MEISTER))->GetCheck();
  295. else
  296. m_bGameMeister = TRUE;
  297. RegEntry Reg(szRegPath);
  298. Reg.SetValue(regvalRole, m_bGameMeister ? 1 : 0L);
  299. Reg.SetValue(regvalName, m_myname);
  300. // ::WinHelp(m_hWnd, szHelpFileName, HELP_QUIT, 0);
  301. EndDialog(IDOK);
  302. }
  303. /****************************************************************************
  304. CWelcomeDlg::IsNetDdeActive()
  305. This check is only done once. m_bNetDdeActive starts as -1 (UNKNOWN).
  306. The first time this function is called, a call to NDdeGetWindow returns
  307. NULL if NETDDE is not loaded. NetDDE is exec'd and the call is repeated.
  308. If the call fails the second time, it is assumed NetDDE couldn't start
  309. because no compatible NETBIOS was found.
  310. ****************************************************************************/
  311. BOOL CWelcomeDlg::IsNetDdeActive()
  312. {
  313. if (m_bNetDdeActive != UNKNOWN)
  314. return m_bNetDdeActive;
  315. m_bNetDdeActive = TRUE; // assume true, then check
  316. SetErrorMode(SEM_NOOPENFILEERRORBOX);
  317. HINSTANCE hinstNDDEAPI = LoadLibrary(TEXT("NDDEAPI.DLL"));
  318. if (hinstNDDEAPI <= (HINSTANCE)HINSTANCE_ERROR)
  319. {
  320. m_bNetDdeActive = FALSE;
  321. return m_bNetDdeActive;
  322. }
  323. FPROC lpfnNDDEGetWindow = (FPROC) GetProcAddress(hinstNDDEAPI, "NDdeGetWindow");
  324. if (lpfnNDDEGetWindow == NULL)
  325. {
  326. FreeLibrary(hinstNDDEAPI);
  327. m_bNetDdeActive = FALSE;
  328. return m_bNetDdeActive;
  329. }
  330. if ((*lpfnNDDEGetWindow)() == NULL) // look for netdde main window
  331. {
  332. UINT ret = WinExec("NETDDE.EXE", SW_SHOWNA);
  333. TRACE1("ret from WinExec is %u\n", ret);
  334. if ((*lpfnNDDEGetWindow)() == NULL)
  335. m_bNetDdeActive = FALSE;
  336. }
  337. FreeLibrary(hinstNDDEAPI);
  338. return m_bNetDdeActive;
  339. }
  340. /****************************************************************************
  341. CWelcomeDlg::OnHelp()
  342. ****************************************************************************/
  343. void CWelcomeDlg::OnHelp()
  344. {
  345. // ::WinHelp(m_hWnd, szHelpFileName, HELP_CONTEXT, IDH_START_HOW_HRTS);
  346. }
  347. /****************************************************************************
  348. COptionsDlg constructor
  349. ****************************************************************************/
  350. COptionsDlg::COptionsDlg(CWnd *pParent) : CModalDialog(DLG_OPTIONS, pParent)
  351. {
  352. }
  353. /****************************************************************************
  354. COptionsDlg::OnInitDialog
  355. Set dialog controls to current values
  356. ****************************************************************************/
  357. BOOL COptionsDlg::OnInitDialog()
  358. {
  359. RegEntry Reg(szRegPath);
  360. // Set animation speed radio button
  361. DWORD dwSpeed = Reg.GetNumber(regvalSpeed, IDC_NORMAL);
  362. ((CButton *)GetDlgItem((int)dwSpeed))->SetCheck(TRUE);
  363. // Set current computer player names. If they are not specified in
  364. // the .ini file, get defaults from the resource file.
  365. CEdit *pName[3];
  366. CString sName[3];
  367. for (int i = 0; i < 3; i++)
  368. {
  369. pName[i] = (CEdit *)GetDlgItem(IDC_NAME1 + i);
  370. pName[i]->LimitText(MAXNAMELENGTH);
  371. TCHAR *p = sName[i].GetBuffer(MAXNAMELENGTH + 1);
  372. Reg.GetString(regvalPName[i], p, MAXNAMELENGTH+1);
  373. sName[i].ReleaseBuffer();
  374. if (sName[i].IsEmpty())
  375. sName[i].LoadString(IDS_P1NAME + i);
  376. pName[i]->SetWindowText(p);
  377. }
  378. // get current autostart state
  379. m_bInitialState = IsAutoStart();
  380. // ((CButton *)GetDlgItem(IDC_AUTO))->SetCheck(m_bInitialState);
  381. return TRUE;
  382. }
  383. /****************************************************************************
  384. COptionsDlg::OnOK
  385. save contol settings
  386. ****************************************************************************/
  387. void COptionsDlg::OnOK()
  388. {
  389. RegEntry Reg(szRegPath);
  390. // save animation speed setting
  391. DWORD dwSpeed;
  392. int nStepSize;
  393. if (((CButton *)GetDlgItem(IDC_FAST))->GetCheck())
  394. {
  395. dwSpeed = IDC_FAST;
  396. nStepSize = 60;
  397. }
  398. else if (((CButton *)GetDlgItem(IDC_SLOW))->GetCheck())
  399. {
  400. dwSpeed = IDC_SLOW;
  401. nStepSize = 5;
  402. }
  403. else
  404. {
  405. dwSpeed = IDC_NORMAL;
  406. nStepSize = 15;
  407. }
  408. card c;
  409. c.SetStepSize(nStepSize);
  410. Reg.SetValue(regvalSpeed, dwSpeed);
  411. // save computer player names
  412. for (int i = 0; i < 3; i++)
  413. {
  414. CString sDefault, sEdit;
  415. sDefault.LoadString(IDS_P1NAME + i);
  416. GetDlgItemText(IDC_NAME1 + i, sEdit.GetBuffer(MAXNAMELENGTH+1),
  417. MAXNAMELENGTH+1);
  418. sEdit.ReleaseBuffer();
  419. if (sDefault == sEdit)
  420. Reg.DeleteValue(regvalPName[i]);
  421. else
  422. Reg.SetValue(regvalPName[i], sEdit);
  423. }
  424. // save autostart state
  425. // BOOL bState = ((CButton *)GetDlgItem(IDC_AUTO))->GetCheck();
  426. // if (bState != m_bInitialState)
  427. // IsAutoStart(TRUE); // toggle state
  428. EndDialog(IDOK);
  429. }
  430. /****************************************************************************
  431. COptionsDlg::IsAutoStart
  432. returns autostart state, and optionally toggles it. The bToggle
  433. parameter is FALSE by default.
  434. If bToggle is TRUE, this function returns the NEW state.
  435. ****************************************************************************/
  436. BOOL COptionsDlg::IsAutoStart(BOOL bToggle)
  437. {
  438. #ifdef USENETDDE
  439. DWORD dwAvail;
  440. WORD wItems;
  441. BOOL bStatus;
  442. CButton *check = (CButton *)GetDlgItem(IDC_AUTO);
  443. SetErrorMode(SEM_NOOPENFILEERRORBOX);
  444. HINSTANCE hinstNDDEAPI = LoadLibrary("NDDEAPI.DLL");
  445. if (hinstNDDEAPI <= (HINSTANCE)HINSTANCE_ERROR)
  446. {
  447. check->EnableWindow(FALSE);
  448. (CWnd *)GetDlgItem(IDC_AUTOGROUP)->EnableWindow(FALSE);
  449. return FALSE;
  450. }
  451. SGIPROC lpfnNDdeShareGetInfo =
  452. (SGIPROC) GetProcAddress(hinstNDDEAPI, "NDdeShareGetInfo");
  453. if (lpfnNDdeShareGetInfo == NULL)
  454. {
  455. check->EnableWindow(FALSE);
  456. (CWnd *)GetDlgItem(IDC_AUTOGROUP)->EnableWindow(FALSE);
  457. FreeLibrary(hinstNDDEAPI);
  458. return FALSE;
  459. }
  460. (*lpfnNDdeShareGetInfo)(NULL, szShareName, 2, m_buffer,
  461. sizeof(m_buffer), &dwAvail, &wItems);
  462. NDDESHAREINFO *pnddeInfo = (NDDESHAREINFO *)m_buffer;
  463. bStatus = (pnddeInfo->dwPermissions1 == 31);
  464. if (bToggle)
  465. {
  466. pnddeInfo->dwPermissions1 = (bStatus ? 15 : 31);
  467. SSIPROC lpfnNDdeShareSetInfo =
  468. (SSIPROC) GetProcAddress(hinstNDDEAPI, "NDdeShareSetInfo");
  469. UINT res = (*lpfnNDdeShareSetInfo)(NULL, szShareName, 2, m_buffer,
  470. sizeof(m_buffer), 0);
  471. if (res == NDDE_NO_ERROR)
  472. bStatus = !bStatus;
  473. }
  474. FreeLibrary(hinstNDDEAPI);
  475. return bStatus;
  476. #else
  477. return FALSE;
  478. #endif
  479. }
  480. /****************************************************************************
  481. CLocateDlg
  482. ****************************************************************************/
  483. BEGIN_MESSAGE_MAP( CLocateDlg, CModalDialog )
  484. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  485. ON_BN_CLICKED(IDC_LOCATEHELP, OnHelp)
  486. END_MESSAGE_MAP()
  487. /****************************************************************************
  488. CLocateDlg constructor
  489. ****************************************************************************/
  490. CLocateDlg::CLocateDlg(CWnd *pParent) : CModalDialog(DLG_LOCATE, pParent)
  491. {
  492. }
  493. /****************************************************************************
  494. CLocateDlg::OnInitDialog()
  495. Gray browse button if not available. Read old server name from .ini file.
  496. ****************************************************************************/
  497. BOOL CLocateDlg::OnInitDialog()
  498. {
  499. // BUGBUG -- uncomment this if we ever get a Chicago browse dialog
  500. // (no support for this in Win95)
  501. //
  502. // BROWSEPROC m_pWNetServerBrowseDialog = NULL;
  503. //
  504. // m_hmodNetDriver = WNetGetCaps(0xFFFF);
  505. //
  506. // if (m_hmodNetDriver >= HINSTANCE_ERROR)
  507. // m_pWNetServerBrowseDialog =
  508. // (BROWSEPROC)GetProcAddress(m_hmodNetDriver, MAKEINTRESOURCE(146));
  509. //
  510. // if (m_hmodNetDriver < HINSTANCE_ERROR || m_pWNetServerBrowseDialog == NULL)
  511. // ((CButton *)GetDlgItem(IDC_BROWSE))->EnableWindow(FALSE);
  512. CEdit *locname = (CEdit *)GetDlgItem(IDC_SERVERNAME);
  513. locname->LimitText(MAXCOMPUTERNAME);
  514. CString oldname;
  515. RegEntry Reg(szRegPath);
  516. TCHAR *poldname = oldname.GetBuffer(MAXCOMPUTERNAME+1);
  517. Reg.GetString(regvalServer, poldname, MAXCOMPUTERNAME+1);
  518. oldname.ReleaseBuffer();
  519. locname->SetWindowText(oldname);
  520. return TRUE;
  521. }
  522. /****************************************************************************
  523. CLocateDlg::OnOK()
  524. Store server name in .ini file.
  525. ****************************************************************************/
  526. void CLocateDlg::OnOK()
  527. {
  528. RegEntry Reg(szRegPath);
  529. GetDlgItemText(IDC_SERVERNAME, m_server.GetBuffer(MAXCOMPUTERNAME+1),
  530. MAXCOMPUTERNAME+1);
  531. m_server.ReleaseBuffer();
  532. Reg.SetValue(regvalServer, m_server);
  533. // ::WinHelp(m_hWnd, szHelpFileName, HELP_QUIT, 0);
  534. EndDialog(IDOK);
  535. }
  536. /****************************************************************************
  537. CLocateDlg::OnHelp()
  538. ****************************************************************************/
  539. void CLocateDlg::OnHelp()
  540. {
  541. // ::WinHelp(m_hWnd, szHelpFileName, HELP_CONTEXT, IDH_LOCATE);
  542. }
  543. /****************************************************************************
  544. CLocateDlg::OnBrowse()
  545. Call the winnet driver computer browse dialog.
  546. ****************************************************************************/
  547. void CLocateDlg::OnBrowse()
  548. {
  549. // BUGBUG -- uncomment if we ever get a Chicago browse dialog
  550. /* char buf[MAXCOMPUTERNAME+10]; // handle slashes, etc.
  551. BROWSEPROC m_pWNetServerBrowseDialog;
  552. m_pWNetServerBrowseDialog =
  553. (BROWSEPROC)GetProcAddress(m_hmodNetDriver, MAKEINTRESOURCE(146));
  554. (*m_pWNetServerBrowseDialog)( m_hWnd,
  555. "MRU_MSHearts",
  556. buf,
  557. MAXCOMPUTERNAME+10,
  558. 0L );
  559. char *p = buf;
  560. if (*p != '\0') // if server name is not empty
  561. {
  562. while (*p == '\\') // skip past leading backslashes
  563. p++;
  564. SetDlgItemText(IDC_SERVERNAME, p);
  565. OnOK();
  566. }
  567. else
  568. {
  569. // server name was empty, set focus back to edit field.
  570. ((CButton *)GetDlgItem(IDOK))->SetButtonStyle(BS_DEFPUSHBUTTON);
  571. ((CButton *)GetDlgItem(IDC_BROWSE))->SetButtonStyle(BS_PUSHBUTTON);
  572. ((CEdit *)GetDlgItem(IDC_SERVERNAME))->SetFocus();
  573. }
  574. */
  575. }