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

金融证券系统

开发平台:

Visual C++

  1. // SListView.cpp : implementation of the CSListView class
  2. //
  3. #include "stdafx.h"
  4. #include "../StaticDoc.h"
  5. #include "SListView.h"
  6. #include "../Dialog/ListExportDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CSListView
  14. #define SLV_TIMER_REFRESH 1
  15. #define IDC_SLISTVIEW_GRID 100
  16. #define IDC_SLISTVIEW_WORKTAB 101
  17. #define SL_WORKTAB_CLASS 0
  18. #define SL_WORKTAB_A 1
  19. #define SL_WORKTAB_SZNB 2
  20. #define SL_WORKTAB_SHB 3
  21. #define SL_WORKTAB_BOND 4
  22. #define SL_WORKTAB_FUND 5
  23. #define SL_WORKTAB_RIGHT 6
  24. #define SL_WORKTAB_SELF 7
  25. #define SL_WORKTAB_GROUP 8
  26. #define SL_WORKTAB_DOMAIN 9
  27. IMPLEMENT_DYNCREATE(CSListView, CFormView)
  28. BEGIN_MESSAGE_MAP(CSListView, CFormView)
  29. //{{AFX_MSG_MAP(CSListView)
  30. ON_WM_CREATE()
  31. ON_WM_ERASEBKGND()
  32. ON_WM_DESTROY()
  33. ON_WM_TIMER()
  34. ON_COMMAND(ID_SLIST_EXPORTLIST, OnSlistExportlist)
  35. ON_WM_SIZE()
  36. ON_WM_SETFOCUS()
  37. ON_NOTIFY(TCN_SELCHANGE, IDC_SLISTVIEW_WORKTAB, OnSelchangeWorktab)
  38. //}}AFX_MSG_MAP
  39. // Standard printing commands
  40. ON_MESSAGE(WM_USER_GETVIEWTITLE, OnGetViewTitle)
  41. ON_MESSAGE(WM_USER_GETVIEWCMDID, OnGetViewCmdid)
  42. ON_MESSAGE(WM_USER_COLORCHANGE, OnColorChange)
  43. ON_MESSAGE(WM_APP_STKRECEIVER_DATA, OnStkReceiverData)
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CSListView construction/destruction
  47. CSListView::CSListView()
  48. : CFormView(CSListView::IDD)
  49. {
  50. m_nColSort = -1;
  51. m_bSortAscend = FALSE;
  52. m_bShouldUpdate = FALSE;
  53. m_bFirstUpdate = TRUE;
  54. }
  55. CSListView::~CSListView()
  56. {
  57. }
  58. void CSListView::SetFont( LPLOGFONT pLogFont )
  59. {
  60. ASSERT( pLogFont );
  61. HFONT hFont = ::CreateFontIndirect(pLogFont);
  62. m_Grid.SendMessage( WM_SETFONT, (WPARAM)hFont, MAKELPARAM(1, 0) );
  63. m_Grid.AutoSize( );
  64. DeleteObject(hFont);
  65. }
  66. void CSListView::GetSelectedStocks( CSPStringArray & astr )
  67. {
  68. CStockContainer & container = AfxGetSListStockContainer();
  69. container.Lock();
  70. int nTotalCount = m_Grid.GetSelectedCount();
  71. astr.RemoveAll();
  72. astr.SetSize( 0, nTotalCount > 10 ? nTotalCount : -1 );
  73. for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
  74. {
  75. BOOL bSelected = FALSE;
  76. for( int nCol=0; nCol<m_Grid.GetColumnCount(); nCol ++ )
  77. bSelected |= ( m_Grid.GetItemState(nRow,nCol) & GVIS_SELECTED );
  78. if( !bSelected )
  79. continue;
  80. LPARAM id = m_Grid.GetItemData(nRow,0);
  81. CStockInfo & info = container.GetStockInfoByID(id);
  82. astr.Add( info.GetStockCode() );
  83. }
  84. container.UnLock();
  85. }
  86. void CSListView::ExportList( CListExportDlg * pDlg )
  87. {
  88. ASSERT( pDlg );
  89. if( NULL == pDlg )
  90. return;
  91. int nColumnCount = m_Grid.GetColumnCount();
  92. ASSERT( nColumnCount > 0 );
  93. if( nColumnCount <= 0 )
  94. return;
  95. CStockContainer & container = AfxGetSListStockContainer();
  96. // Get Current StockList Time
  97. DWORD dwDate;
  98. CSPTime sptime;
  99. CSPTime time;
  100. if( container.GetCurrentType( NULL, NULL, &dwDate )
  101. && (-1 != dwDate || container.GetLatestTechDate(&dwDate))
  102. && sptime.FromStockTimeDay( dwDate ) )
  103. time = CSPTime( sptime.GetTime() );
  104. // Set Column
  105. CStringArray astrColumn;
  106. CUIntArray anWidth;
  107. CUIntArray anParams;
  108. for(int nCol = 0; nCol < nColumnCount; nCol ++ )
  109. {
  110. astrColumn.Add( m_Grid.GetItemText(0,nCol) );
  111. anWidth.Add( m_Grid.GetColumnWidth(nCol) );
  112. anParams.Add( m_Grid.GetItemData(0,nCol) );
  113. }
  114. if( ! pDlg->ExportBegin( astrColumn, anWidth, TRUE )
  115. || ! pDlg->ExportOpenTable( time, TRUE ) )
  116. return;
  117. container.Lock();
  118. // set Item
  119. int nCount = 0, nTotalCount = 0;
  120. if( pDlg->m_bItemAll )
  121. {
  122. nTotalCount = m_Grid.GetRowCount()-1;
  123. pDlg->SetProgressRange( 0, nTotalCount );
  124. for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
  125. {
  126. CStringArray astrItemText;
  127. astrItemText.SetSize( 0, nColumnCount+1 );
  128. LPARAM id = m_Grid.GetItemData(nRow,0);
  129. CStockInfo & info = container.GetStockInfoByID(id);
  130. for(nCol=0; nCol<anParams.GetSize(); nCol++ )
  131. {
  132. astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
  133. }
  134. pDlg->ExportAddItem( astrItemText );
  135. nCount ++;
  136. pDlg->SetProgress( nCount );
  137. }
  138. }
  139. else if( pDlg->m_bItemSelected )
  140. {
  141. nTotalCount = m_Grid.GetSelectedCount();
  142. pDlg->SetProgressRange( 0, nTotalCount );
  143. for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
  144. {
  145. BOOL bSelected = FALSE;
  146. for( nCol=0; nCol<m_Grid.GetColumnCount(); nCol ++ )
  147. bSelected |= ( m_Grid.GetItemState(nRow,nCol) & GVIS_SELECTED );
  148. if( !bSelected )
  149. continue;
  150. CStringArray astrItemText;
  151. astrItemText.SetSize( 0, nColumnCount+1 );
  152. LPARAM id = m_Grid.GetItemData(nRow,0);
  153. CStockInfo & info = container.GetStockInfoByID(id);
  154. for(nCol=0; nCol<anParams.GetSize(); nCol++ )
  155. {
  156. astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
  157. }
  158. pDlg->ExportAddItem( astrItemText );
  159. nCount ++;
  160. pDlg->SetProgress( nCount );
  161. }
  162. }
  163. else if( pDlg->m_bItemDefine )
  164. {
  165. nTotalCount = min(m_Grid.GetRowCount()-1,pDlg->m_nItemEnd) - max(1,pDlg->m_nItemBegin) + 1;
  166. pDlg->SetProgressRange( 0, nTotalCount );
  167. for( int nRow=max(1,pDlg->m_nItemBegin); nRow<=min(m_Grid.GetRowCount()-1,pDlg->m_nItemEnd); nRow++ )
  168. {
  169. CStringArray astrItemText;
  170. astrItemText.SetSize( 0, nColumnCount+1 );
  171. LPARAM id = m_Grid.GetItemData(nRow,0);
  172. CStockInfo & info = container.GetStockInfoByID(id);
  173. for(nCol=0; nCol<anParams.GetSize(); nCol++ )
  174. {
  175. astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
  176. }
  177. pDlg->ExportAddItem( astrItemText );
  178. nCount ++;
  179. pDlg->SetProgress( nCount );
  180. }
  181. }
  182. container.UnLock();
  183. pDlg->ExportFinish( );
  184. }
  185. void CSListView::RemoveSortSign( )
  186. {
  187. if( m_nColSort < 0 || m_nColSort >= m_Grid.GetColumnCount() )
  188. return;
  189. LPARAM lParam = m_Grid.GetItemData( 0, m_nColSort );
  190. CString strColTitle = AfxGetVariantName(lParam,TRUE);
  191. m_Grid.SetItemText( 0, m_nColSort, strColTitle );
  192. m_nColSort = -1;
  193. m_bSortAscend = FALSE;
  194. }
  195. void CSListView::SetSortSign( )
  196. {
  197. if( m_nColSort < 0 || m_nColSort >= m_Grid.GetColumnCount() )
  198. return;
  199. CString strPrefix, strColTitle;
  200. if( m_bSortAscend )
  201. strPrefix.LoadString( IDS_SLISTVIEW_UP );
  202. else
  203. strPrefix.LoadString( IDS_SLISTVIEW_DOWN );
  204. LPARAM lParam = m_Grid.GetItemData( 0, m_nColSort );
  205. strColTitle = AfxGetVariantName(lParam,TRUE);
  206. strColTitle = strPrefix + strColTitle;
  207. m_Grid.SetItemText( 0, m_nColSort, strColTitle );
  208. }
  209. void CSListView::SetSortVariant( UINT nVariant )
  210. {
  211. RemoveSortSign( );
  212. for( int nCol=0; nCol < m_Grid.GetColumnCount(); nCol++ )
  213. {
  214. LPARAM lParam = m_Grid.GetItemData( 0, nCol );
  215. if( (UINT)lParam == nVariant )
  216. {
  217. m_nColSort = nCol;
  218. m_bSortAscend = FALSE;
  219. SetSortSign();
  220. break;
  221. }
  222. }
  223. }
  224. void CSListView::SetCurrentStatus( int nType, LPCTSTR lpszDomain, DWORD dwDate )
  225. {
  226. AfxGetSListStockContainer().RetrieveFromStatic( nType, lpszDomain, AfxGetActiveStrategy(), dwDate );
  227. OnUpdate( NULL, UPDATE_HINT_SLISTVIEW, NULL );
  228. }
  229. void CSListView::StoreColumnOrderArray( )
  230. {
  231. // Now The CGridCtrl cannot drag and drop columns, so nothing to do
  232. // in this function
  233. return;
  234. }
  235. void CSListView::ResetColumns( )
  236. {
  237. CStockContainer & container = AfxGetSListStockContainer();
  238. container.Lock();
  239. //  its list control through a call to GetListCtrl().
  240. CSPDWordArray & auint = AfxGetProfile().GetSListColumnsShow( );
  241. ASSERT( auint.GetSize() > 0 );
  242. m_Grid.SetRedraw( FALSE );
  243. m_Grid.DeleteAllItems();
  244. m_Grid.SetRowCount(1);
  245. m_Grid.SetFixedRowCount(1);
  246. m_Grid.SetFixedColumnCount(1);
  247. m_Grid.SetColumnCount(auint.GetSize());
  248. for( int nCol=0; nCol<auint.GetSize(); nCol++ )
  249. {
  250. CString string = AfxGetVariantName(auint[nCol],TRUE);
  251. m_Grid.SetItemText( 0, nCol, string );
  252. m_Grid.SetItemData( 0, nCol, auint[nCol] );
  253. m_Grid.SetItemFormat( 0, nCol, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
  254. m_Grid.SetItemBkColour( 0, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  255. m_Grid.SetItemFgColour( 0, nCol, AfxGetProfile().GetColor(CColorClass::clrTitle) );
  256. }
  257. m_Grid.AutoSizeColumns();
  258. m_Grid.SetRedraw( TRUE, TRUE );
  259. m_Grid.Invalidate( );
  260. container.UnLock();
  261. }
  262. BOOL CSListView::SetAverageItem( CGridCtrl &grid, CStockContainer & container, BOOL bRedraw )
  263. {
  264. if( grid.GetColumnCount() <= 0 )
  265. return FALSE;
  266. container.Lock();
  267. // Get LPARAM
  268. CUIntArray anParams;
  269. anParams.SetSize( 0, grid.GetColumnCount() );
  270. for( int nCol=0; nCol < grid.GetColumnCount(); nCol ++ )
  271. {
  272. LPARAM lParam = grid.GetItemData( 0, nCol );
  273. anParams.Add( lParam );
  274. }
  275. // Set Average
  276. CStockInfo & infoAve = container.GetAverage( );
  277. CStockInfo & infoWAve = container.GetWeightAverage( );
  278. int iRowAve=0, iRowWAve=0;
  279. if( grid.GetRowCount() >= 3
  280. && grid.GetItemData(grid.GetRowCount()-2,0) == (LPARAM)ID_STOCKCNTN_AVERAGE
  281. && grid.GetItemData(grid.GetRowCount()-1,0) == (LPARAM)ID_STOCKCNTN_WEIGHTAVERAGE )
  282. {
  283. // get item id
  284. iRowAve = grid.GetRowCount()-2;
  285. iRowWAve = grid.GetRowCount()-1;
  286. }
  287. else
  288. {
  289. // Insert item
  290. iRowAve = grid.InsertRow( infoAve.GetStockName() );
  291. grid.SetItemData( iRowAve, 0, (LPARAM)ID_STOCKCNTN_AVERAGE );
  292. iRowWAve = grid.InsertRow( infoWAve.GetStockName() );
  293. grid.SetItemData( iRowWAve, 0, (LPARAM)ID_STOCKCNTN_WEIGHTAVERAGE );
  294. }
  295. // Set Average
  296. for( nCol=0; nCol<anParams.GetSize(); nCol++ )
  297. {
  298. grid.SetItemText( iRowAve, nCol, AfxGetVariantDispString(anParams[nCol], infoAve, NULL) );
  299. grid.SetItemBkColour( iRowAve, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  300. grid.SetItemFgColour( iRowAve, nCol, AfxGetVariantColor( anParams[nCol], infoAve ) );
  301. }
  302. // Set Weight Average
  303. for( nCol=0; nCol<anParams.GetSize(); nCol++ )
  304. {
  305. grid.SetItemText( iRowWAve, nCol, AfxGetVariantDispString(anParams[nCol], infoWAve, NULL) );
  306. grid.SetItemBkColour( iRowWAve, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  307. grid.SetItemFgColour( iRowWAve, nCol, AfxGetVariantColor( anParams[nCol], infoWAve ) );
  308. }
  309. // Set Param which is
  310. // SLH_MARKETVALUE, SLH_MARKETVALUEA, SLH_MARKETVALUEB and etc,  and more than SLH_USERDEFINE_BEGIN
  311. for( nCol=0; nCol < anParams.GetSize(); nCol ++ )
  312. {
  313. UINT lParam = anParams[nCol];
  314. if( SLH_DIFF == lParam || SLH_DIFFPERCENT == lParam || SLH_SCOPE == lParam
  315. || SLH_DIFFPERCENT_MIN5 == lParam || SLH_PE == lParam
  316. || SLH_PMAININCOME == lParam || SLH_RATIO_PCASH == lParam
  317. || SLH_RATIO_CURRENCY == lParam || SLH_RATIO_CHANGEHAND == lParam
  318. || SLH_RATIO_VOLUME == lParam || SLH_RS == lParam
  319. || SLH_MARKETVALUE == lParam || SLH_MARKETVALUEA == lParam
  320. || SLH_MARKETVALUEB == lParam || lParam >= SLH_USERDEFINE_BEGIN )
  321. {
  322. double dc = 0., average = 0.;
  323. double wsum = 0.0001, waverage = 0., w = 0.;
  324. for( int iRow=1; iRow<grid.GetRowCount(); iRow++ )
  325. {
  326. if( iRow == iRowAve || iRow == iRowWAve )
  327. continue;
  328. int id = grid.GetItemData(iRow,0);
  329. if( id < 0 || id > container.GetSize() )
  330. continue;
  331. CStockInfo & info = container.ElementAt(id);
  332. w = info.m_fShare_count_total;
  333. double dValue = 0.;
  334. if( !AfxGetVariantValue( lParam, info, &dValue, &container ) )
  335. continue;
  336. average = (average * dc + dValue)/(dc+1);
  337. waverage = (waverage * wsum + dValue * w)/(wsum+w);
  338. dc += 1;
  339. wsum += w;
  340. }
  341. CString strText;
  342. if( SLH_MARKETVALUE == lParam || SLH_MARKETVALUEA == lParam || SLH_MARKETVALUEB == lParam )
  343. {
  344. strText.Format( "%u", (DWORD)average );
  345. grid.SetItemText( iRowAve, nCol, strText );
  346. grid.SetItemText( iRowWAve, nCol, "-" );
  347. }
  348. else
  349. {
  350. strText.Format( "%.2f", average );
  351. grid.SetItemText( iRowAve, nCol, strText );
  352. strText.Format( "%.2f", waverage );
  353. grid.SetItemText( iRowWAve, nCol, strText );
  354. }
  355. }
  356. }
  357. container.UnLock();
  358. if( bRedraw )
  359. {
  360. grid.RedrawRow( iRowAve );
  361. grid.RedrawRow( iRowWAve );
  362. }
  363. return TRUE;
  364. }
  365. void CSListView::OnDblclkItem( int nStockIndex )
  366. {
  367. CStockContainer & container = AfxGetSListStockContainer();
  368. int nType;
  369. CSPString strDomain;
  370. DWORD dwDate = -1;
  371. if( nStockIndex >= 0 )
  372. {
  373. container.GetCurrentType( &nType, &strDomain, &dwDate );
  374. if( ( nType == CStockContainer::typeDomain && strDomain.IsEmpty() )
  375. || ( nType == CStockContainer::typeGroup && strDomain.IsEmpty() ) )
  376. {
  377. CStockInfo & info = container.GetStockInfoByID( nStockIndex );
  378. AfxShowSlist( nType, CString(info.GetStockName()), dwDate );
  379. }
  380. else
  381. AfxShowStockGraph( nStockIndex, TRUE );
  382. }
  383. }
  384. void CSListView::StockInfoChanged( LONG infoid, CStockInfo & info )
  385. {
  386. CStockContainer & container = AfxGetSListStockContainer();
  387. container.Lock();
  388. // update grid value
  389. for( int nRow=m_Grid.GetRowCount()-1; nRow >= 0; nRow-- )
  390. {
  391. LPARAM id = m_Grid.GetItemData(nRow,0);
  392. if( id == infoid )
  393. {
  394. for( int nCol=0; nCol<m_Grid.GetColumnCount(); nCol++ )
  395. {
  396. LPARAM lParam = m_Grid.GetItemData(0,nCol);
  397. m_Grid.SetItemText( nRow, nCol, AfxGetVariantDispString( lParam, info, &container ) );
  398. m_Grid.SetItemFgColour( nRow, nCol, AfxGetVariantColor( lParam, info ) );
  399. }
  400. m_Grid.RedrawRow( nRow );
  401. break;
  402. }
  403. }
  404. container.UnLock();
  405. }
  406. void CSListView::SendRequestQuote( BOOL bForced )
  407. {
  408. static int nLastStart = -1;
  409. static int nLastCount = -1;
  410. BOOL bQuoteTipSended = FALSE;
  411. BOOL bInTrade = CSPTime::InTradeTime(CSPTime::GetCurrentTime().GetTime(),900);
  412. CView * pView = AfxGetStaticDoc()->GetActiveView();
  413. if( bForced )
  414. {
  415. CStockContainer stocks;
  416. CStockInfo info;
  417. if( AfxGetStockContainer().GetStockInfo( STKLIB_CODE_MAIN, &info ) )
  418. stocks.Add(info);
  419. if( AfxGetStockContainer().GetStockInfo( STKLIB_CODE_MAINSZN, &info ) )
  420. stocks.Add(info);
  421. if( stocks.GetSize() > 0 )
  422. AfxGetStkReceiver().RequestStockData( CStock::dataReport, stocks.GetData(), stocks.GetSize(), 0, 0 );
  423. }
  424. if( bForced || pView == this )
  425. {
  426. CCellRange cr = m_Grid.GetVisibleNonFixedCellRange();
  427. int nStart = cr.GetMinRow() - 1;
  428. int nCount = cr.GetMaxRow() - cr.GetMinRow() + 1;
  429. CStockContainer & container = AfxGetSListStockContainer();
  430. container.Lock();
  431. if( nStart >= 0 && nCount > 0 && container.GetSize() > 0 && (bInTrade || bForced || nLastStart != nStart || nLastCount != nCount) )
  432. {
  433. nLastStart = nStart;
  434. nLastCount = nCount;
  435. AfxGetStkReceiver().RequestStockData( CStock::dataReport, container.GetData()+nStart, min(nCount,container.GetSize()-nStart), 0, 0 );
  436. bQuoteTipSended = (0 == nStart && nCount >= 9);
  437. }
  438. container.UnLock();
  439. }
  440. if( bInTrade )
  441. {
  442. // 预警系统所需股票行情刷新
  443. CAlarmCondContainer & conds = AfxGetProfile().GetAlarmCondContainer();
  444. CStockContainer stocks;
  445. stocks.SetSize( 0, conds.GetSize() + 5 );
  446. for( int i=0; i<conds.GetSize(); i++ )
  447. {
  448. ALARMCOND cond = conds.GetAt(i);
  449. CStockInfo info;
  450. if( AfxGetStockContainer().GetStockInfo( cond.m_szCode, &info ) )
  451. stocks.Add( info );
  452. }
  453. CStockInfo infoMain, infoMainSzn;
  454. if( AfxGetStockContainer().GetStockInfo( STKLIB_CODE_MAIN, &infoMain )
  455. && AfxGetStockContainer().GetStockInfo( STKLIB_CODE_MAINSZN, &infoMainSzn ) )
  456. {
  457. stocks.Add( infoMain );
  458. stocks.Add( infoMainSzn );
  459. }
  460. //  行情QuoteTip 需要行情数据
  461. if( !bQuoteTipSended )
  462. {
  463. CStockContainer & container = AfxGetSListStockContainer();
  464. container.Lock();
  465. for( int i=0; i<9 && i<container.GetSize(); i++ )
  466. stocks.Add( container.ElementAt(i) );
  467. container.UnLock();
  468. }
  469. if( stocks.GetSize() > 0 )
  470. AfxGetStkReceiver().RequestStockData( CStock::dataReport, stocks.GetData(), stocks.GetSize(), 0, 0 );
  471. }
  472. }
  473. /////////////////////////////////////////////////////////////////////////////
  474. // CSListView overrides
  475. BOOL CSListView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
  476. {
  477. // TODO: Add your specialized code here and/or call the base class
  478. return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  479. }
  480. BOOL CSListView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  481. {
  482. // TODO: Add your specialized code here and/or call the base class
  483. if( ::IsWindow(m_Grid.GetSafeHwnd()) )
  484. if( m_Grid.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  485. return TRUE;
  486. return CFormView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  487. }
  488. int CALLBACK ItemCompareFunc(LPARAM lParam1, LPARAM lParam2, 
  489. LPARAM lParamSort)
  490. {
  491. if( lParam1 < 0 && lParam2 < 0 )
  492. return 0;
  493. if( lParam1 < 0 )
  494. return 1;
  495. if( lParam2 < 0 )
  496. return -1;
  497. CStockContainer & container = AfxGetSListStockContainer();
  498. if( lParam1 >= container.GetSize() || lParam2 >= container.GetSize() )
  499. {
  500. ASSERT( FALSE );
  501. return 0;
  502. }
  503. CStockInfo &s1 = container.ElementAt(lParam1);
  504. CStockInfo &s2 = container.ElementAt(lParam2);
  505. return CStockContainer::SortFunction( &s1, &s2 );
  506. }
  507. BOOL CSListView::PreTranslateMessage(MSG* pMsg) 
  508. {
  509. // TODO: Add your specialized code here and/or call the base class
  510. if( m_Grid.GetSafeHwnd() == pMsg->hwnd )
  511. {
  512. if( WM_LBUTTONDBLCLK == pMsg->message
  513. || ( WM_KEYDOWN == pMsg->message && VK_RETURN == pMsg->wParam ) )
  514. {
  515. int nColumnCount = m_Grid.GetColumnCount();
  516. int nRowCount = m_Grid.GetRowCount();
  517. if( nColumnCount <=0 || nRowCount <= 0 )
  518. return CFormView::PreTranslateMessage(pMsg);
  519. CRect rectCell;
  520. m_Grid.GetCellRect(0,0,&rectCell);
  521. CPoint pt = pMsg->pt;
  522. ::ScreenToClient( m_Grid.GetSafeHwnd(), &pt );
  523. if( pt.y >= rectCell.top && pt.y < rectCell.bottom )
  524. return CFormView::PreTranslateMessage(pMsg);
  525. int nSelRow = m_Grid.GetFocusCell().row;
  526. if( nSelRow >= 1 && nSelRow < m_Grid.GetRowCount() )
  527. {
  528. int id = m_Grid.GetItemData(nSelRow,0);
  529. OnDblclkItem( id );
  530. }
  531. }
  532. else if( WM_LBUTTONUP == pMsg->message )
  533. {
  534. int nColumnCount = m_Grid.GetColumnCount();
  535. int nRowCount = m_Grid.GetRowCount();
  536. if( nColumnCount <=0 || nRowCount <= 0 )
  537. return CFormView::PreTranslateMessage(pMsg);
  538. CRect rectCell;
  539. m_Grid.GetCellRect(0,0,&rectCell);
  540. CPoint pt = pMsg->pt;
  541. ::ScreenToClient( m_Grid.GetSafeHwnd(), &pt );
  542. if( pt.y < rectCell.top || pt.y >= rectCell.bottom )
  543. return CFormView::PreTranslateMessage(pMsg);
  544. CCellID cell = m_Grid.GetFocusCell();
  545. if( cell.col >=0 && cell.col < nColumnCount )
  546. {
  547. BOOL bSortAscendNew = ( m_nColSort == cell.col ? !m_bSortAscend : FALSE );
  548. RemoveSortSign( );
  549. m_nColSort = cell.col;
  550. m_bSortAscend = bSortAscendNew;
  551. SetSortSign( );
  552. LPARAM lParam = m_Grid.GetItemData( 0, cell.col );
  553. if( lParam >= 0 )
  554. {
  555. CStockContainer & container = AfxGetSListStockContainer();
  556. container.Lock();
  557. //if( container.Sort( lParam, m_bSortAscend ) )
  558. // OnUpdate( NULL, UPDATE_HINT_SLISTVIEW, NULL );
  559. CStockContainer::m_pSortContainer = &container;
  560. container.m_nSortVariantID = lParam;
  561. container.m_bSortAscend = m_bSortAscend;
  562. m_Grid.SortItems( ItemCompareFunc, 0, TRUE );
  563. container.UnLock();
  564. }
  565. m_Grid.Invalidate( );
  566. }
  567. }
  568. }
  569. return CFormView::PreTranslateMessage(pMsg);
  570. }
  571. void CSListView::DoDataExchange(CDataExchange* pDX)
  572. {
  573. CFormView::DoDataExchange(pDX);
  574. //{{AFX_DATA_MAP(CSListView)
  575. //}}AFX_DATA_MAP
  576. }
  577. void CSListView::OnInitialUpdate()
  578. {
  579. CFormView::OnInitialUpdate();
  580. // SetColumn
  581. ResetColumns( );
  582. // Create Tab
  583. if( !::IsWindow( m_wndWorkTab.GetSafeHwnd() )
  584. && m_wndWorkTab.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this, IDC_SLISTVIEW_WORKTAB) )
  585. {
  586. CString strName;
  587. strName.LoadString( IDS_SLISTVIEW_CLASS );
  588. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_CLASS);
  589. strName.LoadString( IDS_SLISTVIEW_A );
  590. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_A);
  591. strName.LoadString( IDS_SLISTVIEW_SHB );
  592. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_SHB);
  593. strName.LoadString( IDS_SLISTVIEW_SZNB );
  594. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_SZNB);
  595. strName.LoadString( IDS_SLISTVIEW_BOND );
  596. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_BOND);
  597. strName.LoadString( IDS_SLISTVIEW_FUND );
  598. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_FUND);
  599. strName.LoadString( IDS_SLISTVIEW_RIGHT );
  600. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_RIGHT);
  601. strName.LoadString( IDS_SLISTVIEW_SELF );
  602. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_SELF);
  603. strName.LoadString( IDS_SLISTVIEW_GROUP );
  604. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_GROUP);
  605. strName.LoadString( IDS_SLISTVIEW_DOMAIN );
  606. m_wndWorkTab.Addtab( &m_Grid, strName, SL_WORKTAB_DOMAIN);
  607. m_wndWorkTab.SetSelectTabColor( AfxGetProfile().GetColor(CColorClass::clrSListBK),
  608. AfxGetProfile().GetColor(CColorClass::clrTitle) );
  609. m_wndWorkTab.SetActualTitle(FALSE);
  610. m_wndWorkTab.SetCurtab( SL_WORKTAB_SELF );
  611. CFont font;
  612. font.CreateStockObject (DEFAULT_GUI_FONT);
  613. m_wndWorkTab.SetFont( &font );
  614. // m_Grid No HScrollBar
  615. m_Grid.SetOuterHScrollBar( TRUE, m_wndWorkTab.GetSafeHwnd() );
  616. }
  617. }
  618. void CSListView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
  619. {
  620. // TODO: Add your specialized code here and/or call the base class
  621. if( UPDATE_HINT_SLISTVIEW != lHint )
  622. return;
  623. if( IsWindowVisible() )
  624. SetFocus( );
  625. int nColumnCount = m_Grid.GetColumnCount();
  626. if( nColumnCount <= 0 )
  627. return;
  628. if( GetParentFrame()->GetSafeHwnd() != AfxGetMainFrame()->GetActiveFrame()->GetSafeHwnd() )
  629. {
  630. m_bShouldUpdate = TRUE;
  631. return;
  632. }
  633. m_bShouldUpdate = FALSE;
  634. CStockContainer & container = AfxGetSListStockContainer();
  635. container.Lock();
  636. m_Grid.DeleteNonFixedRows();
  637. // Progress
  638. CMainFrame * pMainFrame = AfxGetMainFrame();
  639. if( pMainFrame )
  640. {
  641. pMainFrame->ShowProgressBar( );
  642. pMainFrame->SetProgress( 0 );
  643. pMainFrame->SetMessageText( IDS_MAINFRAME_WAITING );
  644. }
  645. CUIntArray anParams;
  646. anParams.SetSize( 0, nColumnCount );
  647. for( int nCol=0; nCol < nColumnCount; nCol ++ )
  648. {
  649. LPARAM lParam = m_Grid.GetItemData( 0, nCol );
  650. anParams.Add( lParam );
  651. }
  652. CRect rectClient;
  653. GetClientRect( &rectClient );
  654. int nPageCount = 1 + rectClient.Height() / abs(m_Grid.GetFixedRowHeight()) + 1;
  655. for( int i=0; i<container.GetSize(); i++ )
  656. {
  657. CStockInfo & info = container.GetStockInfoByID(i);
  658. int nRow = m_Grid.InsertRow( info.GetStockName() );
  659. m_Grid.SetItemData( nRow, 0, i );
  660. for( int nCol=0; nCol<anParams.GetSize(); nCol++ )
  661. {
  662. m_Grid.SetItemFormat( nRow, nCol, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
  663. m_Grid.SetItemText( nRow, nCol, AfxGetVariantDispString( anParams[nCol], info, &container ) );
  664. m_Grid.SetItemBkColour( nRow, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  665. m_Grid.SetItemFgColour( nRow, nCol, AfxGetVariantColor( anParams[nCol], info ) );
  666. if( anParams[nCol] == SLH_DATE )
  667. m_Grid.SetColumnWidth( nCol, 80 );
  668. }
  669. if( i == nPageCount+5 )
  670. {
  671. m_Grid.Invalidate( );
  672. MSG msg;
  673. while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) )
  674. AfxGetApp()->PumpMessage();
  675. }
  676. if( pMainFrame )
  677. pMainFrame->SetProgress( 100*i/container.GetSize() );
  678. }
  679. // Set Average and Weight Average
  680. SetAverageItem( m_Grid, container, FALSE );
  681. // Sort If Needed
  682. if( -1 != m_nColSort )
  683. {
  684. LPARAM lParam = m_Grid.GetItemData( 0, m_nColSort );
  685. if( lParam >= 0 )
  686. {
  687. CStockContainer::m_pSortContainer = &container;
  688. container.m_nSortVariantID = lParam;
  689. container.m_bSortAscend = m_bSortAscend;
  690. m_Grid.SortItems( ItemCompareFunc, 0, TRUE );
  691. }
  692. }
  693. if( pMainFrame )
  694. {
  695. pMainFrame->SetProgress( 100 );
  696. pMainFrame->HideProgressBar( );
  697. pMainFrame->SetMessageText( IDS_MAINFRAME_FINISHED );
  698. pMainFrame->SetMessageText( IDS_HELPTIP_SLIST );
  699. }
  700. if( m_bFirstUpdate )
  701. m_Grid.AutoSizeColumns( );
  702. else
  703. m_Grid.SetColumnWidth( 0, 80 );
  704. m_bFirstUpdate = FALSE;
  705. m_Grid.Invalidate( );
  706. SendRequestQuote(TRUE);
  707. container.UnLock();
  708. }
  709. /////////////////////////////////////////////////////////////////////////////
  710. // CSListView diagnostics
  711. #ifdef _DEBUG
  712. void CSListView::AssertValid() const
  713. {
  714. CFormView::AssertValid();
  715. }
  716. void CSListView::Dump(CDumpContext& dc) const
  717. {
  718. CFormView::Dump(dc);
  719. }
  720. #endif //_DEBUG
  721. /////////////////////////////////////////////////////////////////////////////
  722. // CSListView message handlers
  723. int CSListView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  724. {
  725. if (CFormView::OnCreate(lpCreateStruct) == -1)
  726. return -1;
  727. // Create GridCtrl
  728. CRect rect;
  729. GetClientRect(rect);
  730. if( !m_Grid.Create(rect, this, IDC_SLISTVIEW_GRID, WS_CHILD|WS_BORDER|WS_TABSTOP|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL) )
  731. {
  732. TRACE( "CSListView::OnCreate(...), Create m_Grid Error.n" );
  733. return -1;
  734. }
  735. // fill it up with stuff
  736. m_Grid.SetEditable(FALSE);
  737. m_Grid.SetListMode(TRUE);
  738. m_Grid.SetHeaderSort( FALSE ); 
  739. m_Grid.SetSingleRowSelection(FALSE);
  740. m_Grid.EnableDragAndDrop(TRUE);
  741. m_Grid.SetGridLines( GVL_NONE );
  742. m_Grid.EnableTitleTips( TRUE );
  743. m_Grid.SetRowResize( TRUE );
  744. m_Grid.SetColumnResize( TRUE );
  745. m_Grid.SetBkColor( AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  746. m_Grid.SetTextBkColor( AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  747. m_Grid.SetSelectedBkColor(AfxGetProfile().GetColor(CColorClass::clrSListSelected));
  748. LOGFONT lf;
  749. memset( &lf, 0, sizeof(lf) );
  750. AfxGetProfile().GetFontSListView( &lf );
  751. SetFont( &lf );
  752. // 实时行情刷新
  753. AfxGetStkReceiver().AddRcvDataWnd( GetSafeHwnd() );
  754. SetTimer( SLV_TIMER_REFRESH, 3000, NULL );
  755. return 0;
  756. }
  757. void CSListView::OnDestroy() 
  758. {
  759. // 停止行情刷新通知消息
  760. AfxGetStkReceiver().RemoveRcvDataWnd( GetSafeHwnd() );
  761. KillTimer( SLV_TIMER_REFRESH );
  762. StoreColumnOrderArray( );
  763. CFormView::OnDestroy();
  764. }
  765. void CSListView::OnTimer(UINT nIDEvent) 
  766. {
  767. if( SLV_TIMER_REFRESH == nIDEvent )
  768. {
  769. SendRequestQuote(FALSE);
  770. }
  771. CFormView::OnTimer(nIDEvent);
  772. }
  773. void CSListView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
  774. {
  775. // TODO: Add your specialized code here and/or call the base class
  776. CMainFrame * pFrame = AfxGetMainFrame( );
  777. if( pFrame )
  778. pFrame->SetMessageText( bActivate ? IDS_HELPTIP_SLIST : AFX_IDS_IDLEMESSAGE );
  779. if( bActivate && m_bShouldUpdate )
  780. {
  781. OnUpdate( NULL, UPDATE_HINT_SLISTVIEW, NULL );
  782. m_bShouldUpdate = FALSE;
  783. }
  784. CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
  785. if( ::IsWindow(m_wndWorkTab.GetSafeHwnd()) )
  786. {
  787. m_wndWorkTab.Invalidate( );
  788. m_wndWorkTab.UpdateWindow( );
  789. }
  790. }
  791. void CSListView::OnSelchangeWorktab(NMHDR* pNMHDR, LRESULT* pResult) 
  792. {
  793. int nCur = m_wndWorkTab.GetCurtab();
  794. CRect rect = m_wndWorkTab.GetTabRect( nCur );
  795. CMenu menu;
  796. switch( nCur )
  797. {
  798. case SL_WORKTAB_CLASS:
  799. if( menu.LoadMenu( IDR_MENU_SLISTBARCLASS ) )
  800. {
  801. CMenu* pPopupMenu = menu.GetSubMenu(0);
  802. if( pPopupMenu )
  803. pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON , rect.left+3, rect.top+6, AfxGetMainFrame() );
  804. }
  805. break;
  806. case SL_WORKTAB_A:
  807. SetCurrentStatus( CStockContainer::typeA, NULL, -1 );
  808. break;
  809. case SL_WORKTAB_SHB:
  810. SetCurrentStatus( CStockContainer::typeClassShab, NULL, -1 );
  811. break;
  812. case SL_WORKTAB_SZNB:
  813. SetCurrentStatus( CStockContainer::typeClassSznb, NULL, -1 );
  814. break;
  815. case SL_WORKTAB_BOND:
  816. SetCurrentStatus( CStockContainer::typeBond, NULL, -1 );
  817. break;
  818. case SL_WORKTAB_FUND:
  819. SetCurrentStatus( CStockContainer::typeFund, NULL, -1 );
  820. break;
  821. case SL_WORKTAB_RIGHT:
  822. SetCurrentStatus( CStockContainer::typeRight, NULL, -1 );
  823. break;
  824. case SL_WORKTAB_SELF:
  825. {
  826. CString strSelf;
  827. strSelf.LoadString( IDS_DOMAIN_SELF );
  828. SetCurrentStatus( CStockContainer::typeGroup, strSelf, -1 );
  829. }
  830. break;
  831. case SL_WORKTAB_GROUP:
  832. if( menu.LoadMenu( IDR_MENU_SLISTBARGROUP ) )
  833. {
  834. CMenu* pPopupMenu = menu.GetSubMenu(0);
  835. if( pPopupMenu )
  836. pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON , rect.left+3, rect.top+6, AfxGetMainFrame() );
  837. }
  838. break;
  839. case SL_WORKTAB_DOMAIN:
  840. if( menu.LoadMenu( IDR_MENU_SLISTBARDOMAIN ) )
  841. {
  842. CMenu* pPopupMenu = menu.GetSubMenu(0);
  843. if( pPopupMenu )
  844. pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON , rect.left+3, rect.top+6, AfxGetMainFrame() );
  845. }
  846. break;
  847. default:;
  848. }
  849. *pResult = 0;
  850. }
  851. LRESULT CSListView::OnGetViewTitle(WPARAM wParam, LPARAM lParam)
  852. {
  853. CString strTitle;
  854. strTitle.LoadString( IDS_TITLE_SLISTVIEW );
  855. lstrcpyn((LPTSTR)lParam, (LPCTSTR)strTitle, wParam);
  856. if ((int)wParam > strTitle.GetLength())
  857. wParam = strTitle.GetLength();
  858. return wParam;
  859. }
  860. LRESULT CSListView::OnGetViewCmdid(WPARAM wParam, LPARAM lParam)
  861. {
  862. if( lParam )
  863. *((LPARAM *)lParam) = ID_VIEW_SLIST;
  864. return 0L;
  865. }
  866. LRESULT CSListView::OnColorChange(WPARAM wParam, LPARAM lParam)
  867. {
  868. m_wndWorkTab.SetSelectTabColor( AfxGetProfile().GetColor(CColorClass::clrSListBK),
  869. AfxGetProfile().GetColor(CColorClass::clrTitle) );
  870. m_wndWorkTab.Invalidate( );
  871. m_Grid.SetBkColor( AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  872. m_Grid.SetTextBkColor( AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  873. m_Grid.SetSelectedBkColor(AfxGetProfile().GetColor(CColorClass::clrSListSelected));
  874. OnUpdate( NULL, UPDATE_HINT_SLISTVIEW, NULL );
  875. return 0L;
  876. }
  877. LRESULT CSListView::OnStkReceiverData(WPARAM wParam, LPARAM lParam)
  878. {
  879. PCOMMPACKET pCommPacket = (PCOMMPACKET)lParam;
  880. switch( wParam )
  881. {
  882. case CStock::dataReport:
  883. if( pCommPacket && CStock::dataReport == pCommPacket->m_dwDataType 
  884. && pCommPacket->m_dwCount > 0 )
  885. {
  886. CStockContainer & container = AfxGetSListStockContainer();
  887. // 如果当前股票列表显示的日期不是今天的,返回,不做刷新
  888. DWORD dwDate = -1;;
  889. AfxGetSListStockContainer().GetCurrentType(NULL,NULL,&dwDate);
  890. if( -1 != dwDate && dwDate != CSPTime(pCommPacket->m_pReport[0].m_time).ToStockTimeDay() )
  891. return 0L;
  892. container.Lock();
  893. // 刷新数据
  894. BOOL bNeedReSort = FALSE;
  895. for( DWORD i=0; i<pCommPacket->m_dwCount; i++ )
  896. {
  897. int id = 0;
  898. if( container.GetStockInfo( pCommPacket->m_pReport[i].m_szCode, NULL, &id ) )
  899. {
  900. CStockInfo & info = container.ElementAt(id);
  901. UpdateStockInfoByREPORT( info, &(pCommPacket->m_pReport[i]) );
  902. StockInfoChanged( id, info );
  903. bNeedReSort = TRUE;
  904. }
  905. }
  906. // 统计平均值刷新
  907. if( bNeedReSort )
  908. {
  909. container.SetAverage( );
  910. SetAverageItem( m_Grid, container, TRUE );
  911. }
  912. // 重新排序
  913. if( -1 != m_nColSort && bNeedReSort )
  914. {
  915. LPARAM lParam = m_Grid.GetItemData( 0, m_nColSort );
  916. if( lParam >= 0 )
  917. {
  918. CStockContainer::m_pSortContainer = &container;
  919. container.m_nSortVariantID = lParam;
  920. container.m_bSortAscend = m_bSortAscend;
  921. m_Grid.SortItems( ItemCompareFunc, 0, TRUE );
  922. }
  923. m_Grid.Invalidate( );
  924. }
  925. container.UnLock();
  926. }
  927. break;
  928. }
  929. return 0L;
  930. }
  931. BOOL CSListView::OnEraseBkgnd(CDC* pDC) 
  932. {
  933. // TODO: Add your message handler code here and/or call default
  934. if( pDC && pDC->IsKindOf(RUNTIME_CLASS(CDC)) )
  935. {
  936. CRect rect;
  937. GetClientRect( &rect );
  938. CBrush brush;
  939. brush.CreateSolidBrush( AfxGetProfile().GetColor(CColorClass::clrSListBK) );
  940. pDC->FillRect( &rect, &brush );
  941. return TRUE;
  942. }
  943. return CFormView::OnEraseBkgnd(pDC);
  944. }
  945. void CSListView::OnSize(UINT nType, int cx, int cy) 
  946. {
  947. CSize sizeTotal( cx, cy );
  948. SetScaleToFitSize( sizeTotal );
  949. CFormView::OnSize(nType, cx, cy);
  950. CRect rect;
  951. GetClientRect(rect);
  952. /* if( ::IsWindow(m_Grid.GetSafeHwnd()) )
  953. {
  954. m_Grid.MoveWindow(rect);
  955. }
  956. */
  957. if( ::IsWindow(m_wndWorkTab.GetSafeHwnd()) )
  958. {
  959. rect.InflateRect(1,0,0,1);
  960. m_wndWorkTab.MoveWindow(rect);
  961. m_wndWorkTab.Invalidate( );
  962. m_wndWorkTab.UpdateWindow( );
  963. }
  964. }
  965. void CSListView::OnSetFocus(CWnd* pOldWnd) 
  966. {
  967. CFormView::OnSetFocus(pOldWnd);
  968. // TODO: Add your message handler code here
  969. m_Grid.SetFocus();
  970. if( !m_Grid.GetFocusCell().IsValid()
  971. && m_Grid.GetRowCount() > 1 && m_Grid.GetColumnCount() > 1 )
  972. {
  973. m_Grid.SetFocusCell( 1, 1 );
  974. for( int nCol=0; nCol<m_Grid.GetColumnCount(); nCol ++ )
  975. m_Grid.SetItemState(1,nCol,m_Grid.GetItemState(1,nCol) | GVIS_SELECTED);
  976. }
  977. }
  978. void CSListView::OnSlistExportlist() 
  979. {
  980. // TODO: Add your command handler code here
  981. CListExportDlg dlg;
  982. dlg.m_nItemMax = m_Grid.GetRowCount();
  983. if( m_Grid.GetSelectedCount() > 0 )
  984. {
  985. dlg.m_bItemAll = FALSE;
  986. dlg.m_bItemSelected = TRUE;
  987. dlg.m_bItemDefine = FALSE;
  988. }
  989. dlg.DoModal( );
  990. }