AfxCore.cpp
上传用户:zhanglf88
上传日期:2013-11-19
资源大小:6036k
文件大小:18k
源码类别:

金融证券系统

开发平台:

Visual C++

  1. // AfxCore.cpp : implementation of the AfxCore Functions
  2. //
  3. #include "stdafx.h"
  4. #include "AfxCore.h"
  5. #include "Dialogs.h"
  6. #include <complex>
  7. #ifdef AFX_INIT_SEG
  8. #pragma code_seg(AFX_INIT_SEG)
  9. #endif
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. void DDX_DateTimeCtrl(CDataExchange* pDX, int nIDC, CSPTime& value)
  15. {
  16. CTime tm = value.GetTime();
  17. DDX_DateTimeCtrl(pDX, nIDC,tm);
  18. value = tm.GetTime();
  19. }
  20. CFont * AfxSelectDCFont( CDC * pDC, int nHeight )
  21. {
  22. static CFont font;
  23. font.DeleteObject();
  24. #ifdef CLKLAN_ENGLISH_US
  25. if( nHeight <= 15 )
  26. {
  27. CFont *pFont = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT));
  28. return pDC->SelectObject( pFont );
  29. }
  30. else
  31. {
  32. return NULL;
  33. }
  34. #else
  35. font.CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0,
  36. DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH,
  37. "楷体" );
  38. return pDC->SelectObject( &font );
  39. #endif
  40. }
  41. UINT AfxRecalculateYield( int nDays, BOOL bReport )
  42. {
  43. // 计算市场年平均收益率
  44. double market_yield_average = 0.0, market_yield_d = 0.0;
  45. double market_dayyield_average = 0.0, market_dayyield_d = 0.0;
  46. CKData & kdayMain = AfxGetStockMain().GetKDataDay();
  47. if( kdayMain.GetSize() <= nDays )
  48. {
  49. if( bReport )
  50. AfxMessageBox( IDS_RECALYIELD_NOSZZS, MB_OK | MB_ICONINFORMATION );
  51. return 0;
  52. }
  53. BOOL bmarket_yield_ok = CalculateYieldYear( kdayMain, &market_yield_average, &market_yield_d, nDays );
  54. BOOL bmarket_dayyield_ok = CalculateYieldDay( kdayMain, &market_dayyield_average, &market_dayyield_d, nDays );
  55. if( !bmarket_yield_ok && !bmarket_dayyield_ok )
  56. {
  57. if( bReport )
  58. AfxMessageBox( IDS_RECALYIELD_NOSZZS, MB_OK | MB_ICONINFORMATION );
  59. }
  60. // 开始生成结果数据
  61. CStockContainer & container = AfxGetStockContainer();
  62. int nCount = 0;
  63. // 等待对话框
  64. CWaitDlg * pWait = NULL;
  65. if( bReport )
  66. {
  67. pWait = new CWaitDlg( AfxGetMainWnd() );
  68. pWait->SetProgressRange( 0, container.GetSize()-1 );
  69. }
  70. for( int i=0; i<container.GetSize(); i++ )
  71. {
  72. if( pWait )
  73. {
  74. pWait->SetProgress( i );
  75. if( pWait->WaitForCancel( ) )
  76. break;
  77. }
  78. CStockInfo & info = container.ElementAt(i);
  79. LONG stocktype = info.GetType();
  80. if( CStock::typeshIndex != stocktype && CStock::typeshA != stocktype && CStock::typeshB != stocktype
  81. && CStock::typeszIndex != stocktype && CStock::typeszA != stocktype && CStock::typeszB != stocktype )
  82. continue;
  83. CStock stock;
  84. stock.SetStockInfo( &info );
  85. AfxPrepareStockData(&AfxGetDB(),stock,CKData::ktypeDay,CKData::formatXDRup,CKData::mdtypeClose,TRUE,TRUE);
  86. CKData & kday = stock.GetKDataDay();
  87. info.m_fYield_average = (float)STKLIB_DATA_INVALID;
  88. info.m_fYield_stddev = (float)STKLIB_DATA_INVALID;
  89. info.m_fBeite = (float)STKLIB_DATA_INVALID;
  90. double yield_average = 0., yield_d = 0., beite = 0. ;
  91. if( CalculateYieldYear( kday, &yield_average, &yield_d, nDays ) )
  92. {
  93. info.m_fYield_average = (float)( 100. * yield_average );
  94. info.m_fYield_stddev = (float)( 100. * yield_d );
  95. if( bmarket_yield_ok && CalculateBeiteYear( kday, kdayMain, market_yield_average, market_yield_d, &beite, nDays ) )
  96. info.m_fBeite = (float)( beite );
  97. else if( bmarket_dayyield_ok && CalculateBeiteDay( kday, kdayMain, market_dayyield_average, market_dayyield_d, &beite, nDays ) )
  98. info.m_fBeite = (float)( beite );
  99. }
  100. else if( CalculateYieldDay( kday, &yield_average, &yield_d, nDays ) )
  101. {
  102. info.m_fYield_average = (float)( 100. * (pow(1+yield_average,STKLIB_DAYS_INONEYEAR)-1) );
  103. info.m_fYield_stddev = (float)( 100. * sqrt((double)STKLIB_DAYS_INONEYEAR) * yield_d );
  104. if( bmarket_dayyield_ok && CalculateBeiteDay( kday, kdayMain, market_dayyield_average, market_dayyield_d, &beite, nDays ) )
  105. info.m_fBeite = (float)( beite );
  106. }
  107. nCount ++;
  108. }
  109. // 保存到硬盘文件
  110. AfxGetDB().StoreBasetable( container );
  111. // 关闭等待对话框和目标文件
  112. if( pWait )
  113. {
  114. pWait->DestroyWindow();
  115. delete pWait;
  116. }
  117. return nCount;
  118. }
  119. // 快捷键
  120. void AfxExecuteAccelerator( UINT nAcce )
  121. {
  122. HWND hWnd = AfxGetMainFrame()->GetSafeHwnd();
  123. switch( nAcce )
  124. {
  125. case ACCE_01: // 热键F1
  126. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_REPORTDETAIL, 0 );
  127. break;
  128. case ACCE_02: // 热键F2
  129. ::PostMessage( hWnd, WM_COMMAND, ID_VIEW_SLIST, 0 );
  130. break;
  131. case ACCE_03: // 热键F3
  132. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_VIEWSZZS, 0 );
  133. break;
  134. case ACCE_04: // 热键F4
  135. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_VIEWSZNCZ, 0 );
  136. break;
  137. case ACCE_05: // 热键F5
  138. {
  139. CView * pView = AfxGetStaticDoc()->GetActiveView();
  140. if( pView && pView->IsKindOf( RUNTIME_CLASS(CGraphView) ) )
  141. ::PostMessage( hWnd, WM_COMMAND, ID_VIEW_REALTIME, 0 );
  142. else
  143. ::PostMessage( hWnd, WM_COMMAND, ID_VIEW_GRAPH, 0 );
  144. }
  145. break;
  146. case ACCE_06: // 热键F6
  147. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_GROUPSELF, 0 );
  148. break;
  149. case ACCE_07: // 热键F7
  150. ::PostMessage( hWnd, WM_COMMAND, ID_VIEW_MULTISORT, 0 );
  151. break;
  152. case ACCE_08: // 热键F8
  153. break;
  154. case ACCE_09: // 热键F9
  155. break;
  156. case ACCE_10: // 热键F10
  157. ::PostMessage( hWnd, WM_COMMAND, ID_VIEW_F10, 0 );
  158. break;
  159. case ACCE_1: // 上A报价
  160. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SHAA, 0 );
  161. break;
  162. case ACCE_2: // 上B报价
  163. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SHAB, 0 );
  164. break;
  165. case ACCE_3: // 深A报价
  166. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SZNA, 0 );
  167. break;
  168. case ACCE_4: // 深B报价
  169. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SZNB, 0 );
  170. break;
  171. case ACCE_5: // 上债报价
  172. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SHABOND, 0 );
  173. break;
  174. case ACCE_6: // 深债报价
  175. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SZNBOND, 0 );
  176. break;
  177. case ACCE_61: // 上A涨跌
  178. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SHAASORTDP, 0 );
  179. break;
  180. case ACCE_62: // 上B涨跌
  181. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SHABSORTDP, 0 );
  182. break;
  183. case ACCE_63: // 深A涨跌
  184. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SZNASORTDP, 0 );
  185. break;
  186. case ACCE_64: // 深B涨跌
  187. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SZNBSORTDP, 0 );
  188. break;
  189. case ACCE_65: // 上债涨跌
  190. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SHABONDSORTDP, 0 );
  191. break;
  192. case ACCE_66: // 深债涨跌
  193. ::PostMessage( hWnd, WM_COMMAND, ID_SLIST_SZNBONDSORTDP, 0 );
  194. break;
  195. case ACCE_71: // 上证信息
  196. break;
  197. case ACCE_72: // 深证信息
  198. break;
  199. case ACCE_73: // 券商信息
  200. break;
  201. case ACCE_81: // 上A综合
  202. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_MSSZAG, 0 );
  203. break;
  204. case ACCE_82: // 上B综合
  205. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_MSSZBG, 0 );
  206. break;
  207. case ACCE_83: // 深A综合
  208. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_MSSZNAG, 0 );
  209. break;
  210. case ACCE_84: // 深B综合
  211. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_MSSZNBG, 0 );
  212. break;
  213. case ACCE_85: // 上债综合
  214. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_MSSZZQ, 0 );
  215. break;
  216. case ACCE_86: // 深债综合
  217. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_MSSZNZQ, 0 );
  218. break;
  219. case ACCE_LBDK: // 量比多空
  220. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_LBDK, 0 );
  221. break;
  222. case ACCE_MMLD: // 买卖力道
  223. ::PostMessage( hWnd, WM_COMMAND, ID_REALTIME_MMLD, 0 );
  224. break;
  225. default:
  226. ASSERT( FALSE );
  227. }
  228. }
  229. AFX_STATIC_DATA const TCHAR _afxShellOpenFmt[] = _T("%s\shell\open\%s");
  230. AFX_STATIC_DATA const TCHAR _afxShellPrintFmt[] = _T("%s\shell\print\%s");
  231. AFX_STATIC_DATA const TCHAR _afxShellPrintToFmt[] = _T("%s\shell\printto\%s");
  232. AFX_STATIC_DATA const TCHAR _afxDefaultIconFmt[] = _T("%s\DefaultIcon");
  233. AFX_STATIC_DATA const TCHAR _afxShellNewFmt[] = _T("%s\ShellNew");
  234. #define DEFAULT_ICON_INDEX 0
  235. AFX_STATIC_DATA const TCHAR _afxIconIndexFmt[] = _T(",%d");
  236. AFX_STATIC_DATA const TCHAR _afxCommand[] = _T("command");
  237. AFX_STATIC_DATA const TCHAR _afxOpenArg[] = _T(" "%1"");
  238. AFX_STATIC_DATA const TCHAR _afxPrintArg[] = _T(" /p "%1"");
  239. AFX_STATIC_DATA const TCHAR _afxPrintToArg[] = _T(" /pt "%1" "%2" "%3" "%4"");
  240. AFX_STATIC_DATA const TCHAR _afxDDEArg[] = _T(" /dde");
  241. AFX_STATIC_DATA const TCHAR _afxDDEExec[] = _T("ddeexec");
  242. AFX_STATIC_DATA const TCHAR _afxDDEOpen[] = _T("[open("%1")]");
  243. AFX_STATIC_DATA const TCHAR _afxDDEPrint[] = _T("[print("%1")]");
  244. AFX_STATIC_DATA const TCHAR _afxDDEPrintTo[] = _T("[printto("%1","%2","%3","%4")]");
  245. AFX_STATIC_DATA const TCHAR _afxShellNewValueName[] = _T("NullFile");
  246. AFX_STATIC_DATA const TCHAR _afxShellNewValue[] = _T("");
  247. void AfxUnregisterShellFileTypes()
  248. {
  249. CString strPathName, strTemp;
  250. AfxGetModuleShortFileName(AfxGetInstanceHandle(), strPathName);
  251. CString strMainFrame;
  252. VERIFY(strMainFrame.LoadString( IDR_MAINFRAME ));
  253. CString strFilterExt, strFileTypeId, strFileTypeName;
  254. if (AfxExtractSubString( strFileTypeId,strMainFrame,
  255.    CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty())
  256. {
  257. // enough info to register it
  258. if (!AfxExtractSubString( strFileTypeName, strMainFrame,
  259.    CDocTemplate::regFileTypeName))
  260. strFileTypeName = strFileTypeId;    // use id name
  261. ASSERT(strFileTypeId.Find(' ') == -1);  // no spaces allowed
  262. strTemp.Format(_afxDefaultIconFmt, (LPCTSTR)strFileTypeId);
  263. AfxDeleteRegKey(strTemp);
  264. // pathshellopencommand = path filename
  265. strTemp.Format(_afxShellOpenFmt, (LPCTSTR)strFileTypeId,
  266. (LPCTSTR)_afxCommand);
  267. AfxDeleteRegKey(strTemp);
  268. // pathshellprintcommand = path /p filename
  269. strTemp.Format(_afxShellPrintFmt, (LPCTSTR)strFileTypeId,
  270. (LPCTSTR)_afxCommand);
  271. AfxDeleteRegKey(strTemp);
  272. // pathshellprinttocommand = path /pt filename printer driver port
  273. strTemp.Format(_afxShellPrintToFmt, (LPCTSTR)strFileTypeId,
  274. (LPCTSTR)_afxCommand);
  275. AfxDeleteRegKey(strTemp);
  276. AfxExtractSubString( strFilterExt, strMainFrame, CDocTemplate::filterExt);
  277. if (!strFilterExt.IsEmpty())
  278. {
  279. ASSERT(strFilterExt[0] == '.');
  280. LONG lSize = _MAX_PATH * 2;
  281. LONG lResult = ::RegQueryValue(HKEY_CLASSES_ROOT, strFilterExt,
  282. strTemp.GetBuffer(lSize), &lSize);
  283. strTemp.ReleaseBuffer();
  284. if (lResult != ERROR_SUCCESS || strTemp.IsEmpty() ||
  285. strTemp == strFileTypeId)
  286. {
  287. strTemp.Format(_afxShellNewFmt, (LPCTSTR)strFilterExt);
  288. AfxDeleteRegKey(strTemp);
  289. // no association for that suffix
  290. AfxDeleteRegKey(strFilterExt);
  291. }
  292. }
  293. }
  294. }
  295. void AfxRegisterShellFileTypes(BOOL bCompat)
  296. {
  297. CString strPathName, strTemp;
  298. AfxGetModuleShortFileName(AfxGetInstanceHandle(), strPathName);
  299. CString strOpenCommandLine = strPathName;
  300. CString strPrintCommandLine = strPathName;
  301. CString strPrintToCommandLine = strPathName;
  302. CString strDefaultIconCommandLine = strPathName;
  303. CString strMainFrame;
  304. VERIFY(strMainFrame.LoadString( IDR_MAINFRAME ));
  305. if (bCompat)
  306. {
  307. CString strIconIndex;
  308. HICON hIcon = ::ExtractIcon(AfxGetInstanceHandle(), strPathName, 1);
  309. if (hIcon != NULL)
  310. {
  311. strIconIndex.Format(_afxIconIndexFmt, 1);
  312. DestroyIcon(hIcon);
  313. }
  314. else
  315. {
  316. strIconIndex.Format(_afxIconIndexFmt, DEFAULT_ICON_INDEX);
  317. }
  318. strDefaultIconCommandLine += strIconIndex;
  319. }
  320. CString strFilterExt, strFileTypeId, strFileTypeName;
  321. if (AfxExtractSubString( strFileTypeId, strMainFrame,
  322. CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty())
  323. {
  324. // enough info to register it
  325. if (!AfxExtractSubString( strFileTypeName, strMainFrame, 
  326.    CDocTemplate::regFileTypeName))
  327. strFileTypeName = strFileTypeId;    // use id name
  328. ASSERT(strFileTypeId.Find(' ') == -1);  // no spaces allowed
  329. // first register the type ID of our server
  330. if (!AfxSetRegKey(strFileTypeId, strFileTypeName))
  331. return;       // just skip it
  332. if (bCompat)
  333. {
  334. // pathDefaultIcon = path,1
  335. strTemp.Format(_afxDefaultIconFmt, (LPCTSTR)strFileTypeId);
  336. if (!AfxSetRegKey(strTemp, strDefaultIconCommandLine))
  337. return;       // just skip it
  338. }
  339. // pathshellopencommand = path filename
  340. // pathshellprintcommand = path /p filename
  341. // pathshellprinttocommand = path /pt filename printer driver port
  342. strOpenCommandLine += _afxOpenArg;
  343. if (bCompat)
  344. {
  345. strPrintCommandLine += _afxPrintArg;
  346. strPrintToCommandLine += _afxPrintToArg;
  347. }
  348. // pathshellopencommand = path filename
  349. strTemp.Format(_afxShellOpenFmt, (LPCTSTR)strFileTypeId,
  350. (LPCTSTR)_afxCommand);
  351. if (!AfxSetRegKey(strTemp, strOpenCommandLine))
  352. return;       // just skip it
  353. if (bCompat)
  354. {
  355. // pathshellprintcommand = path /p filename
  356. strTemp.Format(_afxShellPrintFmt, (LPCTSTR)strFileTypeId,
  357. (LPCTSTR)_afxCommand);
  358. if (!AfxSetRegKey(strTemp, strPrintCommandLine))
  359. return;       // just skip it
  360. // pathshellprinttocommand = path /pt filename printer driver port
  361. strTemp.Format(_afxShellPrintToFmt, (LPCTSTR)strFileTypeId,
  362. (LPCTSTR)_afxCommand);
  363. if (!AfxSetRegKey(strTemp, strPrintToCommandLine))
  364. return;       // just skip it
  365. }
  366. AfxExtractSubString( strFilterExt, strMainFrame, CDocTemplate::filterExt);
  367. if (!strFilterExt.IsEmpty())
  368. {
  369. ASSERT(strFilterExt[0] == '.');
  370. LONG lSize = _MAX_PATH * 2;
  371. LONG lResult = ::RegQueryValue(HKEY_CLASSES_ROOT, strFilterExt,
  372. strTemp.GetBuffer(lSize), &lSize);
  373. strTemp.ReleaseBuffer();
  374. if (lResult != ERROR_SUCCESS || strTemp.IsEmpty() ||
  375. strTemp == strFileTypeId)
  376. {
  377. // no association for that suffix
  378. if (!AfxSetRegKey(strFilterExt, strFileTypeId))
  379. return;
  380. if (bCompat)
  381. {
  382. strTemp.Format(_afxShellNewFmt, (LPCTSTR)strFilterExt);
  383. (void)AfxSetRegKey(strTemp, _afxShellNewValue, _afxShellNewValueName);
  384. }
  385. }
  386. }
  387. }
  388. }
  389. #ifdef AFX_CORE3_SEG
  390. #pragma code_seg(AFX_CORE3_SEG)
  391. #endif
  392. AFX_STATIC void AFXAPI _AfxAppendFilterSuffix(CString& filter, OPENFILENAME& ofn,
  393.   CString *pstrDefaultExt)
  394. {
  395. CString strMainFrame;
  396. VERIFY(strMainFrame.LoadString( IDR_MAINFRAME ));
  397. CString strFilterExt, strFilterName;
  398. if (AfxExtractSubString(strFilterExt, strMainFrame, CDocTemplate::filterExt) &&
  399.  !strFilterExt.IsEmpty() &&
  400.  AfxExtractSubString(strFilterName, strMainFrame, CDocTemplate::filterName) &&
  401.  !strFilterName.IsEmpty())
  402. {
  403. // a file based document template - add to filter list
  404. ASSERT(strFilterExt[0] == '.');
  405. if (pstrDefaultExt != NULL)
  406. {
  407. // set the default extension
  408. *pstrDefaultExt = ((LPCTSTR)strFilterExt) + 1;  // skip the '.'
  409. ofn.lpstrDefExt = (LPTSTR)(LPCTSTR)(*pstrDefaultExt);
  410. ofn.nFilterIndex = ofn.nMaxCustFilter + 1;  // 1 based number
  411. }
  412. // add to filter
  413. filter += strFilterName;
  414. ASSERT(!filter.IsEmpty());  // must have a file type name
  415. filter += (TCHAR)'';  // next string please
  416. filter += (TCHAR)'*';
  417. filter += strFilterExt;
  418. filter += (TCHAR)'';  // next string please
  419. ofn.nMaxCustFilter++;
  420. }
  421. }
  422. BOOL AfxDoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog )
  423. {
  424. CFileDialog dlgFile(bOpenFileDialog);
  425. CString title;
  426. VERIFY(title.LoadString(nIDSTitle));
  427. dlgFile.m_ofn.Flags |= lFlags;
  428. CString strFilter;
  429. CString strDefault;
  430. _AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn,&strDefault);
  431. // append the "*.*" all files filter
  432. CString allFilter;
  433. VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
  434. strFilter += allFilter;
  435. strFilter += (TCHAR)'';   // next string please
  436. strFilter += _T("*.*");
  437. strFilter += (TCHAR)'';   // last string
  438. dlgFile.m_ofn.nMaxCustFilter++;
  439. dlgFile.m_ofn.lpstrFilter = strFilter;
  440. dlgFile.m_ofn.lpstrTitle = title;
  441. dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH);
  442. int nResult = dlgFile.DoModal();
  443. fileName.ReleaseBuffer();
  444. CString strPath = dlgFile.GetPathName( );
  445. return nResult == IDOK;
  446. }
  447. BOOL AfxDoSelectDirectory( CString & strSrc, HWND hWnd )
  448. {
  449. /* The Old Version */
  450. /*
  451. BROWSEINFO bi;
  452. char szWorkDir[MAX_PATH+1] = "";
  453. LPITEMIDLIST piidlRoot;
  454. SHGetSpecialFolderLocation(hWnd, CSIDL_DRIVES, &piidlRoot);
  455. ZeroMemory(&bi, sizeof(BROWSEINFO));
  456. bi.hwndOwner = hWnd;
  457. bi.pidlRoot = piidlRoot;
  458. bi.pszDisplayName = szWorkDir;
  459. CString strTitle;
  460. strTitle.LoadString( IDS_SELECT_DIRECTORY );
  461. if( GetSystemMetrics(SM_DBCSENABLED) )
  462. {
  463. bi.lpszTitle = strTitle.GetBuffer(strTitle.GetLength()+1);
  464. }
  465. bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
  466. LPITEMIDLIST piidlTarget = SHBrowseForFolder(&bi);
  467. if( piidlTarget )
  468. {
  469. ::SHGetPathFromIDList( piidlTarget, szWorkDir ) ;
  470. strSrc = szWorkDir;
  471. ::CoTaskMemFree( piidlTarget );
  472. return TRUE;
  473. }
  474. return FALSE;
  475. */
  476. /* The New Version Using CPathDialog */
  477. CString strCaption;
  478. CString strTitle;
  479. strCaption.LoadString( IDS_SELECT_DIRECTORY );
  480. strTitle.LoadString( IDS_SELECT_DIRECTORY );
  481. CPathDialog dlg(strCaption, strTitle, strSrc);
  482. if(dlg.DoModal()==IDOK
  483. && CPathDialog::MakeSurePathExists(dlg.GetPathName())==0 )
  484. {
  485. strSrc = dlg.GetPathName();
  486. return TRUE;
  487. }
  488. return FALSE;
  489. }
  490. CString AfxGetStrategyFileExt( )
  491. {
  492. CString strMainFrame;
  493. strMainFrame.LoadString( IDR_MAINFRAME );
  494. CString strExt;
  495. VERIFY( AfxExtractSubString( strExt, strMainFrame,CDocTemplate::filterExt) );
  496. ASSERT( !strExt.IsEmpty() && strExt[0] == '.');
  497. return strExt;
  498. }
  499. CString AfxGetApplicationName( )
  500. {
  501. CString strMainFrame;
  502. strMainFrame.LoadString( IDR_MAINFRAME );
  503. CString strName;
  504. VERIFY( AfxExtractSubString( strName, strMainFrame,CDocTemplate::windowTitle) );
  505. return strName;
  506. }
  507. CString AfxGetStockIndexReportTip( )
  508. {
  509. CString strResult;
  510. CString strSHTipFmt, strSZTipFmt;
  511. strSHTipFmt.LoadString( IDS_MAINFRAME_SHINDEXTIP );
  512. strSZTipFmt.LoadString( IDS_MAINFRAME_SZINDEXTIP );
  513. double dDevided = 100000000;
  514. #ifdef CLKLAN_ENGLISH_US
  515. dDevided = 1000000000;
  516. #endif
  517. CStockInfo infoMain, infoMainSZN;
  518. double dDiff;
  519. CString strSH, strSZ;
  520. if( AfxGetStockContainer().GetStockInfo( STKLIB_CODE_MAIN, &infoMain )
  521. && infoMain.GetDiff(&dDiff, infoMain.m_datetech ,1) )
  522. strSH.Format( strSHTipFmt, infoMain.m_fClose, dDiff, infoMain.m_fAmount/dDevided );
  523. if( AfxGetStockContainer().GetStockInfo( STKLIB_CODE_MAINSZN, &infoMainSZN )
  524. && infoMainSZN.GetDiff(&dDiff, infoMainSZN.m_datetech,1) )
  525. strSZ.Format( strSZTipFmt, infoMainSZN.m_fClose, dDiff, infoMainSZN.m_fAmount/dDevided );
  526. if( strSH.IsEmpty() && strSZ.IsEmpty() )
  527. return AfxGetApplicationName();
  528. strResult = strSH + "  " + strSZ;
  529. return strResult;
  530. }
  531. #ifdef AFX_CORE2_SEG
  532. #pragma code_seg(AFX_CORE2_SEG)
  533. #endif
  534. #ifdef AFX_TERM_SEG
  535. #pragma code_seg(AFX_TERM_SEG)
  536. #endif
  537. #ifdef AFX_INIT_SEG
  538. #pragma code_seg(AFX_INIT_SEG)
  539. #endif
  540. /////////////////////////////////////////////////////////////////////////////