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

金融证券系统

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "StkUI.h"
  5. #include "MainFrm.h"
  6. #include "ChildFrm.h"
  7. #include "StaticDoc.h"
  8. #include "View/SimuView.h"
  9. #include "View/SListView.h"
  10. #include "View/RealTimeView.h"
  11. #include "View/MultiSortView.h"
  12. #include "View/GraphView.h"
  13. #include "View/BaseView.h"
  14. #include "View/InfoView.h"
  15. #include "View/SelectorView.h"
  16. #include "Dialog/DownloadDlg.h"
  17. #include "Dialog/InstallPacDlg.h"
  18. #include "Dialog/DataSrcDlg.h"
  19. #include "Dialog/SetColumnDlg.h"
  20. #include "Dialog/BaseIndexDlg.h"
  21. #include "Dialog/UpgradeDlg.h"
  22. #include "Dialog/FilterInfoDlg.h"
  23. #include "Dialog/SetGroupDlg.h"
  24. #include "Dialog/SelectGrpDlg.h"
  25. #include "Dialog/SetPrpt.h"
  26. #include "Dialog/SelectStk.h"
  27. #include "Dialog/SetRule.h"
  28. #include "Dialog/SetRate.h"
  29. #include "Dialog/SimuReport.h"
  30. #include "Dialog/SimuRealOp.h"
  31. #include "Dialog/ExportOption.h"
  32. #include "Dialog/ExportDest.h"
  33. #include "Dialog/SetDrdataDlg.h"
  34. #include "Dialog/TyDataDlg.h"
  35. #include "Dialog/SelectTraderDlg.h"
  36. #include "Dialog/SetBaseDlg.h"
  37. #include "Dialog/SetBasedataDlg.h"
  38. #include "Dialog/SetKDataDlg.h"
  39. #include "Dialog/AlarmSettingDlg.h"
  40. #include "Dialog/AlarmResultDlg.h"
  41. #include "Dialog/DeclareDlg.h"
  42. #include "ParamDlg/SetParamDlg.h"
  43. #include <io.h>
  44. #include "Dialogs.h"
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CMainFrame
  47. // toolbar buttons - IDs are command buttons
  48. static UINT indicators[] =
  49. {
  50. ID_SEPARATOR,           // status line indicator
  51. ID_SEPARATOR,           // stock indicator, and progress indicator
  52. ID_SEPARATOR,           // stock indicator
  53. ID_SEPARATOR,           // time indicator
  54. };
  55. extern TCHAR szRegKeyCompany[];
  56. extern TCHAR szRegKeyApp[];
  57. IMPLEMENT_DYNCREATE(CMainFrame, CMDIFrameWnd)
  58. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  59. //{{AFX_MSG_MAP(CMainFrame)
  60. ON_WM_CREATE()
  61. ON_WM_TIMER()
  62. ON_WM_SIZE()
  63. ON_WM_CLOSE()
  64. ON_WM_INITMENUPOPUP()
  65. //ON_COMMAND(ID_MAINBAR_SETTING, OnMainbarSetting)
  66. //ON_COMMAND(ID_MAINBAR_VIEW, OnMainbarView)
  67. //ON_COMMAND(ID_MAINBAR_TECH, OnMainbarTech)
  68. //ON_COMMAND(ID_MAINBAR_PERIOD, OnMainbarPeriod)
  69. //ON_COMMAND(ID_SLISTBAR_GROUP, OnSlistbarGroup)
  70. //ON_COMMAND(ID_SLISTBAR_DOMAIN, OnSlistbarDomain)
  71. //ON_COMMAND(ID_SLISTBAR_CLASS, OnSlistbarClass)
  72. ON_COMMAND(ID_SYS_CONNECTSERVER, OnSysConnectserver)
  73. ON_UPDATE_COMMAND_UI(ID_SYS_CONNECTSERVER, OnUpdateSysConnectserver)
  74. ON_COMMAND(ID_SYS_DISCONNECTSERVER, OnSysDisconnectserver)
  75. ON_UPDATE_COMMAND_UI(ID_SYS_DISCONNECTSERVER, OnUpdateSysDisconnectserver)
  76. ON_COMMAND(ID_SYS_STARTTONGSHI, OnSysStarttongshi)
  77. ON_UPDATE_COMMAND_UI(ID_SYS_STARTTONGSHI, OnUpdateSysStarttongshi)
  78. ON_COMMAND(ID_SYS_SETUPTONGSHI, OnSysSetuptongshi)
  79. ON_UPDATE_COMMAND_UI(ID_SYS_SETUPTONGSHI, OnUpdateSysSetuptongshi)
  80. ON_COMMAND(ID_SYS_STOPTONGSHI, OnSysStoptongshi)
  81. ON_UPDATE_COMMAND_UI(ID_SYS_STOPTONGSHI, OnUpdateSysStoptongshi)
  82. ON_COMMAND(ID_SYS_AUTOUPGRADE, OnSysAutoupgrade)
  83. ON_COMMAND(ID_SYS_AUTOSAVE, OnSysAutosave)
  84. ON_UPDATE_COMMAND_UI(ID_SYS_AUTOSAVE, OnUpdateSysAutosave)
  85. ON_COMMAND(ID_SYS_NOTIFYICON, OnSysNotifyicon)
  86. ON_UPDATE_COMMAND_UI(ID_SYS_NOTIFYICON, OnUpdateSysNotifyicon)
  87. ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullscreen)
  88. ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREEN, OnUpdateViewFullscreen)
  89. ON_WM_GETMINMAXINFO()
  90. ON_COMMAND(ID_VIEW_SIMU, OnViewSimu)
  91. ON_UPDATE_COMMAND_UI(ID_VIEW_SIMU, OnUpdateViewSimu)
  92. ON_COMMAND(ID_VIEW_SLIST, OnViewSlist)
  93. ON_UPDATE_COMMAND_UI(ID_VIEW_SLIST, OnUpdateViewSlist)
  94. ON_COMMAND(ID_VIEW_REALTIME, OnViewRealtime)
  95. ON_UPDATE_COMMAND_UI(ID_VIEW_REALTIME, OnUpdateViewRealtime)
  96. ON_COMMAND(ID_VIEW_MULTISORT, OnViewMultisort)
  97. ON_UPDATE_COMMAND_UI(ID_VIEW_MULTISORT, OnUpdateViewMultisort)
  98. ON_COMMAND(ID_VIEW_GRAPH, OnViewTechgraph)
  99. ON_UPDATE_COMMAND_UI(ID_VIEW_GRAPH, OnUpdateViewTechgraph)
  100. ON_COMMAND(ID_VIEW_BASE, OnViewBase)
  101. ON_UPDATE_COMMAND_UI(ID_VIEW_BASE, OnUpdateViewBase)
  102. ON_COMMAND(ID_VIEW_INFO, OnViewInfo)
  103. ON_UPDATE_COMMAND_UI(ID_VIEW_INFO, OnUpdateViewInfo)
  104. ON_COMMAND(ID_VIEW_SELECTOR, OnViewSelector)
  105. ON_UPDATE_COMMAND_UI(ID_VIEW_SELECTOR, OnUpdateViewSelector)
  106. ON_COMMAND(ID_VIEW_F10, OnViewF10)
  107. ON_UPDATE_COMMAND_UI(ID_VIEW_F10, OnUpdateViewF10)
  108. ON_COMMAND(ID_SLIST_INDEX, OnSlistIndex)
  109. ON_COMMAND(ID_SLIST_STRATEGY, OnSlistStrategy)
  110. ON_COMMAND(ID_SLIST_GROUP, OnSlistGroup)
  111. ON_COMMAND(ID_SLIST_GROUPSELF, OnSlistGroupself)
  112. ON_COMMAND(ID_SLIST_DOMAIN, OnSlistDomain)
  113. ON_COMMAND(ID_SLIST_ALL, OnSlistAll)
  114. ON_COMMAND(ID_SLIST_SHAA, OnSlistShaa)
  115. ON_COMMAND(ID_SLIST_SHAB, OnSlistShab)
  116. ON_COMMAND(ID_SLIST_SZNA, OnSlistSzna)
  117. ON_COMMAND(ID_SLIST_SZNB, OnSlistSznb)
  118. ON_COMMAND(ID_SLIST_SHABOND, OnSlistShabond)
  119. ON_COMMAND(ID_SLIST_SZNBOND, OnSlistSznbond)
  120. ON_COMMAND(ID_SLIST_SHAASORTDP, OnSlistShaasortdp)
  121. ON_COMMAND(ID_SLIST_SHABSORTDP, OnSlistShabsortdp)
  122. ON_COMMAND(ID_SLIST_SZNASORTDP, OnSlistSznasortdp)
  123. ON_COMMAND(ID_SLIST_SZNBSORTDP, OnSlistSznbsortdp)
  124. ON_COMMAND(ID_SLIST_SHABONDSORTDP, OnSlistShabondsortdp)
  125. ON_COMMAND(ID_SLIST_SZNBONDSORTDP, OnSlistSznbondsortdp)
  126. ON_COMMAND(ID_SLIST_SETCOLUMN, OnSlistSetcolumn)
  127. ON_COMMAND(ID_SLIST_BASEINDEX, OnSlistBaseindex)
  128. ON_COMMAND(ID_SLISTBAR_DATE, OnSlistbarDate)
  129. ON_COMMAND(ID_SLISTBAR_NAME, OnSlistbarName)
  130. ON_COMMAND(ID_VIEW_VIEWSZZS, OnViewViewszzs)
  131. ON_COMMAND(ID_VIEW_VIEWSZYBL, OnViewViewszybl)
  132. ON_COMMAND(ID_VIEW_VIEWSZAG, OnViewViewszag)
  133. ON_COMMAND(ID_VIEW_VIEWSZBG, OnViewViewszbg)
  134. ON_COMMAND(ID_VIEW_VIEWSZNCZ, OnViewViewszncz)
  135. ON_COMMAND(ID_VIEW_VIEWSZNZZ, OnViewViewsznzz)
  136. ON_COMMAND(ID_VIEW_VIEWSZNCFAZ, OnViewViewszncfaz)
  137. ON_COMMAND(ID_VIEW_VIEWSZNCFBZ, OnViewViewszncfbz)
  138. ON_COMMAND(ID_VIEW_TECHOPTION, OnViewTechoption)
  139. ON_COMMAND(ID_VIEW_PDAY, OnViewPday)
  140. ON_UPDATE_COMMAND_UI(ID_VIEW_PDAY, OnUpdateViewPday)
  141. ON_COMMAND(ID_VIEW_PWEEK, OnViewPweek)
  142. ON_UPDATE_COMMAND_UI(ID_VIEW_PWEEK, OnUpdateViewPweek)
  143. ON_COMMAND(ID_VIEW_PMONTH, OnViewPmonth)
  144. ON_UPDATE_COMMAND_UI(ID_VIEW_PMONTH, OnUpdateViewPmonth)
  145. ON_COMMAND(ID_VIEW_PMIN5, OnViewPmin5)
  146. ON_UPDATE_COMMAND_UI(ID_VIEW_PMIN5, OnUpdateViewPmin5)
  147. ON_COMMAND(ID_VIEW_PMIN15, OnViewPmin15)
  148. ON_UPDATE_COMMAND_UI(ID_VIEW_PMIN15, OnUpdateViewPmin15)
  149. ON_COMMAND(ID_VIEW_PMIN30, OnViewPmin30)
  150. ON_UPDATE_COMMAND_UI(ID_VIEW_PMIN30, OnUpdateViewPmin30)
  151. ON_COMMAND(ID_VIEW_PMIN60, OnViewPmin60)
  152. ON_UPDATE_COMMAND_UI(ID_VIEW_PMIN60, OnUpdateViewPmin60)
  153. ON_COMMAND(ID_VIEW_LEFT, OnViewLeft)
  154. ON_COMMAND(ID_VIEW_RIGHT, OnViewRight)
  155. ON_COMMAND(ID_VIEW_PAGELEFT, OnViewPageleft)
  156. ON_COMMAND(ID_VIEW_PAGERIGHT, OnViewPageright)
  157. ON_COMMAND(ID_VIEW_HOME, OnViewHome)
  158. ON_COMMAND(ID_VIEW_END, OnViewEnd)
  159. ON_COMMAND(ID_VIEW_ZOOMIN, OnViewZoomin)
  160. ON_COMMAND(ID_VIEW_ZOOMOUT, OnViewZoomout)
  161. ON_COMMAND(ID_VIEW_PREV, OnViewPrev)
  162. ON_COMMAND(ID_VIEW_NEXT, OnViewNext)
  163. ON_COMMAND(ID_VIEW_INSERT, OnViewInsert)
  164. ON_COMMAND(ID_VIEW_NORESUMEDR, OnViewNoresumedr)
  165. ON_UPDATE_COMMAND_UI(ID_VIEW_NORESUMEDR, OnUpdateViewNoresumedr)
  166. ON_COMMAND(ID_VIEW_RESUMEDRUP, OnViewResumedrup)
  167. ON_UPDATE_COMMAND_UI(ID_VIEW_RESUMEDRUP, OnUpdateViewResumedrup)
  168. ON_COMMAND(ID_VIEW_RESUMEDRDOWN, OnViewResumedrdown)
  169. ON_UPDATE_COMMAND_UI(ID_VIEW_RESUMEDRDOWN, OnUpdateViewResumedrdown)
  170. ON_COMMAND(ID_VIEW_MAINDATACLOSE, OnViewMaindataclose)
  171. ON_UPDATE_COMMAND_UI(ID_VIEW_MAINDATACLOSE, OnUpdateViewMaindataclose)
  172. ON_COMMAND(ID_VIEW_MAINDATAOPEN, OnViewMaindataopen)
  173. ON_UPDATE_COMMAND_UI(ID_VIEW_MAINDATAOPEN, OnUpdateViewMaindataopen)
  174. ON_COMMAND(ID_VIEW_MAINDATAAVERAGE, OnViewMaindataaverage)
  175. ON_UPDATE_COMMAND_UI(ID_VIEW_MAINDATAAVERAGE, OnUpdateViewMaindataaverage)
  176. ON_COMMAND(ID_VIEW_KLINECANDLE, OnViewKlinecandle)
  177. ON_UPDATE_COMMAND_UI(ID_VIEW_KLINECANDLE, OnUpdateViewKlinecandle)
  178. ON_COMMAND(ID_VIEW_KLINEAMERICA, OnViewKlineamerica)
  179. ON_UPDATE_COMMAND_UI(ID_VIEW_KLINEAMERICA, OnUpdateViewKlineamerica)
  180. ON_COMMAND(ID_VIEW_KLINETOWER, OnViewKlinetower)
  181. ON_UPDATE_COMMAND_UI(ID_VIEW_KLINETOWER, OnUpdateViewKlinetower)
  182. ON_COMMAND(ID_REALTIME_VIEWSZZS, OnRealtimeViewszzs)
  183. ON_COMMAND(ID_REALTIME_VIEWSZYBL, OnRealtimeViewszybl)
  184. ON_COMMAND(ID_REALTIME_VIEWSZAG, OnRealtimeViewszag)
  185. ON_COMMAND(ID_REALTIME_VIEWSZBG, OnRealtimeViewszbg)
  186. ON_COMMAND(ID_REALTIME_VIEWSZNCZ, OnRealtimeViewszncz)
  187. ON_COMMAND(ID_REALTIME_VIEWSZNZZ, OnRealtimeViewsznzz)
  188. ON_COMMAND(ID_REALTIME_VIEWSZNCFAZ, OnRealtimeViewszncfaz)
  189. ON_COMMAND(ID_REALTIME_VIEWSZNCFBZ, OnRealtimeViewszncfbz)
  190. ON_COMMAND(ID_REALTIME_LEFT, OnRealtimeLeft)
  191. ON_COMMAND(ID_REALTIME_RIGHT, OnRealtimeRight)
  192. ON_COMMAND(ID_REALTIME_HOME, OnRealtimeHome)
  193. ON_COMMAND(ID_REALTIME_END, OnRealtimeEnd)
  194. ON_COMMAND(ID_REALTIME_PREV, OnRealtimePrev)
  195. ON_COMMAND(ID_REALTIME_NEXT, OnRealtimeNext)
  196. ON_COMMAND(ID_REALTIME_ONESTOCK, OnRealtimeOnestock)
  197. ON_COMMAND(ID_REALTIME_TWOSTOCK, OnRealtimeTwostock)
  198. ON_COMMAND(ID_REALTIME_FOURSTOCK, OnRealtimeFourstock)
  199. ON_COMMAND(ID_REALTIME_SIXSTOCK, OnRealtimeSixstock)
  200. ON_COMMAND(ID_REALTIME_NINESTOCK, OnRealtimeNinestock)
  201. ON_UPDATE_COMMAND_UI(ID_REALTIME_ONESTOCK, OnUpdateRealtimeOnestock)
  202. ON_UPDATE_COMMAND_UI(ID_REALTIME_TWOSTOCK, OnUpdateRealtimeTwostock)
  203. ON_UPDATE_COMMAND_UI(ID_REALTIME_FOURSTOCK, OnUpdateRealtimeFourstock)
  204. ON_UPDATE_COMMAND_UI(ID_REALTIME_SIXSTOCK, OnUpdateRealtimeSixstock)
  205. ON_UPDATE_COMMAND_UI(ID_REALTIME_NINESTOCK, OnUpdateRealtimeNinestock)
  206. ON_COMMAND(ID_REALTIME_PRICELINE, OnRealtimePriceline)
  207. ON_COMMAND(ID_REALTIME_REPORTDETAIL, OnRealtimeReportdetail)
  208. ON_COMMAND(ID_REALTIME_MINUTEDETAIL, OnRealtimeMinutedetail)
  209. ON_COMMAND(ID_REALTIME_BIGTRADEDETAIL, OnRealtimeBigtradedetail)
  210. ON_COMMAND(ID_REALTIME_LBDK, OnRealtimeLbdk)
  211. ON_COMMAND(ID_REALTIME_MMLD, OnRealtimeMmld)
  212. ON_UPDATE_COMMAND_UI(ID_REALTIME_PRICELINE, OnUpdateRealtimePriceline)
  213. ON_UPDATE_COMMAND_UI(ID_REALTIME_REPORTDETAIL, OnUpdateRealtimeReportdetail)
  214. ON_UPDATE_COMMAND_UI(ID_REALTIME_MINUTEDETAIL, OnUpdateRealtimeMinutedetail)
  215. ON_UPDATE_COMMAND_UI(ID_REALTIME_BIGTRADEDETAIL, OnUpdateRealtimeBigtradedetail)
  216. ON_UPDATE_COMMAND_UI(ID_REALTIME_LBDK, OnUpdateRealtimeLbdk)
  217. ON_UPDATE_COMMAND_UI(ID_REALTIME_MMLD, OnUpdateRealtimeMmld)
  218. ON_COMMAND(ID_REALTIME_MSSZAG, OnRealtimeMsszag)
  219. ON_COMMAND(ID_REALTIME_MSSZBG, OnRealtimeMsszbg)
  220. ON_COMMAND(ID_REALTIME_MSSZZQ, OnRealtimeMsszzq)
  221. ON_COMMAND(ID_REALTIME_MSSZNAG, OnRealtimeMssznag)
  222. ON_COMMAND(ID_REALTIME_MSSZNBG, OnRealtimeMssznbg)
  223. ON_COMMAND(ID_REALTIME_MSSZNZQ, OnRealtimeMssznzq)
  224. ON_UPDATE_COMMAND_UI(ID_REALTIME_MSSZAG, OnUpdateRealtimeMsszag)
  225. ON_UPDATE_COMMAND_UI(ID_REALTIME_MSSZBG, OnUpdateRealtimeMsszbg)
  226. ON_UPDATE_COMMAND_UI(ID_REALTIME_MSSZZQ, OnUpdateRealtimeMsszzq)
  227. ON_UPDATE_COMMAND_UI(ID_REALTIME_MSSZNAG, OnUpdateRealtimeMssznag)
  228. ON_UPDATE_COMMAND_UI(ID_REALTIME_MSSZNBG, OnUpdateRealtimeMssznbg)
  229. ON_UPDATE_COMMAND_UI(ID_REALTIME_MSSZNZQ, OnUpdateRealtimeMssznzq)
  230. ON_COMMAND(ID_INFO_SELF, OnInfoSelf)
  231. ON_COMMAND(ID_INFO_F10, OnInfoF10)
  232. ON_COMMAND(ID_INFO_STOCKSTAR, OnInfoStockstar)
  233. ON_COMMAND(ID_INFO_SOHU, OnInfoSohu)
  234. ON_COMMAND(ID_INFO_SINA, OnInfoSina)
  235. ON_COMMAND(ID_INFO_163, OnInfo163)
  236. ON_COMMAND(ID_INFO_SHSE, OnInfoShse)
  237. ON_COMMAND(ID_INFO_SZSE, OnInfoSzse)
  238. ON_COMMAND(ID_INFO_HKEX, OnInfoHkex)
  239. ON_COMMAND(ID_INFO_LSE, OnInfoLse)
  240. ON_COMMAND(ID_INFO_NYSE, OnInfoNyse)
  241. ON_COMMAND(ID_INFO_NASDAQ, OnInfoNasdaq)
  242. ON_COMMAND(ID_INFO_P5W, OnInfoP5w)
  243. ON_COMMAND(ID_INFO_SSNEWS, OnInfoSsnews)
  244. ON_COMMAND(ID_INFO_CS, OnInfoCs)
  245. ON_UPDATE_COMMAND_UI(ID_INFO_SELF, OnUpdateInfoSelf)
  246. ON_UPDATE_COMMAND_UI(ID_INFO_F10, OnUpdateInfoF10)
  247. ON_UPDATE_COMMAND_UI(ID_INFO_STOCKSTAR, OnUpdateInfoStockstar)
  248. ON_UPDATE_COMMAND_UI(ID_INFO_SOHU, OnUpdateInfoSohu)
  249. ON_UPDATE_COMMAND_UI(ID_INFO_SINA, OnUpdateInfoSina)
  250. ON_UPDATE_COMMAND_UI(ID_INFO_163, OnUpdateInfo163)
  251. ON_UPDATE_COMMAND_UI(ID_INFO_SHSE, OnUpdateInfoShse)
  252. ON_UPDATE_COMMAND_UI(ID_INFO_SZSE, OnUpdateInfoSzse)
  253. ON_UPDATE_COMMAND_UI(ID_INFO_HKEX, OnUpdateInfoHkex)
  254. ON_UPDATE_COMMAND_UI(ID_INFO_LSE, OnUpdateInfoLse)
  255. ON_UPDATE_COMMAND_UI(ID_INFO_NYSE, OnUpdateInfoNyse)
  256. ON_UPDATE_COMMAND_UI(ID_INFO_NASDAQ, OnUpdateInfoNasdaq)
  257. ON_UPDATE_COMMAND_UI(ID_INFO_P5W, OnUpdateInfoP5w)
  258. ON_UPDATE_COMMAND_UI(ID_INFO_SSNEWS, OnUpdateInfoSsnews)
  259. ON_UPDATE_COMMAND_UI(ID_INFO_CS, OnUpdateInfoCs)
  260. ON_COMMAND(ID_STRATEGY_PROPERTY, OnStrategyProperty)
  261. ON_UPDATE_COMMAND_UI(ID_STRATEGY_PROPERTY, OnUpdateStrategyProperty)
  262. ON_COMMAND(ID_STRATEGY_STOCKS, OnStrategyStocks)
  263. ON_UPDATE_COMMAND_UI(ID_STRATEGY_STOCKS, OnUpdateStrategyStocks)
  264. ON_COMMAND(ID_STRATEGY_SETRULE, OnStrategySetRule)
  265. ON_UPDATE_COMMAND_UI(ID_STRATEGY_SETRULE, OnUpdateStrategySetRule)
  266. ON_COMMAND(ID_STRATEGY_SETRATE, OnStrategySetRate)
  267. ON_UPDATE_COMMAND_UI(ID_STRATEGY_SETRATE, OnUpdateStrategySetRate)
  268. ON_COMMAND(ID_STRATEGY_SIMU, OnStrategySimu)
  269. ON_UPDATE_COMMAND_UI(ID_STRATEGY_SIMU, OnUpdateStrategySimu)
  270. ON_COMMAND(ID_STRATEGY_REPORT, OnStrategyReport)
  271. ON_UPDATE_COMMAND_UI(ID_STRATEGY_REPORT, OnUpdateStrategyReport)
  272. ON_COMMAND(ID_STRATEGY_REALOP, OnStrategyRealOp)
  273. ON_UPDATE_COMMAND_UI(ID_STRATEGY_REALOP, OnUpdateStrategyRealOp)
  274. ON_COMMAND(ID_DATA_DOWNLOAD, OnDataDownload)
  275. ON_COMMAND(ID_DATA_DATASOURCE, OnDataDatasource)
  276. ON_COMMAND(ID_DATA_MANAGE, OnDataManage)
  277. ON_COMMAND(ID_DATA_EXPORT, OnDataExport)
  278. ON_COMMAND(ID_DATA_RECALCULATEYIELD, OnDataRecalculateyield)
  279. ON_COMMAND(ID_OPTION_PROXYSET, OnOptionProxyset)
  280. ON_COMMAND(ID_OPTION_SELECTTRADER, OnOptionSelecttrader)
  281. //ON_COMMAND(ID_OPTION_COLOR, OnOptionColor)
  282. ON_COMMAND(ID_OPTION_FONTSLIST, OnOptionFontslist)
  283. ON_COMMAND(ID_OPTION_FONTBASE, OnOptionFontbase)
  284. ON_COMMAND(ID_OPTION_SETGROUP, OnOptionSetgroup)
  285. ON_COMMAND(ID_OPTION_ADDTOSTRATEGY, OnOptionAddtostrategy)
  286. ON_UPDATE_COMMAND_UI(ID_OPTION_ADDTOSTRATEGY, OnUpdateOptionAddtostrategy)
  287. //}}AFX_MSG_MAP
  288. // Global help commands
  289. ON_COMMAND(ID_TOOL_TRADER, OnToolTrader)
  290. ON_COMMAND(ID_TOOL_NOTE, OnToolNote)
  291. ON_COMMAND(ID_TOOL_CALCULATOR, OnToolCalculator)
  292. ON_COMMAND(ID_TOOL_FILTERINFO, OnToolFilterinfo)
  293. ON_COMMAND(ID_TOOL_ALARM, OnToolAlarm)
  294. ON_COMMAND(ID_HELP_SHOWHELP, OnHelpShowhelp)
  295. ON_COMMAND(ID_HELP_PRODUCT, OnHelpProduct)
  296. ON_COMMAND(ID_HELP_DECLARE, OnHelpDeclare)
  297. ON_COMMAND(ID_HELP_FORUM, OnHelpForum)
  298. ON_NOTIFY(TBN_DROPDOWN, IDW_MAINBAR, OnMainBarDropDown)
  299. ON_NOTIFY(TBN_DROPDOWN, IDW_SLISTBAR, OnSlistBarDropDown)
  300. ON_COMMAND_RANGE(ID_SLIST_DOMAIN_START, ID_SLIST_DOMAIN_END, OnSlistDomainRange)
  301. ON_COMMAND_RANGE(ID_SLIST_GROUP_START, ID_SLIST_GROUP_END, OnSlistGroupRange)
  302. ON_COMMAND_RANGE(ID_VIEW_TECH_START, ID_VIEW_TECH_END, OnViewTechRange)
  303. ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_TECH_START, ID_VIEW_TECH_END, OnUpdateViewTechRange)
  304. ON_COMMAND_RANGE(ID_OPTION_ADDTOGROUP_START, ID_OPTION_ADDTOGROUP_END, OnOptionAddtogroupRange)
  305. ON_UPDATE_COMMAND_UI_RANGE(ID_OPTION_ADDTOGROUP_START, ID_OPTION_ADDTOGROUP_END, OnUpdateOptionAddtogroupRange)
  306. ON_UPDATE_COMMAND_UI(IDW_MENUBAR, OnUpdateControlBarMenu)
  307. ON_COMMAND_EX(IDW_MENUBAR, OnBarCheck)
  308. ON_UPDATE_COMMAND_UI(IDW_MAINBAR, OnUpdateControlBarMenu)
  309. ON_COMMAND_EX(IDW_MAINBAR, OnBarCheck)
  310. ON_UPDATE_COMMAND_UI(IDW_VIEWBAR, OnUpdateControlBarMenu)
  311. ON_COMMAND_EX(IDW_VIEWBAR, OnBarCheck)
  312. ON_UPDATE_COMMAND_UI(IDW_PERIODBAR, OnUpdateControlBarMenu)
  313. ON_COMMAND_EX(IDW_PERIODBAR, OnBarCheck)
  314. ON_UPDATE_COMMAND_UI(IDW_SLISTBAR, OnUpdateControlBarMenu)
  315. ON_COMMAND_EX(IDW_SLISTBAR, OnBarCheck)
  316. ON_UPDATE_COMMAND_UI(IDW_SIMUBAR, OnUpdateControlBarMenu)
  317. ON_COMMAND_EX(IDW_SIMUBAR, OnBarCheck)
  318. ON_MESSAGE(WM_USER_UPDATEBARMENU, OnUpdateBarMenu)
  319. ON_MESSAGE(WM_USER_NIFMESSAGE, OnNifMessage)
  320. ON_MESSAGE(WM_USER_INITDATES, OnInitDates)
  321. ON_MESSAGE(WM_USER_UPDATESLISTVIEW, OnUpdateSlistView)
  322. ON_MESSAGE(WM_APP_STKRECEIVER_ALARM, OnStkReceiverAlarm)
  323. END_MESSAGE_MAP()
  324. CMainFrame* CMainFrame::CreateNewFrame()
  325. {
  326. CRuntimeClass* pFrameClass = RUNTIME_CLASS(CMainFrame);
  327. CMainFrame* pFrame = (CMainFrame*)pFrameClass->CreateObject();
  328. if (pFrame == NULL)
  329. {
  330. TRACE1("Warning: Dynamic create of frame %hs failed.n",
  331. pFrameClass->m_lpszClassName);
  332. return NULL;
  333. }
  334. ASSERT_KINDOF(CMainFrame, pFrame);
  335. // create new from resource
  336. if (!pFrame->LoadFrame(IDR_MAINFRAME))
  337. {
  338. TRACE0("Warning: Couldn't create a frame.n");
  339. // frame will be deleted in PostNcDestroy cleanup
  340. return NULL;
  341. }
  342. // it worked !
  343. return pFrame;
  344. }
  345. /////////////////////////////////////////////////////////////////////////////
  346. // CMainFrame construction/destruction
  347. CMainFrame::CMainFrame()
  348. {
  349. memset(&m_fullScreen, 0, sizeof(m_fullScreen));
  350. m_fullScreen.bFullScreen = FALSE;
  351. ::memset(&m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT));
  352. m_dataFrameWP.length = sizeof(WINDOWPLACEMENT);
  353. m_dataFrameWP.showCmd = SW_HIDE;
  354. }
  355. CMainFrame::~CMainFrame()
  356. {
  357. }
  358. #define FRM_SEARCH_WIDTH 180
  359. #define FRM_SEARCH_HEIGHT 22
  360. #define SLB_DATE_WIDTH 135
  361. #define SLB_DATE_HEIGHT 22
  362. BOOL CMainFrame::CreateStatusBar()
  363. {
  364. if (!m_wndStatusBar.Create(this) ||
  365. !m_wndStatusBar.SetIndicators(indicators,
  366.   sizeof(indicators)/sizeof(UINT)))
  367. {
  368. TRACE0("Failed to create status barn");
  369. return FALSE;      // fail to create
  370. }
  371. if (!m_wndProgressBar.Create(this, IDD_PROGRESS, CBRS_BOTTOM, IDW_PROGRESSBAR))
  372. {
  373. TRACE0("Failed to create progress barn");
  374. return FALSE;      // fail to create
  375. }
  376. CProgressCtrl* pPrg = (CProgressCtrl*)m_wndProgressBar.GetDlgItem(IDC_PROGRESS);
  377. if (pPrg != NULL)
  378. pPrg->SetRange(0, 100);
  379. HideProgressBar();
  380. // Set Status Bar Styles
  381. UINT nID, nStyle;
  382. int cxWidth;
  383. m_wndStatusBar.GetPaneInfo(1, nID, nStyle, cxWidth);
  384. m_wndStatusBar.SetPaneInfo(1, nID, nStyle, 140 );
  385. m_wndStatusBar.GetPaneInfo(2, nID, nStyle, cxWidth);
  386. m_wndStatusBar.SetPaneInfo(2, nID, nStyle, 140 );
  387. m_wndStatusBar.GetPaneInfo(3, nID, nStyle, cxWidth);
  388. m_wndStatusBar.SetPaneInfo(3, nID, nStyle, 165 );
  389. m_wndStatusBar.GetStatusBarCtrl().SetMinHeight(20);
  390. HICON icon = AfxGetApp()->LoadIcon(IDI_INDICATOR);
  391. m_wndStatusBar.GetStatusBarCtrl().SetIcon(0,  icon);
  392. return TRUE;
  393. }
  394. char szBarSection[] = "StockAnaBar";
  395. char szMainBar[] = "MainBar";
  396. char szSListBar[] = "SListBar";
  397. char szSimuBar[] = "SimuBar";
  398. char szViewBar[] = "ViewBar";
  399. char szPeriodBar[] = "PeriodBar";
  400. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  401. {
  402. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  403. return -1;
  404. // Create ToolBars
  405. if (!CreateStatusBar())
  406. {
  407. return -1;      // failed to create
  408. }
  409. // Name Search ComboBox
  410. if (!m_SearchBox.Create(WS_CHILD | CBS_DROPDOWN | CBS_SORT | CBS_AUTOHSCROLL | WS_VSCROLL | CBS_HASSTRINGS,
  411. CRect(-FRM_SEARCH_WIDTH, -FRM_SEARCH_HEIGHT, 0, 200), this, ID_SLISTBAR_NAME))
  412. {
  413. TRACE0("Failed to create m_SearchBoxn");
  414. return FALSE;
  415. }
  416. m_SearchBox.SetItemHeight(-1, 16); 
  417. m_SearchBox.SetAutoHide(TRUE);
  418. SendMessage(WM_USER_UPDATEBARMENU, 0, 0);
  419. // Enable Docking
  420. EnableDocking(CBRS_ALIGN_ANY);
  421. // Set Timer
  422. SetTimer(TIMER_TIME, 1000, NULL);
  423. SetTimer(TIMER_STOCKINDEXREFRESH, 5000, NULL);
  424. // Notify Icon
  425. NOTIFYICONDATA nid;
  426. memset(&nid, 0, sizeof(nid));
  427. nid.cbSize = sizeof(nid);
  428. nid.hWnd = GetSafeHwnd();
  429. nid.uID = 1;
  430. nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
  431. nid.uCallbackMessage = WM_USER_NIFMESSAGE;
  432. nid.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  433. CString strName = AfxGetStockIndexReportTip();
  434. strncpy(nid.szTip, strName, min(strName.GetLength(),sizeof(nid.szTip)-1));
  435. Shell_NotifyIcon(NIM_ADD, &nid);
  436. // StkReceiver Alarm
  437. AfxGetStkReceiver().AddRcvAlarmWnd(GetSafeHwnd());
  438. return 0;
  439. }
  440. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  441. {
  442. if (!CMDIFrameWnd::PreCreateWindow(cs))
  443. return FALSE;
  444. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  445. return TRUE;
  446. }
  447. void CMainFrame::ActivateFrame(int nCmdShow) 
  448. {
  449. // window placement persistence
  450. if (m_dataFrameWP.showCmd != SW_HIDE)
  451. {
  452. SetWindowPlacement(&m_dataFrameWP);
  453. CFrameWnd::ActivateFrame(m_dataFrameWP.showCmd);
  454. m_dataFrameWP.showCmd = SW_HIDE;
  455. return;
  456. }
  457. CMDIFrameWnd::ActivateFrame(nCmdShow);
  458. }
  459. void CMainFrame::ShowProgressBar()
  460. {
  461. m_wndStatusBar.SetWindowPos(&wndBottom, 0, 0, 0, 0,
  462.  SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|
  463.  SWP_NOACTIVATE|SWP_HIDEWINDOW);
  464. CRect rect;
  465. GetClientRect(&rect);
  466. CSize size = m_wndProgressBar.CalcFixedLayout(TRUE, TRUE);
  467. rect.top = rect.bottom - size.cy;
  468. m_wndProgressBar.SetWindowPos(&wndTop,//m_wndStatusBar,
  469.    rect.left, 
  470.    rect.top,
  471.    rect.right  - rect.left,
  472.    rect.bottom - rect.top, 
  473.    SWP_NOACTIVATE|SWP_SHOWWINDOW);
  474. m_wndProgressBar.Invalidate();
  475. MSG msg;
  476. while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE))
  477. {
  478. AfxGetApp()->PumpMessage();
  479. }
  480. }
  481. void CMainFrame::HideProgressBar()
  482. {
  483. m_wndProgressBar.SetWindowPos(&wndBottom, 0, 0, 0, 0,
  484.  SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|
  485.  SWP_NOACTIVATE|SWP_HIDEWINDOW);
  486. CRect rect;
  487. GetClientRect(&rect);
  488. CSize size = m_wndStatusBar.CalcFixedLayout(TRUE, TRUE);
  489. rect.top = rect.bottom - size.cy;
  490. m_wndStatusBar.SetWindowPos(&wndTop, 
  491. rect.left, 
  492. rect.top,
  493. rect.Width(), 
  494. rect.Height(), 
  495. SWP_NOACTIVATE|SWP_SHOWWINDOW);
  496. m_wndStatusBar.Invalidate();
  497. MSG msg;
  498. while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE))
  499. {
  500. AfxGetApp()->PumpMessage();
  501. }
  502. }
  503. void CMainFrame::SetStatusMsg(LPCTSTR lpszText)
  504. {
  505. if (m_wndStatusBar.IsWindowVisible())
  506. {
  507. SetMessageText(lpszText);
  508. }
  509. else if (m_wndProgressBar.IsWindowVisible())
  510. {
  511. CWnd *pWnd = m_wndProgressBar.GetDlgItem(IDC_MESSAGE);
  512. if (pWnd)
  513. pWnd->SetWindowText(lpszText);
  514. }
  515. }
  516. void CMainFrame::SetProgress(int nPercent)
  517. {
  518. if (m_wndProgressBar.IsWindowVisible())
  519. {
  520. CProgressCtrl* pPrg = (CProgressCtrl*)m_wndProgressBar.GetDlgItem(IDC_PROGRESS);
  521. if (pPrg != NULL)
  522. pPrg->SetPos(nPercent);
  523. }
  524. else if (m_wndStatusBar.IsWindowVisible())
  525. {
  526. CString string;
  527. int maxcount = nPercent/9;
  528. CString strProgress;
  529. strProgress.LoadString(IDS_MAINFRAME_PROGRESS);
  530. for(int i=0; i<maxcount; i++)
  531. {
  532. string += strProgress;
  533. }
  534. if (100 == nPercent)
  535. string = "";
  536. m_wndStatusBar.SetPaneText(1,string);
  537. }
  538. }
  539. CPoint CMainFrame::CalcPopupMenuPoint(CToolBar * pBar, UINT nID, CMenu *pMenu)
  540. {
  541. ASSERT(pBar && pBar->IsKindOf(RUNTIME_CLASS(CToolBar)));
  542. // Button rect
  543. CRect rectButton;
  544. pBar->GetToolBarCtrl().GetRect(nID, &rectButton);
  545. pBar->ClientToScreen(&rectButton);
  546. // Screen size
  547. int cyScreen = GetSystemMetrics(SM_CYSCREEN);
  548. // Menu height
  549. int nMenuHeight = cyScreen/4;
  550. if (pMenu)
  551. {
  552. nMenuHeight = 5;
  553. for(UINT i=0; i<pMenu->GetMenuItemCount(); i++)
  554. {
  555. if (ID_SEPARATOR == pMenu->GetMenuItemID(i))
  556. nMenuHeight += 9;
  557. else
  558. nMenuHeight += 19;
  559. }
  560. }
  561. // Left Width
  562. int nLeftWidth = rectButton.Height();
  563. for(int i=0; i<pBar->GetCount(); i++)
  564. {
  565. if (pBar->GetButtonStyle(i) == TBSTYLE_BUTTON)
  566. {
  567. CRect rectItem;
  568. pBar->GetToolBarCtrl().GetRect(i, &rectItem);
  569. nLeftWidth = rectItem.Width();
  570. break;
  571. }
  572. }
  573. // Track Point
  574. CPoint pt;
  575. if (cyScreen-rectButton.bottom-2 >= nMenuHeight
  576. || rectButton.top-2 < nMenuHeight)
  577. {
  578. pt.x = rectButton.left + nLeftWidth;
  579. pt.y = rectButton.bottom + 1;
  580. }
  581. else
  582. {
  583. pt.x = rectButton.left + nLeftWidth;
  584. pt.y = rectButton.top - 1;
  585. }
  586. return pt;
  587. }
  588. void CMainFrame::InitMenuPopup(CMenu* pPopupMenu)
  589. {
  590. if (NULL == pPopupMenu || NULL == pPopupMenu->GetSafeHmenu())
  591. return;
  592. for(UINT nMenu=0; nMenu<pPopupMenu->GetMenuItemCount(); nMenu++)
  593. {
  594. if (ID_SLIST_GROUP1 == pPopupMenu->GetMenuItemID(nMenu))
  595. {
  596. pPopupMenu->ModifyMenu(nMenu, MF_BYPOSITION | MF_GRAYED, ID_SLIST_GROUP1, (LPCTSTR)NULL);
  597. for(UINT k=pPopupMenu->GetMenuItemCount()-1; k>nMenu; k--)
  598. pPopupMenu->DeleteMenu(k, MF_BYPOSITION);
  599. AfxMenuInsertGroup(pPopupMenu, nMenu+1, ID_SLIST_GROUP_START, ID_SLIST_GROUP_END, TRUE);
  600. break;
  601. }
  602. else if (ID_SLIST_DOMAIN1 == pPopupMenu->GetMenuItemID(nMenu))
  603. {
  604. pPopupMenu->DeleteMenu(nMenu, MF_BYPOSITION);
  605. AfxMenuInsertDomain(pPopupMenu, nMenu, ID_SLIST_DOMAIN_START, ID_SLIST_DOMAIN_END);
  606. break;
  607. }
  608. else if (ID_OPTION_ADDTOGROUP == pPopupMenu->GetMenuItemID(nMenu))
  609. {
  610. pPopupMenu->ModifyMenu(nMenu, MF_BYPOSITION | MF_GRAYED, ID_OPTION_ADDTOGROUP, (LPCTSTR)NULL);
  611. for(UINT k=pPopupMenu->GetMenuItemCount()-1; k>nMenu; k--)
  612. pPopupMenu->DeleteMenu(k, MF_BYPOSITION);
  613. CView * pView = AfxGetStaticDoc()->GetActiveView();
  614. AfxMenuInsertGroup(pPopupMenu, nMenu+1, ID_OPTION_ADDTOGROUP_START, ID_OPTION_ADDTOGROUP_END,
  615. pView && (pView->IsKindOf(RUNTIME_CLASS(CSListView))||pView->IsKindOf(RUNTIME_CLASS(CGraphView))||pView->IsKindOf(RUNTIME_CLASS(CBaseView))));
  616. break;
  617. }
  618. else if (ID_VIEW_TECHKLINE == pPopupMenu->GetMenuItemID(nMenu))
  619. {
  620. CView * pView = AfxGetStaticDoc()->GetActiveView();
  621. UINT nFlags = ((pView && pView->IsKindOf(RUNTIME_CLASS(CGraphView))) ? MF_BYPOSITION | MF_STRING : MF_BYPOSITION | MF_STRING | MF_GRAYED);
  622. pPopupMenu->DeleteMenu(nMenu, MF_BYPOSITION);
  623. for(UINT nID = STT_KLINE_MAX; nID >= STT_KLINE_MIN; nID --)
  624. {
  625. UINT nFlagsLocal = nFlags;
  626. if (AfxGetProfile().IsGraphTechShow(nID)) nFlagsLocal |= MF_CHECKED;
  627. pPopupMenu->InsertMenu(nMenu, nFlagsLocal, ID_VIEW_TECH_START+nID, AfxGetSTTFullName(nID));
  628. }
  629. }
  630. else if (ID_VIEW_TECHTREND == pPopupMenu->GetMenuItemID(nMenu))
  631. {
  632. CView * pView = AfxGetStaticDoc()->GetActiveView();
  633. UINT nFlags = ((pView && pView->IsKindOf(RUNTIME_CLASS(CGraphView))) ? MF_BYPOSITION | MF_STRING : MF_BYPOSITION | MF_STRING | MF_GRAYED);
  634. pPopupMenu->DeleteMenu(nMenu, MF_BYPOSITION);
  635. for(UINT nID = STT_TREND_MAX; nID >= STT_TREND_MIN; nID --)
  636. {
  637. UINT nFlagsLocal = nFlags;
  638. if (AfxGetProfile().IsGraphTechShow(nID)) nFlagsLocal |= MF_CHECKED;
  639. pPopupMenu->InsertMenu(nMenu, nFlagsLocal, ID_VIEW_TECH_START+nID, AfxGetSTTFullName(nID));
  640. }
  641. }
  642. else if (ID_VIEW_TECHENERGY == pPopupMenu->GetMenuItemID(nMenu))
  643. {
  644. pPopupMenu->DeleteMenu(nMenu, MF_BYPOSITION);
  645. CView * pView = AfxGetStaticDoc()->GetActiveView();
  646. UINT nFlags = ((pView && pView->IsKindOf(RUNTIME_CLASS(CGraphView))) ? MF_BYPOSITION | MF_STRING : MF_BYPOSITION | MF_STRING | MF_GRAYED);
  647. for(UINT nID = STT_ENERGY_MAX; nID >= STT_ENERGY_MIN; nID --)
  648. {
  649. UINT nFlagsLocal = nFlags;
  650. if (AfxGetProfile().IsGraphTechShow(nID)) nFlagsLocal |= MF_CHECKED;
  651. pPopupMenu->InsertMenu(nMenu, nFlagsLocal, ID_VIEW_TECH_START+nID, AfxGetSTTFullName(nID));
  652. }
  653. }
  654. else if (ID_VIEW_TECHSWING == pPopupMenu->GetMenuItemID(nMenu))
  655. {
  656. CView * pView = AfxGetStaticDoc()->GetActiveView();
  657. UINT nFlags = ((pView && pView->IsKindOf(RUNTIME_CLASS(CGraphView))) ? MF_BYPOSITION | MF_STRING : MF_BYPOSITION | MF_STRING | MF_GRAYED);
  658. pPopupMenu->DeleteMenu(nMenu, MF_BYPOSITION);
  659. for(UINT nID = STT_SWING_MAX; nID >= STT_SWING_MIN; nID --)
  660. {
  661. UINT nFlagsLocal = nFlags;
  662. if (AfxGetProfile().IsGraphTechShow(nID)) nFlagsLocal |= MF_CHECKED;
  663. pPopupMenu->InsertMenu(nMenu, nFlagsLocal, ID_VIEW_TECH_START+nID, AfxGetSTTFullName(nID));
  664. }
  665. }
  666. else if (ID_VIEW_TECHOTHER == pPopupMenu->GetMenuItemID(nMenu))
  667. {
  668. CView * pView = AfxGetStaticDoc()->GetActiveView();
  669. UINT nFlags = ((pView && pView->IsKindOf(RUNTIME_CLASS(CGraphView))) ? MF_BYPOSITION | MF_STRING : MF_BYPOSITION | MF_STRING | MF_GRAYED);
  670. pPopupMenu->DeleteMenu(nMenu, MF_BYPOSITION);
  671. for(UINT nID = STT_OTHER_MAX; nID >= STT_OTHER_MIN; nID --)
  672. {
  673. UINT nFlagsLocal = nFlags;
  674. if (AfxGetProfile().IsGraphTechShow(nID)) nFlagsLocal |= MF_CHECKED;
  675. pPopupMenu->InsertMenu(nMenu, nFlagsLocal, ID_VIEW_TECH_START+nID, AfxGetSTTFullName(nID));
  676. }
  677. }
  678. else if (ID_VIEW_TECHCLK == pPopupMenu->GetMenuItemID(nMenu))
  679. {
  680. CView * pView = AfxGetStaticDoc()->GetActiveView();
  681. UINT nFlags = ((pView && pView->IsKindOf(RUNTIME_CLASS(CGraphView))) ? MF_BYPOSITION | MF_STRING : MF_BYPOSITION | MF_STRING | MF_GRAYED);
  682. pPopupMenu->DeleteMenu(nMenu, MF_BYPOSITION);
  683. for(UINT nID = STT_CLK_MAX; nID >= STT_CLK_MIN; nID --)
  684. {
  685. UINT nFlagsLocal = nFlags;
  686. if (AfxGetProfile().IsGraphTechShow(nID)) nFlagsLocal |= MF_CHECKED;
  687. pPopupMenu->InsertMenu(nMenu, nFlagsLocal, ID_VIEW_TECH_START+nID, AfxGetSTTFullName(nID));
  688. }
  689. }
  690. else if (ID_VIEW_TECHUSER == pPopupMenu->GetMenuItemID(nMenu))
  691. {
  692. CView * pView = AfxGetStaticDoc()->GetActiveView();
  693. UINT nFlags = ((pView && pView->IsKindOf(RUNTIME_CLASS(CGraphView))) ? MF_BYPOSITION | MF_STRING : MF_BYPOSITION | MF_STRING | MF_GRAYED);
  694. pPopupMenu->DeleteMenu(nMenu, MF_BYPOSITION);
  695. UINT nTechUserCount = CTechUser::GetTechUserCount();
  696. UINT nIDEnd = STT_USER_MIN+nTechUserCount-1;
  697. if (nIDEnd > STT_USER_MIN+14)
  698. nIDEnd = STT_USER_MIN+14;
  699. for(UINT nID = nIDEnd; nID >= STT_USER_MIN; nID --)
  700. {
  701. UINT nFlagsLocal = nFlags;
  702. if (AfxGetProfile().IsGraphTechShow(nID)) nFlagsLocal |= MF_CHECKED;
  703. pPopupMenu->InsertMenu(nMenu, nFlagsLocal, ID_VIEW_TECH_START+nID-STT_USER_MIN+1+STT_MAX, AfxGetSTTFullName(nID));
  704. }
  705. }
  706. }
  707. }
  708. /////////////////////////////////////////////////////////////////////////////
  709. // CMainFrame diagnostics
  710. #ifdef _DEBUG
  711. void CMainFrame::AssertValid() const
  712. {
  713. CMDIFrameWnd::AssertValid();
  714. }
  715. void CMainFrame::Dump(CDumpContext& dc) const
  716. {
  717. CMDIFrameWnd::Dump(dc);
  718. }
  719. #endif //_DEBUG
  720. /////////////////////////////////////////////////////////////////////////////
  721. // CMainFrame message handlers
  722. void CMainFrame::OnTimer(UINT nIDEvent) 
  723. {
  724. if (TIMER_TIME == nIDEvent)
  725. {
  726. CSPTime time = CSPTime::GetCurrentTime();
  727. CString string = (LPCTSTR)AfxGetTimeString(time.GetTime(), "%b %d,%Y %H:%M:%S,", TRUE);
  728. m_wndStatusBar.SetPaneText(3, string);
  729. }
  730. else if (TIMER_STOCKINDEXREFRESH == nIDEvent)
  731. {
  732. CString strSHTipFmt, strSZTipFmt;
  733. strSHTipFmt.LoadString(IDS_MAINFRAME_SHINDEXTIP);
  734. strSZTipFmt.LoadString(IDS_MAINFRAME_SZINDEXTIP);
  735. double dDevided = 100000000;
  736. #ifdef CLKLAN_ENGLISH_US
  737. dDevided = 1000000000;
  738. #endif
  739. CString string;
  740. double dDiff = 0;
  741. CStockInfo info;
  742. COLORREF clrRise = AfxGetProfile().GetColor(CColorClass::clrRise);
  743. COLORREF clrFall = AfxGetProfile().GetColor(CColorClass::clrFall);
  744. if (AfxGetStockContainer().GetStockInfo(STKLIB_CODE_SZZS, &info))
  745. {
  746. info.GetDiff(&dDiff,info.m_datetech,1);
  747. string.Format(strSHTipFmt, info.m_fClose, dDiff, info.m_fAmount/dDevided);
  748. // m_wndStatusBar.SetPaneColor(dDiff > 0 ? clrRise : clrFall);
  749. m_wndStatusBar.SetPaneText(1, string);
  750. }
  751. if (AfxGetStockContainer().GetStockInfo(STKLIB_CODE_SZNCZ, &info))
  752. {
  753. info.GetDiff(&dDiff,info.m_datetech,1);
  754. string.Format(strSZTipFmt, info.m_fClose, dDiff, info.m_fAmount/dDevided);
  755. // m_wndStatusBar.SetPaneColor(dDiff > 0 ? clrRise : clrFall);
  756. m_wndStatusBar.SetPaneText(2, string);
  757. }
  758. PostMessage(WM_APP_STKRECEIVER_ALARM, STKRCV_ALARM_REFRESH, 0);
  759. }
  760. else if (TIMER_SHOWNETINFO == nIDEvent)
  761. {
  762. static unsigned long countShow = 0;
  763. countShow ++;
  764. if (countShow == 10)
  765. {
  766. KillTimer(TIMER_SHOWNETINFO);
  767. if (AfxGetProfile().HasNewVersion()
  768. && IDYES == AfxMessageBox(IDS_DOWNLOAD_UPGRADENOW, MB_YESNO))
  769. {
  770. CUpgradeDlg* dlg = new CUpgradeDlg;
  771. dlg->Create(CUpgradeDlg::IDD, this);
  772. dlg->SetAutoRun(TRUE);
  773. dlg->CenterWindow(this);
  774. dlg->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOSIZE);
  775. }
  776. }
  777. }
  778. CMDIFrameWnd::OnTimer(nIDEvent);
  779. }
  780. LRESULT CMainFrame::OnUpdateBarMenu(WPARAM wParam, LPARAM lParam)
  781. {
  782. return 0;
  783. /* ProfUIS Using Code
  784. // Menu Bar Group
  785. UINT nMenu = 0;
  786. for(nMenu=0; nMenu<m_wndMenuBar.GetMenu().GetMenuItemCount(); nMenu ++)
  787. {
  788. CMenu * pMenu = m_wndMenuBar.GetMenu().GetSubMenu(nMenu);
  789. if (!pMenu)
  790. continue;
  791. for(UINT nSubMenu=0; nSubMenu<pMenu->GetMenuItemCount(); nSubMenu ++)
  792. {
  793. CMenu * pPopupMenu = pMenu->GetSubMenu(nSubMenu);
  794. InitMenuPopup(pPopupMenu);
  795. }
  796. }
  797. CMenu menu;
  798. CMenu * pMenu = NULL;
  799. CMenu * pPopupMenu = NULL;
  800. // Main Bar
  801. menu.Attach(m_wndMainBar.GetButtonMenu(m_wndMainBar.CommandToIndex(ID_MAINBAR_SETTING)));
  802. pMenu = menu.GetSubMenu(0);
  803. for(nMenu=0; pMenu && nMenu<pMenu->GetMenuItemCount(); nMenu++)
  804. {
  805. pPopupMenu = pMenu->GetSubMenu(nMenu);
  806. InitMenuPopup(pPopupMenu);
  807. }
  808. menu.Detach();
  809. menu.Attach(m_wndMainBar.GetButtonMenu(m_wndMainBar.CommandToIndex(ID_MAINBAR_TECH)));
  810. pMenu = menu.GetSubMenu(0);
  811. for(nMenu=0; pMenu && nMenu<pMenu->GetMenuItemCount(); nMenu++)
  812. {
  813. pPopupMenu = pMenu->GetSubMenu(nMenu);
  814. InitMenuPopup(pPopupMenu);
  815. }
  816. menu.Detach();
  817. // SList Bar
  818. menu.Attach(m_wndSListBar.GetButtonMenu(m_wndSListBar.CommandToIndex(ID_SLISTBAR_GROUP)));
  819. pPopupMenu = menu.GetSubMenu(0);
  820. InitMenuPopup(pPopupMenu);
  821. menu.Detach();
  822. menu.Attach(m_wndSListBar.GetButtonMenu(m_wndSListBar.CommandToIndex(ID_SLISTBAR_DOMAIN)));
  823. pPopupMenu = menu.GetSubMenu(0);
  824. InitMenuPopup(pPopupMenu);
  825. menu.Detach();
  826. return 0;
  827. */
  828. }
  829. LRESULT CMainFrame::OnNifMessage(WPARAM wParam, LPARAM lParam)
  830. {
  831. if (WM_LBUTTONDOWN == lParam)
  832. {
  833. if (!IsIconic())
  834. {
  835. ShowWindow(SW_MINIMIZE);
  836. if (AfxGetProfile().GetNotifyIcon())
  837. ShowWindow(SW_HIDE);
  838. }
  839. else
  840. {
  841. SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
  842. ShowWindow(SW_RESTORE);
  843. UpdateWindow();
  844. }
  845. }
  846. else if (WM_RBUTTONDOWN == lParam)
  847. {
  848. // 临时刷新一下行情
  849. CStockContainer & container = AfxGetSListStockContainer();
  850. AfxGetStkReceiver().RequestStockData(CStock::dataReport, container.GetData(), container.GetSize(), 0, 0);
  851. }
  852. return 0;
  853. }
  854. LRESULT CMainFrame::OnInitDates(WPARAM wParam, LPARAM lParam)
  855. {
  856. //if (::IsWindow(m_DateBox.GetSafeHwnd()))
  857. //{
  858. // m_DateBox.InitDates();
  859. // m_DateBox.SetCurrentWindowText();
  860. //}
  861. return 0;
  862. }
  863. LRESULT CMainFrame::OnUpdateSlistView(WPARAM wParam, LPARAM lParam)
  864. {
  865. AfxGetSListStockContainer().ReRetrieveFromStatic(AfxGetActiveStrategy());
  866. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SLISTVIEW, NULL);
  867. return 0;
  868. }
  869. LRESULT CMainFrame::OnStkReceiverAlarm(WPARAM wParam, LPARAM lParam)
  870. {
  871. return 0;
  872. }
  873. BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) 
  874. {
  875. if (WM_KEYDOWN == pMsg->message)
  876. {
  877. int nVirtKey = (int) pMsg->wParam;
  878. if (VK_ESCAPE == nVirtKey && m_fullScreen.bFullScreen)
  879. OnViewFullscreen();
  880. if (m_SearchBox.IsWantChar(pMsg->wParam))
  881. {
  882. CView * pView = AfxGetStaticDoc()->GetActiveView();
  883. if (!pView ||
  884. (pView->IsKindOf(RUNTIME_CLASS(CGraphView))
  885. || pView->IsKindOf(RUNTIME_CLASS(CRealTimeView))
  886. || pView->IsKindOf(RUNTIME_CLASS(CMultiSortView))
  887. || pView->IsKindOf(RUNTIME_CLASS(CSListView))
  888. || pView->IsKindOf(RUNTIME_CLASS(CBaseView))
  889. || pView->IsKindOf(RUNTIME_CLASS(CSelectorView))))
  890. {
  891. CRect rect;
  892. GetClientRect(&rect);
  893. m_SearchBox.SetWindowPos(NULL, rect.right-FRM_SEARCH_WIDTH-18, rect.bottom-FRM_SEARCH_HEIGHT-22,
  894. 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
  895. m_SearchBox.OnChangeStatus(pMsg->wParam, pMsg->lParam, FALSE);
  896. }
  897. }
  898. else if (!m_SearchBox.GetDroppedState())
  899. {
  900. CView * pView = AfxGetStaticDoc()->GetActiveView();
  901. if (pView && 
  902. (pView->IsKindOf(RUNTIME_CLASS(CGraphView))
  903. || pView->IsKindOf(RUNTIME_CLASS(CRealTimeView))
  904. || pView->IsKindOf(RUNTIME_CLASS(CMultiSortView))
  905. || pView->IsKindOf(RUNTIME_CLASS(CSListView))))
  906. pView->SetFocus();
  907. }
  908. }
  909. return CMDIFrameWnd::PreTranslateMessage(pMsg);
  910. }
  911. void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
  912. {
  913. // CMDIFrameWnd::OnUpdateFrameTitle(bAddToTitle);
  914. //if (::IsWindow(m_MdiTabbed.GetSafeHwnd()))
  915. // m_MdiTabbed.UpdateWindows();
  916. if (bAddToTitle)
  917. {
  918. CString strMainFrame;
  919. VERIFY(strMainFrame.LoadString(IDR_MAINFRAME));
  920. CString strTitle;
  921. if (AfxExtractSubString(strTitle,strMainFrame,
  922. CDocTemplate::windowTitle) && !strTitle.IsEmpty())
  923. {
  924. strTitle += "(";
  925. strTitle += AfxGetVersionString();
  926. strTitle += ")";
  927. // reset title
  928. AfxSetWindowText(m_hWnd, strTitle);
  929. }
  930. }
  931. }
  932. void CMainFrame::OnSize(UINT nType, int cx, int cy) 
  933. {
  934. CMDIFrameWnd::OnSize(nType, cx, cy);
  935. if (SIZE_MINIMIZED == nType)
  936. {
  937. if (AfxGetProfile().GetNotifyIcon())
  938. ShowWindow(SW_HIDE);
  939. }
  940. }
  941. void CMainFrame::OnClose() 
  942. {
  943. if (m_fullScreen.bFullScreen)
  944. OnViewFullscreen();
  945. BOOL bCanClose;
  946. bCanClose = TRUE;
  947. CSimuView * pSimuView = AfxGetSimuView();
  948. if (pSimuView && 0 == pSimuView->SendMessage(WM_USER_CANCLOSEVIEW, NULL, (LPARAM)(&bCanClose)) && !bCanClose)
  949. return;
  950. bCanClose = TRUE;
  951. CSelectorView * pSelectorView = AfxGetSelectorView();
  952. if (pSelectorView && 0 == pSelectorView->SendMessage(WM_USER_CANCLOSEVIEW, NULL, (LPARAM)(&bCanClose)) && !bCanClose)
  953. return;
  954. if (IsWindowVisible())
  955. {
  956. WINDOWPLACEMENT wp;
  957. wp.length = sizeof wp;
  958. if (GetWindowPlacement(&wp))
  959. {
  960. wp.flags = 0;
  961. if (IsZoomed())
  962. wp.flags |= WPF_RESTORETOMAXIMIZED;
  963. // and write it to the .INI file
  964. AfxGetProfile().SetWindowPlacement(&wp);
  965. }
  966. }
  967. // delete notify icon
  968. NOTIFYICONDATA nid;
  969. memset(&nid, 0, sizeof(nid));
  970. nid.cbSize = sizeof(nid);
  971. nid.hWnd = GetSafeHwnd();
  972. nid.uID = 1;
  973. nid.uFlags = 0;
  974. Shell_NotifyIcon(NIM_DELETE, &nid);
  975. CMDIFrameWnd::OnClose();
  976. }
  977. BOOL CMainFrame::DestroyWindow() 
  978. {
  979. return CMDIFrameWnd::DestroyWindow();
  980. }
  981. void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) 
  982. {
  983. if (!bSysMenu && pPopupMenu)
  984. {
  985. InitMenuPopup(pPopupMenu);
  986. }
  987. CMDIFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
  988. }
  989. ////////////////////////////////////////////////////////////////////////////////
  990. // ToolBar
  991. // 工具条下拉菜单显示
  992. void CMainFrame::OnMainBarDropDown(NMHDR* pNMHDR, LRESULT* pResult)
  993. {
  994. NMTOOLBAR* pNMToolBar = (NMTOOLBAR*)pNMHDR;
  995. BOOL bLoad = FALSE;
  996. CMenu menu;
  997. if (ID_MAINBAR_SETTING == pNMToolBar->iItem)
  998. bLoad = menu.LoadMenu(IDR_MENU_MAINBARSETTING);
  999. else if (ID_MAINBAR_VIEW == pNMToolBar->iItem)
  1000. bLoad = menu.LoadMenu(IDR_MENU_MAINBARVIEW);
  1001. else if (ID_MAINBAR_TECH == pNMToolBar->iItem)
  1002. bLoad = menu.LoadMenu(IDR_MENU_MAINBARTECH);
  1003. else if (ID_MAINBAR_PERIOD == pNMToolBar->iItem)
  1004. bLoad = menu.LoadMenu(IDR_MENU_MAINBARPERIOD);
  1005. else
  1006. ASSERT(FALSE);
  1007. if (bLoad)
  1008. {
  1009. CMenu* pPopupMenu = menu.GetSubMenu(0);
  1010. if (pPopupMenu)
  1011. {
  1012. //CPoint pt = CalcPopupMenuPoint(&m_wndMainBar, pNMToolBar->iItem, pPopupMenu);
  1013. //pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, pt.x, pt.y, this);
  1014. }
  1015. }
  1016. *pResult = TBDDRET_DEFAULT;
  1017. }
  1018. void CMainFrame::OnSlistBarDropDown(NMHDR* pNMHDR, LRESULT* pResult)
  1019. {
  1020. NMTOOLBAR* pNMToolBar = (NMTOOLBAR*)pNMHDR;
  1021. BOOL bLoad = FALSE;
  1022. CMenu menu;
  1023. if (ID_SLISTBAR_GROUP == pNMToolBar->iItem)
  1024. bLoad = menu.LoadMenu(IDR_MENU_SLISTBARGROUP);
  1025. else if (ID_SLISTBAR_DOMAIN == pNMToolBar->iItem)
  1026. bLoad = menu.LoadMenu(IDR_MENU_SLISTBARDOMAIN);
  1027. else if (ID_SLISTBAR_CLASS == pNMToolBar->iItem)
  1028. bLoad = menu.LoadMenu(IDR_MENU_SLISTBARCLASS);
  1029. else
  1030. ASSERT(FALSE);
  1031. if (bLoad)
  1032. {
  1033. CMenu* pPopupMenu = menu.GetSubMenu(0);
  1034. if (pPopupMenu)
  1035. {
  1036. //CPoint pt = CalcPopupMenuPoint(&m_wndSListBar, pNMToolBar->iItem, pPopupMenu);
  1037. //pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, pt.x, pt.y, this);
  1038. }
  1039. }
  1040. *pResult = TBDDRET_DEFAULT;
  1041. }
  1042. ////////////////////////////////////////////////////////////////////////////////
  1043. // “系统”菜单
  1044. // 实时行情接收
  1045. void CMainFrame::OnSysConnectserver()
  1046. {
  1047. // AfxGetStkReceiver().NetEngineBeginWorking();
  1048. extern BOOL CALLBACK LoadProgram(HWND hWnd, int nMinProgress, int nMaxProgress);
  1049. CStartupDlg startup;
  1050. CBitmap bmp;
  1051. bmp.LoadBitmap(IDB_DLGLEFTLOGO);
  1052. startup.SetBitmap((HBITMAP)bmp.GetSafeHandle());
  1053. startup.SetLoadProgramFunc(LoadProgram);
  1054. startup.SetDisableOffline(TRUE);
  1055. startup.DoModal();
  1056. }
  1057. void CMainFrame::OnUpdateSysConnectserver(CCmdUI* pCmdUI)
  1058. {
  1059. pCmdUI->Enable(!AfxGetStkReceiver().NetEngineIsWorking());
  1060. }
  1061. void CMainFrame::OnSysDisconnectserver()
  1062. {
  1063. AfxGetStkReceiver().NetEngineEndWorking();
  1064. }
  1065. void CMainFrame::OnUpdateSysDisconnectserver(CCmdUI* pCmdUI)
  1066. {
  1067. pCmdUI->Enable(AfxGetStkReceiver().NetEngineIsWorking());
  1068. }
  1069. void CMainFrame::OnSysStarttongshi()
  1070. {
  1071. AfxGetStkReceiver().EngineBeginWorking(TRUE);
  1072. AfxGetSListStockContainer().ReRetrieveFromStatic(AfxGetActiveStrategy());
  1073. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SLISTVIEW, NULL);
  1074. }
  1075. void CMainFrame::OnUpdateSysStarttongshi(CCmdUI* pCmdUI)
  1076. {
  1077. pCmdUI->SetCheck(AfxGetStkReceiver().EngineIsWorking());
  1078. pCmdUI->Enable(TRUE);
  1079. }
  1080. void CMainFrame::OnSysSetuptongshi()
  1081. {
  1082. AfxGetStkReceiver().EngineSetup();
  1083. AfxGetSListStockContainer().ReRetrieveFromStatic(AfxGetActiveStrategy());
  1084. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SLISTVIEW, NULL);
  1085. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_GRAPHVIEW, NULL);
  1086. }
  1087. void CMainFrame::OnUpdateSysSetuptongshi(CCmdUI* pCmdUI)
  1088. {
  1089. pCmdUI->Enable(AfxGetStkReceiver().EngineIsWorking());
  1090. }
  1091. void CMainFrame::OnSysStoptongshi()
  1092. {
  1093. AfxGetStkReceiver().EngineEndWorking();
  1094. }
  1095. void CMainFrame::OnUpdateSysStoptongshi(CCmdUI* pCmdUI)
  1096. {
  1097. pCmdUI->Enable(AfxGetStkReceiver().EngineIsWorking());
  1098. }
  1099. void CMainFrame::OnSysAutoupgrade() 
  1100. {
  1101. CUpgradeDlg * dlg = new CUpgradeDlg;
  1102. dlg->Create(CUpgradeDlg::IDD, this);
  1103. dlg->CenterWindow(this);
  1104. dlg->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOSIZE);
  1105. }
  1106. void CMainFrame::OnSysAutosave() 
  1107. {
  1108. AfxGetProfile().SetAutoSaveKDataMin(!AfxGetProfile().GetAutoSaveKDataMin());
  1109. }
  1110. void CMainFrame::OnUpdateSysAutosave(CCmdUI* pCmdUI)
  1111. {
  1112. pCmdUI->SetCheck(AfxGetProfile().GetAutoSaveKDataMin());
  1113. pCmdUI->Enable(TRUE);
  1114. }
  1115. void CMainFrame::OnSysNotifyicon() 
  1116. {
  1117. AfxGetProfile().SetNotifyIcon(!AfxGetProfile().GetNotifyIcon());
  1118. }
  1119. void CMainFrame::OnUpdateSysNotifyicon(CCmdUI* pCmdUI)
  1120. {
  1121. pCmdUI->SetCheck(AfxGetProfile().GetNotifyIcon());
  1122. pCmdUI->Enable(TRUE);
  1123. }
  1124. void CMainFrame::OnViewFullscreen() 
  1125. {
  1126. int nHeight = 0; //GetSystemMetrics(SM_CYMENU);
  1127. if (m_fullScreen.bFullScreen)
  1128. {
  1129. m_fullScreen.bFullScreen = FALSE;
  1130. if (m_fullScreen.bMaximized)
  1131. {
  1132. MoveWindow( -GetSystemMetrics(SM_CXFRAME),
  1133. -GetSystemMetrics(SM_CYFRAME)-nHeight,
  1134. GetSystemMetrics(SM_CXSCREEN) + 2*GetSystemMetrics(SM_CXFRAME),
  1135. GetSystemMetrics(SM_CYSCREEN) + 2*GetSystemMetrics(SM_CYFRAME) + nHeight);
  1136. }
  1137. else
  1138. SendMessage(WM_SYSCOMMAND, SC_RESTORE);
  1139. memset(&m_fullScreen, 0, sizeof(m_fullScreen));
  1140. }
  1141. else
  1142. {
  1143. m_fullScreen.bFullScreen = TRUE;
  1144. m_fullScreen.bMaximized = IsZoomed();
  1145. if (m_wndStatusBar.IsWindowVisible())
  1146. {
  1147. m_fullScreen.bStatusBar = 1;
  1148. OnBarCheck(AFX_IDW_STATUS_BAR);
  1149. }
  1150. if (!m_fullScreen.bMaximized)
  1151. SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE);
  1152. else
  1153. MoveWindow( -GetSystemMetrics(SM_CXFRAME),
  1154. -GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYCAPTION) - nHeight,
  1155. GetSystemMetrics(SM_CXSCREEN) + 2*GetSystemMetrics(SM_CXFRAME),
  1156. GetSystemMetrics(SM_CYSCREEN) + 2*GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION) + nHeight);
  1157. }
  1158. }
  1159. void CMainFrame::OnUpdateViewFullscreen(CCmdUI* pCmdUI) 
  1160. {
  1161. pCmdUI->SetCheck(m_fullScreen.bFullScreen);
  1162. }
  1163. void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
  1164. {
  1165. CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);
  1166. if (m_fullScreen.bFullScreen)
  1167. {
  1168. int nHeight = GetSystemMetrics(SM_CYMENU);
  1169. lpMMI->ptMaxPosition.y = -GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYCAPTION) - nHeight;
  1170. lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y
  1171. = GetSystemMetrics(SM_CYSCREEN)
  1172. + 2*GetSystemMetrics(SM_CYFRAME)
  1173. + GetSystemMetrics(SM_CYCAPTION)
  1174. + nHeight;
  1175. }
  1176. }
  1177. void CMainFrame::OnViewSimu() 
  1178. {
  1179. AfxSwitchToStaticView(RUNTIME_CLASS(CSimuView));
  1180. }
  1181. void CMainFrame::OnUpdateViewSimu(CCmdUI* pCmdUI) 
  1182. {
  1183. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1184. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CSimuView)));
  1185. }
  1186. void CMainFrame::OnViewSlist() 
  1187. {
  1188. AfxSwitchToStaticView(RUNTIME_CLASS(CSListView));
  1189. }
  1190. void CMainFrame::OnUpdateViewSlist(CCmdUI* pCmdUI) 
  1191. {
  1192. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1193. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CSListView)));
  1194. }
  1195. void CMainFrame::OnViewRealtime() 
  1196. {
  1197. AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1198. }
  1199. void CMainFrame::OnUpdateViewRealtime(CCmdUI* pCmdUI) 
  1200. {
  1201. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1202. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CRealTimeView)));
  1203. }
  1204. void CMainFrame::OnViewMultisort() 
  1205. {
  1206. AfxSwitchToStaticView(RUNTIME_CLASS(CMultiSortView));
  1207. }
  1208. void CMainFrame::OnUpdateViewMultisort(CCmdUI* pCmdUI) 
  1209. {
  1210. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1211. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CMultiSortView)));
  1212. }
  1213. void CMainFrame::OnViewTechgraph() 
  1214. {
  1215. AfxSwitchToStaticView(RUNTIME_CLASS(CGraphView));
  1216. }
  1217. void CMainFrame::OnUpdateViewTechgraph(CCmdUI* pCmdUI) 
  1218. {
  1219. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1220. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CGraphView)));
  1221. }
  1222. void CMainFrame::OnViewBase() 
  1223. {
  1224. AfxSwitchToStaticView(RUNTIME_CLASS(CBaseView));
  1225. }
  1226. void CMainFrame::OnUpdateViewBase(CCmdUI* pCmdUI) 
  1227. {
  1228. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1229. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CBaseView)));
  1230. }
  1231. void CMainFrame::OnViewInfo() 
  1232. {
  1233. AfxSwitchToStaticView(RUNTIME_CLASS(CInfoView));
  1234. }
  1235. void CMainFrame::OnUpdateViewInfo(CCmdUI* pCmdUI) 
  1236. {
  1237. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1238. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CInfoView)));
  1239. }
  1240. void CMainFrame::OnViewSelector() 
  1241. {
  1242. AfxSwitchToStaticView(RUNTIME_CLASS(CSelectorView));
  1243. }
  1244. void CMainFrame::OnUpdateViewSelector(CCmdUI* pCmdUI) 
  1245. {
  1246. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1247. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CSelectorView)));
  1248. }
  1249. void CMainFrame::OnViewF10() 
  1250. {
  1251. AfxSwitchToStaticView(RUNTIME_CLASS(CBaseView));
  1252. }
  1253. void CMainFrame::OnUpdateViewF10(CCmdUI* pCmdUI) 
  1254. {
  1255. CView* pView = AfxGetStaticDoc()->GetActiveView();
  1256. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CBaseView)));
  1257. }
  1258. ////////////////////////////////////////////////////////////////////////////////
  1259. // “列表”菜单
  1260. // 股票列表
  1261. void CMainFrame::OnSlistIndex() { AfxShowSlist(CStockContainer::typeIndex); }
  1262. void CMainFrame::OnSlistStrategy() { AfxShowSlist(CStockContainer::typeStrategy); }
  1263. void CMainFrame::OnSlistGroup() { AfxShowSlist(CStockContainer::typeGroup); }
  1264. void CMainFrame::OnSlistGroupself()
  1265. { CString strSelf;
  1266. strSelf.LoadString(IDS_DOMAIN_SELF);
  1267. AfxShowSlist(CStockContainer::typeGroup, strSelf); }
  1268. void CMainFrame::OnSlistDomain(){ AfxShowSlist(CStockContainer::typeDomain);}
  1269. void CMainFrame::OnSlistDomainRange(UINT nCmdID)
  1270. {
  1271. if (nCmdID < ID_SLIST_DOMAIN_START || nCmdID > ID_SLIST_DOMAIN_END)
  1272. {
  1273. ASSERT(FALSE);
  1274. return;
  1275. }
  1276. CDomainContainer &container = AfxGetDomainContainer();
  1277. int nIndex = nCmdID - ID_SLIST_DOMAIN_START;
  1278. CString strDomainName;
  1279. if (ID_SLIST_DOMAIN_END == nCmdID)
  1280. {
  1281. CSelectGrpDlg dlg;
  1282. dlg.SetMode(CSelectGrpDlg::modeDomain);
  1283. if (IDOK == dlg.DoModal())
  1284. strDomainName = dlg.GetSelectedName();
  1285. else
  1286. return;
  1287. }
  1288. else if (nIndex < container.GetSize())
  1289. {
  1290. CDomain & domain = container.ElementAt(nIndex);
  1291. strDomainName = domain.m_strName;
  1292. }
  1293. else
  1294. {
  1295. ASSERT(FALSE);
  1296. return;
  1297. }
  1298. AfxShowSlist(CStockContainer::typeDomain, strDomainName);
  1299. }
  1300. void CMainFrame::OnSlistGroupRange(UINT nCmdID)
  1301. {
  1302. if (nCmdID < ID_SLIST_GROUP_START || nCmdID > ID_SLIST_GROUP_END)
  1303. {
  1304. ASSERT(FALSE);
  1305. return;
  1306. }
  1307. CDomainContainer &container = AfxGetGroupContainer();
  1308. int nIndex = nCmdID - ID_SLIST_GROUP_START;
  1309. CString strGroupName;
  1310. if (ID_SLIST_GROUP_END == nCmdID)
  1311. {
  1312. CSelectGrpDlg dlg;
  1313. dlg.SetMode(CSelectGrpDlg::modeGroup);
  1314. if (IDOK == dlg.DoModal())
  1315. strGroupName = dlg.GetSelectedName();
  1316. else
  1317. return;
  1318. }
  1319. else if (nIndex < container.GetSize())
  1320. {
  1321. CDomain & domain = container.ElementAt(nIndex);
  1322. strGroupName = domain.m_strName;
  1323. }
  1324. else
  1325. {
  1326. ASSERT(FALSE);
  1327. return;
  1328. }
  1329. AfxShowSlist(CStockContainer::typeGroup, strGroupName);
  1330. }
  1331. // 股票列表报价
  1332. void CMainFrame::OnSlistAll() { AfxShowSlist(CStockContainer::typeAll); }
  1333. void CMainFrame::OnSlistShaa() { AfxShowSlist(CStockContainer::typeClassShaa); }
  1334. void CMainFrame::OnSlistShab() { AfxShowSlist(CStockContainer::typeClassShab); }
  1335. void CMainFrame::OnSlistSzna() { AfxShowSlist(CStockContainer::typeClassSzna); }
  1336. void CMainFrame::OnSlistSznb() { AfxShowSlist(CStockContainer::typeClassSznb); }
  1337. void CMainFrame::OnSlistShabond() { AfxShowSlist(CStockContainer::typeClassShabond); }
  1338. void CMainFrame::OnSlistSznbond() { AfxShowSlist(CStockContainer::typeClassSznbond); }
  1339. // 股票列表涨跌排名
  1340. void CMainFrame::OnSlistShaasortdp() { AfxShowSlistSortDP(CStockContainer::typeClassShaa); }
  1341. void CMainFrame::OnSlistShabsortdp() { AfxShowSlistSortDP(CStockContainer::typeClassShab); }
  1342. void CMainFrame::OnSlistSznasortdp() { AfxShowSlistSortDP(CStockContainer::typeClassSzna); }
  1343. void CMainFrame::OnSlistSznbsortdp() { AfxShowSlistSortDP(CStockContainer::typeClassSznb); }
  1344. void CMainFrame::OnSlistShabondsortdp() { AfxShowSlistSortDP(CStockContainer::typeClassShabond); }
  1345. void CMainFrame::OnSlistSznbondsortdp() { AfxShowSlistSortDP(CStockContainer::typeClassSznbond); }
  1346. void CMainFrame::OnSlistSetcolumn()
  1347. {
  1348. CSListView * pView = AfxGetSListView();
  1349. if (pView)
  1350. pView->StoreColumnOrderArray();
  1351. CSetColumnDlg dlg;
  1352. if (IDOK == dlg.DoModal())
  1353. {
  1354. // Show
  1355. CSListView * pView = AfxGetSListView();
  1356. if (pView)
  1357. pView->ResetColumns();
  1358. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SLISTVIEW, NULL);
  1359. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SELECTORVIEW, NULL);
  1360. }
  1361. }
  1362. void CMainFrame::OnSlistBaseindex() 
  1363. {
  1364. CBaseIndexDlg dlg;
  1365. if (IDOK == dlg.DoModal() && dlg.m_bAddToList)
  1366. {
  1367. // Show
  1368. CSListView * pView = AfxGetSListView();
  1369. if (pView)
  1370. pView->ResetColumns();
  1371. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SLISTVIEW, NULL);
  1372. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SELECTORVIEW, NULL);
  1373. }
  1374. }
  1375. void CMainFrame::OnSlistbarDate() { }
  1376. void CMainFrame::OnSlistbarName() { }
  1377. ////////////////////////////////////////////////////////////////////////////////
  1378. // “技术”菜单
  1379. // 指数日线显示
  1380. void CMainFrame::OnViewViewszzs() { AfxShowStockGraph(STKLIB_CODE_SZZS); }
  1381. void CMainFrame::OnViewViewszybl() { AfxShowStockGraph(STKLIB_CODE_SZYBL); }
  1382. void CMainFrame::OnViewViewszag() { AfxShowStockGraph(STKLIB_CODE_SZAG); }
  1383. void CMainFrame::OnViewViewszbg() { AfxShowStockGraph(STKLIB_CODE_SZBG); }
  1384. void CMainFrame::OnViewViewszncz() { AfxShowStockGraph(STKLIB_CODE_SZNCZ); }
  1385. void CMainFrame::OnViewViewsznzz() { AfxShowStockGraph(STKLIB_CODE_SZNZZ); }
  1386. void CMainFrame::OnViewViewszncfaz(){ AfxShowStockGraph(STKLIB_CODE_SZNCFAZ); }
  1387. void CMainFrame::OnViewViewszncfbz(){ AfxShowStockGraph(STKLIB_CODE_SZNCFBZ); }
  1388. void CMainFrame::OnViewTechoption()
  1389. {
  1390. CSetParamDlg dlg;
  1391. dlg.DoModal();
  1392. CGraphView * pGraphView = AfxGetGraphView();
  1393. if (pGraphView)
  1394. pGraphView->OnTechParametersChange();
  1395. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_GRAPHVIEW, NULL);
  1396. }
  1397. #define SWITCH_SHOW_GRAPH_COMMAND(nID, nIDLast)
  1398. AfxSwitchToStaticView(RUNTIME_CLASS(CGraphView));
  1399. ::PostMessage(AfxGetGraphView()->GetSafeHwnd(), WM_COMMAND, nID, nIDLast);
  1400. #define UPDATE_GRAPH_CMDUI(pCmdUI, updateFunc)
  1401. CGraphView * pGraphView = AfxGetGraphView();
  1402. if (pGraphView)
  1403. pGraphView->updateFunc(pCmdUI);
  1404. else
  1405. pCmdUI->Enable(TRUE);
  1406. // K线图周期
  1407. void CMainFrame::OnViewPday() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PDAY, 0); }
  1408. void CMainFrame::OnUpdateViewPday(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewPday); }
  1409. void CMainFrame::OnViewPweek() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PWEEK, 0); }
  1410. void CMainFrame::OnUpdateViewPweek(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewPweek); }
  1411. void CMainFrame::OnViewPmonth() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PMONTH, 0); }
  1412. void CMainFrame::OnUpdateViewPmonth(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewPmonth); }
  1413. void CMainFrame::OnViewPmin5() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PMIN5, 0); }
  1414. void CMainFrame::OnUpdateViewPmin5(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewPmin5); }
  1415. void CMainFrame::OnViewPmin15() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PMIN15, 0); }
  1416. void CMainFrame::OnUpdateViewPmin15(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewPmin15); }
  1417. void CMainFrame::OnViewPmin30() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PMIN30, 0); }
  1418. void CMainFrame::OnUpdateViewPmin30(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewPmin30); }
  1419. void CMainFrame::OnViewPmin60() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PMIN60, 0); }
  1420. void CMainFrame::OnUpdateViewPmin60(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewPmin60); }
  1421. // K线图移动
  1422. void CMainFrame::OnViewLeft() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_LEFT, 0); }
  1423. void CMainFrame::OnViewRight() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_RIGHT, 0); }
  1424. void CMainFrame::OnViewPageleft() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PAGELEFT, 0); }
  1425. void CMainFrame::OnViewPageright() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PAGERIGHT, 0); }
  1426. void CMainFrame::OnViewHome() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_HOME, 0); }
  1427. void CMainFrame::OnViewEnd() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_END, 0); }
  1428. void CMainFrame::OnViewZoomin() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_ZOOMIN, 0); }
  1429. void CMainFrame::OnViewZoomout() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_ZOOMOUT, 0); }
  1430. void CMainFrame::OnViewPrev() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_PREV, 0); }
  1431. void CMainFrame::OnViewNext() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_NEXT, 0); }
  1432. void CMainFrame::OnViewInsert() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_INSERT, 0); }
  1433. void CMainFrame::OnViewTechRange(UINT nCmdID) { SWITCH_SHOW_GRAPH_COMMAND(nCmdID, 0); }
  1434. void CMainFrame::OnUpdateViewTechRange(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewTechRange); }
  1435. // K Format
  1436. void CMainFrame::OnViewNoresumedr() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_NORESUMEDR, 0); }
  1437. void CMainFrame::OnUpdateViewNoresumedr(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewNoresumedr); }
  1438. void CMainFrame::OnViewResumedrup() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_RESUMEDRUP, 0); }
  1439. void CMainFrame::OnUpdateViewResumedrup(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewResumedrup); }
  1440. void CMainFrame::OnViewResumedrdown() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_RESUMEDRDOWN, 0); }
  1441. void CMainFrame::OnUpdateViewResumedrdown(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewResumedrdown); }
  1442. // Main data Type
  1443. void CMainFrame::OnViewMaindataclose() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_MAINDATACLOSE, 0); }
  1444. void CMainFrame::OnUpdateViewMaindataclose(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewMaindataclose); }
  1445. void CMainFrame::OnViewMaindataopen() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_MAINDATAOPEN, 0); }
  1446. void CMainFrame::OnUpdateViewMaindataopen(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewMaindataopen); }
  1447. void CMainFrame::OnViewMaindataaverage(){ SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_MAINDATAAVERAGE, 0);}
  1448. void CMainFrame::OnUpdateViewMaindataaverage(CCmdUI* pCmdUI){ UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewMaindataaverage); }
  1449. // kline Mode
  1450. void CMainFrame::OnViewKlinecandle() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_KLINECANDLE, 0); }
  1451. void CMainFrame::OnUpdateViewKlinecandle(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewKlinecandle); }
  1452. void CMainFrame::OnViewKlineamerica() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_KLINEAMERICA, 0); }
  1453. void CMainFrame::OnUpdateViewKlineamerica(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewKlineamerica); }
  1454. void CMainFrame::OnViewKlinetower() { SWITCH_SHOW_GRAPH_COMMAND(ID_VIEW_KLINETOWER, 0); }
  1455. void CMainFrame::OnUpdateViewKlinetower(CCmdUI* pCmdUI) { UPDATE_GRAPH_CMDUI(pCmdUI,OnUpdateViewKlinetower); }
  1456. ////////////////////////////////////////////////////////////////////////////////
  1457. // “行情”菜单
  1458. // 指数实时行情显示
  1459. void CMainFrame::OnRealtimeViewszzs() { AfxShowStockRealTime(STKLIB_CODE_SZZS); }
  1460. void CMainFrame::OnRealtimeViewszybl() { AfxShowStockRealTime(STKLIB_CODE_SZYBL); }
  1461. void CMainFrame::OnRealtimeViewszag() { AfxShowStockRealTime(STKLIB_CODE_SZAG); }
  1462. void CMainFrame::OnRealtimeViewszbg() { AfxShowStockRealTime(STKLIB_CODE_SZBG); }
  1463. void CMainFrame::OnRealtimeViewszncz() { AfxShowStockRealTime(STKLIB_CODE_SZNCZ); }
  1464. void CMainFrame::OnRealtimeViewsznzz() { AfxShowStockRealTime(STKLIB_CODE_SZNZZ); }
  1465. void CMainFrame::OnRealtimeViewszncfaz() { AfxShowStockRealTime(STKLIB_CODE_SZNCFAZ); }
  1466. void CMainFrame::OnRealtimeViewszncfbz() { AfxShowStockRealTime(STKLIB_CODE_SZNCFBZ); }
  1467. #define SWITCH_SHOW_REALTIME_COMMAND(nID, nIDLast)
  1468. AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1469. ::PostMessage(AfxGetRealTimeView()->GetSafeHwnd(), WM_COMMAND, nID, nIDLast);
  1470. #define SWITCH_SHOW_REALTIME_MULTISTOCK(nMultiStockCount)
  1471. AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1472. CRealTimeView * pView = AfxGetRealTimeView();
  1473. if (pView) pView->ShowMultiStock(nMultiStockCount);
  1474. // 实时行情键盘响应
  1475. void CMainFrame::OnRealtimeLeft() { SWITCH_SHOW_REALTIME_COMMAND(ID_REALTIME_LEFT, 0); }
  1476. void CMainFrame::OnRealtimeRight() { SWITCH_SHOW_REALTIME_COMMAND(ID_REALTIME_RIGHT, 0); }
  1477. void CMainFrame::OnRealtimeHome() { SWITCH_SHOW_REALTIME_COMMAND(ID_REALTIME_HOME, 0); }
  1478. void CMainFrame::OnRealtimeEnd() { SWITCH_SHOW_REALTIME_COMMAND(ID_REALTIME_END, 0); }
  1479. void CMainFrame::OnRealtimePrev() { SWITCH_SHOW_REALTIME_COMMAND(ID_REALTIME_PREV, 0); }
  1480. void CMainFrame::OnRealtimeNext() { SWITCH_SHOW_REALTIME_COMMAND(ID_REALTIME_NEXT, 0); }
  1481. void CMainFrame::OnRealtimeOnestock() { SWITCH_SHOW_REALTIME_MULTISTOCK(1); }
  1482. void CMainFrame::OnRealtimeTwostock() { SWITCH_SHOW_REALTIME_MULTISTOCK(2); }
  1483. void CMainFrame::OnRealtimeFourstock() { SWITCH_SHOW_REALTIME_MULTISTOCK(4); }
  1484. void CMainFrame::OnRealtimeSixstock() { SWITCH_SHOW_REALTIME_MULTISTOCK(6); }
  1485. void CMainFrame::OnRealtimeNinestock() { SWITCH_SHOW_REALTIME_MULTISTOCK(9); }
  1486. void CMainFrame::OnUpdateRealtimeOnestock(CCmdUI* pCmdUI)
  1487. { CRealTimeView * pView = AfxGetRealTimeView();
  1488. pCmdUI->SetCheck(pView && 1 == pView->GetShowMultiStock()); }
  1489. void CMainFrame::OnUpdateRealtimeTwostock(CCmdUI* pCmdUI)
  1490. { CRealTimeView * pView = AfxGetRealTimeView();
  1491. pCmdUI->SetCheck(pView && 2 == pView->GetShowMultiStock()); }
  1492. void CMainFrame::OnUpdateRealtimeFourstock(CCmdUI* pCmdUI)
  1493. { CRealTimeView * pView = AfxGetRealTimeView();
  1494. pCmdUI->SetCheck(pView && 4 == pView->GetShowMultiStock()); }
  1495. void CMainFrame::OnUpdateRealtimeSixstock(CCmdUI* pCmdUI)
  1496. { CRealTimeView * pView = AfxGetRealTimeView();
  1497. pCmdUI->SetCheck(pView && 6 == pView->GetShowMultiStock()); }
  1498. void CMainFrame::OnUpdateRealtimeNinestock(CCmdUI* pCmdUI)
  1499. { CRealTimeView * pView = AfxGetRealTimeView();
  1500. pCmdUI->SetCheck(pView && 9 == pView->GetShowMultiStock()); }
  1501. void CMainFrame::OnRealtimePriceline()
  1502. { AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1503. CRealTimeView * pView = AfxGetRealTimeView();
  1504. if (pView) pView->ChangeDrawMode(CRealTime::modePriceLine); }
  1505. void CMainFrame::OnRealtimeReportdetail()
  1506. { AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1507. CRealTimeView * pView = AfxGetRealTimeView();
  1508. if (pView) pView->ChangeDrawMode(CRealTime::modeReportDetail); }
  1509. void CMainFrame::OnRealtimeMinutedetail()
  1510. { AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1511. CRealTimeView * pView = AfxGetRealTimeView();
  1512. if (pView) pView->ChangeDrawMode(CRealTime::modeMinuteDetail); }
  1513. void CMainFrame::OnRealtimeBigtradedetail()
  1514. { AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1515. CRealTimeView * pView = AfxGetRealTimeView();
  1516. if (pView) pView->ChangeDrawMode(CRealTime::modeBigTradeDetail); }
  1517. void CMainFrame::OnRealtimeLbdk()
  1518. { AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1519. CRealTimeView * pView = AfxGetRealTimeView();
  1520. if (pView) pView->ChangeDrawMode(CRealTime::modePriceLine);
  1521. if (pView) pView->ToggleDrawTechLine(CRealTime::techLBDK); }
  1522. void CMainFrame::OnRealtimeMmld()
  1523. { AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
  1524. CRealTimeView * pView = AfxGetRealTimeView();
  1525. if (pView) pView->ChangeDrawMode(CRealTime::modePriceLine);
  1526. if (pView) pView->ToggleDrawTechLine(CRealTime::techMMLD); }
  1527. void CMainFrame::OnUpdateRealtimePriceline(CCmdUI* pCmdUI)
  1528. { CRealTimeView * pView = AfxGetRealTimeView();
  1529. pCmdUI->SetCheck(pView && CRealTime::modePriceLine == pView->GetDrawMode()); }
  1530. void CMainFrame::OnUpdateRealtimeReportdetail(CCmdUI* pCmdUI)
  1531. { CRealTimeView * pView = AfxGetRealTimeView();
  1532. pCmdUI->SetCheck(pView && CRealTime::modeReportDetail == pView->GetDrawMode()); }
  1533. void CMainFrame::OnUpdateRealtimeMinutedetail(CCmdUI* pCmdUI)
  1534. { CRealTimeView * pView = AfxGetRealTimeView();
  1535. pCmdUI->SetCheck(pView && CRealTime::modeMinuteDetail == pView->GetDrawMode()); }
  1536. void CMainFrame::OnUpdateRealtimeBigtradedetail(CCmdUI* pCmdUI)
  1537. { CRealTimeView * pView = AfxGetRealTimeView();
  1538. pCmdUI->SetCheck(pView && CRealTime::modeBigTradeDetail == pView->GetDrawMode()); }
  1539. void CMainFrame::OnUpdateRealtimeLbdk(CCmdUI* pCmdUI)
  1540. { CRealTimeView * pView = AfxGetRealTimeView();
  1541. pCmdUI->SetCheck(pView && CRealTime::techLBDK == pView->GetDrawTechLine()); }
  1542. void CMainFrame::OnUpdateRealtimeMmld(CCmdUI* pCmdUI)
  1543. { CRealTimeView * pView = AfxGetRealTimeView();
  1544. pCmdUI->SetCheck(pView && CRealTime::techMMLD == pView->GetDrawTechLine()); }
  1545. // 分类股票综合排序
  1546. void CMainFrame::OnRealtimeMsszag() { AfxShowMultiSort(CStock::typeshA); }
  1547. void CMainFrame::OnRealtimeMsszbg() { AfxShowMultiSort(CStock::typeshB); }
  1548. void CMainFrame::OnRealtimeMsszzq() { AfxShowMultiSort(CStock::typeshBond); }
  1549. void CMainFrame::OnRealtimeMssznag() { AfxShowMultiSort(CStock::typeszA); }
  1550. void CMainFrame::OnRealtimeMssznbg() { AfxShowMultiSort(CStock::typeszB); }
  1551. void CMainFrame::OnRealtimeMssznzq() { AfxShowMultiSort(CStock::typeszBond); }
  1552. static LONG GetMultiSortClass()
  1553. {
  1554. CMultiSortView * pMultiSortView = AfxGetMultiSortView();
  1555. if (pMultiSortView)
  1556. return pMultiSortView->GetMultiSortClass();
  1557. return CStock::typeNone;
  1558. }
  1559. void CMainFrame::OnUpdateRealtimeMsszag(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CStock::typeshA == GetMultiSortClass()); }
  1560. void CMainFrame::OnUpdateRealtimeMsszbg(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CStock::typeshB == GetMultiSortClass()); }
  1561. void CMainFrame::OnUpdateRealtimeMsszzq(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CStock::typeshBond == GetMultiSortClass()); }
  1562. void CMainFrame::OnUpdateRealtimeMssznag(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CStock::typeszA == GetMultiSortClass()); }
  1563. void CMainFrame::OnUpdateRealtimeMssznbg(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CStock::typeszB == GetMultiSortClass()); }
  1564. void CMainFrame::OnUpdateRealtimeMssznzq(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CStock::typeszBond == GetMultiSortClass()); }
  1565. // 在线资讯
  1566. void CMainFrame::OnInfoSelf() { AfxShowInfo(CInfoView::serverSelf); }
  1567. void CMainFrame::OnInfoF10() { AfxShowInfo(CInfoView::serverF10); }
  1568. void CMainFrame::OnInfoStockstar() { AfxShowInfo(CInfoView::serverStockstar); }
  1569. void CMainFrame::OnInfoSohu() { AfxShowInfo(CInfoView::serverSohu); }
  1570. void CMainFrame::OnInfoSina() { AfxShowInfo(CInfoView::serverSina); }
  1571. void CMainFrame::OnInfo163() { AfxShowInfo(CInfoView::server163); }
  1572. void CMainFrame::OnInfoShse() { AfxShowInfo(CInfoView::serverShse); }
  1573. void CMainFrame::OnInfoSzse() { AfxShowInfo(CInfoView::serverSzse); }
  1574. void CMainFrame::OnInfoHkex() { AfxShowInfo(CInfoView::serverHkex); }
  1575. void CMainFrame::OnInfoLse() { AfxShowInfo(CInfoView::serverLse); }
  1576. void CMainFrame::OnInfoNyse() { AfxShowInfo(CInfoView::serverNyse); }
  1577. void CMainFrame::OnInfoNasdaq() { AfxShowInfo(CInfoView::serverNasdaq); }
  1578. void CMainFrame::OnInfoP5w() { AfxShowInfo(CInfoView::serverP5w); }
  1579. void CMainFrame::OnInfoSsnews() { AfxShowInfo(CInfoView::serverSsnews); }
  1580. void CMainFrame::OnInfoCs() { AfxShowInfo(CInfoView::serverCs); }
  1581. static int GetInfoServer()
  1582. {
  1583. CInfoView * pInfoView = AfxGetInfoView();
  1584. if (pInfoView)
  1585. return pInfoView->GetCurrentServer();
  1586. return CInfoView::serverUnknown;
  1587. }
  1588. void CMainFrame::OnUpdateInfoSelf(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverSelf == GetInfoServer()); }
  1589. void CMainFrame::OnUpdateInfoF10(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverF10 == GetInfoServer()); }
  1590. void CMainFrame::OnUpdateInfoStockstar(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverStockstar == GetInfoServer()); }
  1591. void CMainFrame::OnUpdateInfoSohu(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverSohu == GetInfoServer()); }
  1592. void CMainFrame::OnUpdateInfoSina(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverSina == GetInfoServer()); }
  1593. void CMainFrame::OnUpdateInfo163(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::server163 == GetInfoServer()); }
  1594. void CMainFrame::OnUpdateInfoShse(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverShse == GetInfoServer()); }
  1595. void CMainFrame::OnUpdateInfoSzse(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverSzse == GetInfoServer()); }
  1596. void CMainFrame::OnUpdateInfoHkex(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverHkex == GetInfoServer()); }
  1597. void CMainFrame::OnUpdateInfoLse(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverLse == GetInfoServer()); }
  1598. void CMainFrame::OnUpdateInfoNyse(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverNyse == GetInfoServer()); }
  1599. void CMainFrame::OnUpdateInfoNasdaq(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverNasdaq == GetInfoServer()); }
  1600. void CMainFrame::OnUpdateInfoP5w(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverP5w == GetInfoServer()); }
  1601. void CMainFrame::OnUpdateInfoSsnews(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverSsnews == GetInfoServer()); }
  1602. void CMainFrame::OnUpdateInfoCs(CCmdUI* pCmdUI) { pCmdUI->SetCheck(CInfoView::serverCs == GetInfoServer()); }
  1603. ////////////////////////////////////////////////////////////////////////////////
  1604. // “策略”菜单
  1605. // 策略
  1606. void CMainFrame::OnStrategyProperty() 
  1607. {
  1608. CSimuView * pSimuView = AfxGetSimuView();
  1609. if (pSimuView && !pSimuView->StoreToStrategy())
  1610. return;
  1611. CStrategy * pStrategy = AfxGetActiveStrategy();
  1612. if (pStrategy)
  1613. {
  1614. CSetPrpt firstPage(NULL, IDS_STRATEGY_SETPRPT, NULL);
  1615. firstPage.SetStrategy(pStrategy);
  1616. CSelectStk selectStk(NULL, IDS_STRATEGY_SELECTSTK, NULL);
  1617. selectStk.m_dwButtonFlags = 0;
  1618. selectStk.m_domainTemp.Copy(pStrategy->GetStocks());
  1619. CSetRule setrule(NULL, IDS_STRATEGY_SETRULE, NULL);
  1620. setrule.SetTechParameters(&(pStrategy->GetTechParametersBuy()), &(pStrategy->GetSelectedTechsBuy()));
  1621. CSetRate setrate(NULL, IDS_STRATEGY_SETRATE, NULL);
  1622. setrate.SetStrategy(pStrategy);
  1623. CPropertySheet sht;
  1624. sht.AddPage(&firstPage);
  1625. sht.AddPage(&selectStk);
  1626. sht.AddPage(&setrule);
  1627. sht.AddPage(&setrate);
  1628. sht.SetActivePage(&firstPage);
  1629. //CBitmap bmp;
  1630. //bmp.LoadBitmap(IDB_BALANG);
  1631. //sht.SetBitmap((HBITMAP)bmp.GetSafeHandle());
  1632. sht.DoModal();
  1633. pStrategy->SetStocks(selectStk.m_domainTemp);
  1634. pStrategy->DoFileSave();
  1635. //AfxOnStrategyUpdated(pStrategy, selectStk.m_bModified || setrule.m_bModified || setrate.m_bModified);
  1636. }
  1637. }
  1638. void CMainFrame::OnUpdateStrategyProperty(CCmdUI* pCmdUI) 
  1639. {
  1640. CStrategy * pStrategy = AfxGetActiveStrategy();
  1641. pCmdUI->Enable(pStrategy && pStrategy->CanModifiedNow());
  1642. }
  1643. void CMainFrame::OnStrategyStocks() 
  1644. {
  1645. CSimuView * pSimuView = AfxGetSimuView();
  1646. if (pSimuView && !pSimuView->StoreToStrategy())
  1647. return;
  1648. CStrategy * pStrategy = AfxGetActiveStrategy();
  1649. if (pStrategy)
  1650. {
  1651. CSetPrpt firstPage(NULL, IDS_STRATEGY_SETPRPT, NULL);
  1652. firstPage.SetStrategy(pStrategy);
  1653. CSelectStk selectStk(NULL, IDS_STRATEGY_SELECTSTK, NULL);
  1654. selectStk.m_dwButtonFlags = 0;
  1655. selectStk.m_domainTemp.Copy(pStrategy->GetStocks());
  1656. CSetRule setrule(NULL, IDS_STRATEGY_SETRULE, NULL);
  1657. setrule.SetTechParameters(&(pStrategy->GetTechParametersBuy()), &(pStrategy->GetSelectedTechsBuy()));
  1658. CSetRate setrate(NULL, IDS_STRATEGY_SETRATE, NULL);
  1659. setrate.SetStrategy(pStrategy);
  1660. CPropertySheet sht;
  1661. sht.AddPage(&firstPage);
  1662. sht.AddPage(&selectStk);
  1663. sht.AddPage(&setrule);
  1664. sht.AddPage(&setrate);
  1665. sht.SetActivePage(&selectStk);
  1666. //CBitmap bmp;
  1667. //bmp.LoadBitmap(IDB_BALANG);
  1668. //sht.SetBitmap((HBITMAP)bmp.GetSafeHandle());
  1669. sht.DoModal();
  1670. pStrategy->SetStocks(selectStk.m_domainTemp);
  1671. pStrategy->DoFileSave();
  1672. //AfxOnStrategyUpdated(pStrategy, selectStk.m_bModified || setrule.m_bModified || setrate.m_bModified);
  1673. }
  1674. }
  1675. void CMainFrame::OnUpdateStrategyStocks(CCmdUI* pCmdUI) 
  1676. {
  1677. CStrategy * pStrategy = AfxGetActiveStrategy();
  1678. pCmdUI->Enable(pStrategy && pStrategy->CanModifiedNow());
  1679. }
  1680. void CMainFrame::OnStrategySetRule() 
  1681. {
  1682. CSimuView * pSimuView = AfxGetSimuView();
  1683. if (pSimuView && !pSimuView->StoreToStrategy())
  1684. return;
  1685. CStrategy * pStrategy = AfxGetActiveStrategy();
  1686. if (pStrategy)
  1687. {
  1688. CSetPrpt firstPage(NULL, IDS_STRATEGY_SETPRPT, NULL);
  1689. firstPage.SetStrategy(pStrategy);
  1690. CSelectStk selectStk(NULL, IDS_STRATEGY_SELECTSTK, NULL);
  1691. selectStk.m_dwButtonFlags = 0;
  1692. selectStk.m_domainTemp.Copy(pStrategy->GetStocks());
  1693. CSetRule setrule(NULL, IDS_STRATEGY_SETRULE, NULL);
  1694. setrule.SetTechParameters(&(pStrategy->GetTechParametersBuy()), &(pStrategy->GetSelectedTechsBuy()));
  1695. CSetRate setrate(NULL, IDS_STRATEGY_SETRATE, NULL);
  1696. setrate.SetStrategy(pStrategy);
  1697. CPropertySheet sht;
  1698. sht.AddPage(&firstPage);
  1699. sht.AddPage(&selectStk);
  1700. sht.AddPage(&setrule);
  1701. sht.AddPage(&setrate);
  1702. sht.SetActivePage(&setrule);
  1703. //CBitmap bmp;
  1704. //bmp.LoadBitmap(IDB_BALANG);
  1705. //sht.SetBitmap((HBITMAP)bmp.GetSafeHandle());
  1706. sht.DoModal();
  1707. pStrategy->SetStocks(selectStk.m_domainTemp);
  1708. pStrategy->DoFileSave();
  1709. //AfxOnStrategyUpdated(pStrategy, selectStk.m_bModified || setrule.m_bModified || setrate.m_bModified);
  1710. }
  1711. }
  1712. void CMainFrame::OnUpdateStrategySetRule(CCmdUI* pCmdUI) 
  1713. {
  1714. CStrategy * pStrategy = AfxGetActiveStrategy();
  1715. pCmdUI->Enable(pStrategy && pStrategy->CanModifiedNow());
  1716. }
  1717. void CMainFrame::OnStrategySetRate() 
  1718. {
  1719. CSimuView * pSimuView = AfxGetSimuView();
  1720. if (pSimuView && !pSimuView->StoreToStrategy())
  1721. return;
  1722. CStrategy * pStrategy = AfxGetActiveStrategy();
  1723. if (pStrategy)
  1724. {
  1725. CSetPrpt firstPage(NULL, IDS_STRATEGY_SETPRPT, NULL);
  1726. firstPage.SetStrategy(pStrategy);
  1727. CSelectStk selectStk(NULL, IDS_STRATEGY_SELECTSTK, NULL);
  1728. selectStk.m_dwButtonFlags = 0;
  1729. selectStk.m_domainTemp.Copy(pStrategy->GetStocks());
  1730. CSetRule setrule(NULL, IDS_STRATEGY_SETRULE, NULL);
  1731. setrule.SetTechParameters(&(pStrategy->GetTechParametersBuy()), &(pStrategy->GetSelectedTechsBuy()));
  1732. CSetRate setrate(NULL, IDS_STRATEGY_SETRATE, NULL);
  1733. setrate.SetStrategy(pStrategy);
  1734. CPropertySheet sht;
  1735. sht.AddPage(&firstPage);
  1736. sht.AddPage(&selectStk);
  1737. sht.AddPage(&setrule);
  1738. sht.AddPage(&setrate);
  1739. sht.SetActivePage(&setrate);
  1740. //CBitmap bmp;
  1741. //bmp.LoadBitmap(IDB_BALANG);
  1742. //sht.SetBitmap((HBITMAP)bmp.GetSafeHandle());
  1743. sht.DoModal();
  1744. pStrategy->SetStocks(selectStk.m_domainTemp);
  1745. pStrategy->DoFileSave();
  1746. //AfxOnStrategyUpdated(pStrategy, selectStk.m_bModified || setrule.m_bModified || setrate.m_bModified);
  1747. }
  1748. }
  1749. void CMainFrame::OnUpdateStrategySetRate(CCmdUI* pCmdUI) 
  1750. {
  1751. CStrategy * pStrategy = AfxGetActiveStrategy();
  1752. pCmdUI->Enable(pStrategy && pStrategy->CanModifiedNow());
  1753. }
  1754. void CMainFrame::OnStrategySimu() 
  1755. {
  1756. AfxSwitchToStaticView(RUNTIME_CLASS(CSimuView));
  1757. }
  1758. void CMainFrame::OnUpdateStrategySimu(CCmdUI* pCmdUI) 
  1759. {
  1760. CStrategy * pStrategy = AfxGetActiveStrategy();
  1761. pCmdUI->Enable(NULL != pStrategy);
  1762. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1763. pCmdUI->SetCheck(pView && pView->IsKindOf(RUNTIME_CLASS(CSimuView)));
  1764. }
  1765. void CMainFrame::OnStrategyReport() 
  1766. {
  1767. CSimuView * pSimuView = AfxGetSimuView();
  1768. if (pSimuView && !pSimuView->StoreToStrategy())
  1769. return;
  1770. CStrategy * pStrategy = AfxGetActiveStrategy();
  1771. if (pStrategy)
  1772. {
  1773. CSimuReport report;
  1774. report.SetStrategy(pStrategy);
  1775. report.DoModal();
  1776. }
  1777. }
  1778. void CMainFrame::OnUpdateStrategyReport(CCmdUI* pCmdUI) 
  1779. {
  1780. CStrategy * pStrategy = AfxGetActiveStrategy();
  1781. pCmdUI->Enable(pStrategy && pStrategy->CanModifiedNow());
  1782. }
  1783. void CMainFrame::OnStrategyRealOp() 
  1784. {
  1785. CSimuView * pSimuView = AfxGetSimuView();
  1786. if (pSimuView && !pSimuView->StoreToStrategy())
  1787. return;
  1788. CStrategy * pStrategy = AfxGetActiveStrategy();
  1789. if (pStrategy)
  1790. {
  1791. { // 运行策略实战,选定下一步操作
  1792. CWaitDlg wait(AfxGetMainWnd(), FALSE);
  1793. wait.SetProgressRange(0, STRATEGY_MAX_PROGRESS);
  1794. pStrategy->ClearCache();
  1795. pStrategy->RealRun(RealRunCallback, wait.GetSafeHwnd());
  1796. wait.DestroyWindow();
  1797. }
  1798. CSimuRealOp realop;
  1799. realop.SetStrategy(pStrategy);
  1800. realop.DoModal();
  1801. pStrategy->OnRealOpViewed();
  1802. pStrategy->DoFileSave();
  1803. //AfxOnStrategyUpdated(pStrategy, realop.m_bModified);
  1804. }
  1805. }
  1806. void CMainFrame::OnUpdateStrategyRealOp(CCmdUI* pCmdUI) 
  1807. {
  1808. CStrategy * pStrategy = AfxGetActiveStrategy();
  1809. pCmdUI->Enable(pStrategy && pStrategy->CanModifiedNow());
  1810. }
  1811. ////////////////////////////////////////////////////////////////////////////////
  1812. // “数据”菜单
  1813. // 数据
  1814. void CMainFrame::OnDataDownload() 
  1815. {
  1816. CDownloadDlg * dlg = new CDownloadDlg;
  1817. dlg->Create(CDownloadDlg::IDD, this);
  1818. //dlg->SetAutoDelete(TRUE);
  1819. dlg->CenterWindow(this);
  1820. dlg->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOSIZE);
  1821. }
  1822. void CMainFrame::OnDataDatasource() 
  1823. {
  1824. CDataSrcDlg dlg;
  1825. dlg.DoModal();
  1826. }
  1827. void CMainFrame::OnDataManage() 
  1828. {
  1829. CInstallPacDlg installdlg;
  1830. CTyDataDlg tydata;
  1831. CSetDrdataDlg setdr;
  1832. CSetBaseDlg setbase;
  1833. CSetBasedataDlg setbasedata;
  1834. CSetKDataDlg setkdata;
  1835. CPropertySheet sht;
  1836. sht.AddPage(&installdlg);
  1837. sht.AddPage(&tydata);
  1838. sht.AddPage(&setdr);
  1839. sht.AddPage(&setbase);
  1840. sht.AddPage(&setbasedata);
  1841. sht.AddPage(&setkdata);
  1842. sht.SetActivePage(&installdlg);
  1843. sht.DoModal();
  1844. }
  1845. void CMainFrame::OnDataExport() 
  1846. {
  1847. CSelectStk selectStk(NULL, IDS_EXPORT_SELECTSTK, NULL);
  1848. selectStk.m_dwButtonFlags = PSWIZB_NEXT | PSWIZB_DISABLEDFINISH;
  1849. CExportOption option(NULL, IDS_EXPORT_OPTION, NULL);
  1850. option.m_dwButtonFlags = PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_DISABLEDFINISH;
  1851. CExportDest dest(NULL, IDS_EXPORT_DEST, NULL);
  1852. dest.m_dwButtonFlags = PSWIZB_BACK | PSWIZB_NEXT;
  1853. CPropertySheet sht;
  1854. sht.AddPage(&selectStk);
  1855. sht.AddPage(&option);
  1856. sht.AddPage(&dest);
  1857. sht.SetWizardMode();
  1858. sht.m_psh.dwFlags |= (PSH_WIZARD97 | PSH_WIZARDHASFINISH /* | PSH_HEADER /*Header Bitmap*/);
  1859. //CBitmap bmp;
  1860. //bmp.LoadBitmap(IDB_BALANG);
  1861. //sht.SetBitmap((HBITMAP)bmp.GetSafeHandle());
  1862. sht.DoModal();
  1863. }
  1864. void CMainFrame::OnDataRecalculateyield() 
  1865. {
  1866. AfxRecalculateYield(AfxGetProfile().GetYieldAverageDays(), TRUE);
  1867. AfxGetStockContainer().ReloadBase(&AfxGetDB());
  1868. AfxGetSListStockContainer().ReRetrieveFromStatic(AfxGetActiveStrategy());
  1869. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SLISTVIEW, NULL);
  1870. AfxGetStaticDoc()->UpdateAllViews(NULL, UPDATE_HINT_SELECTORVIEW, NULL);
  1871. }
  1872. ////////////////////////////////////////////////////////////////////////////////
  1873. // “选项”菜单
  1874. // 选项
  1875. void CMainFrame::OnOptionAddtogroupRange(UINT nCmdID)
  1876. {
  1877. if (nCmdID < ID_OPTION_ADDTOGROUP_START || nCmdID > ID_OPTION_ADDTOGROUP_END)
  1878. {
  1879. ASSERT(FALSE);
  1880. return;
  1881. }
  1882. CDomainContainer &container = AfxGetGroupContainer();
  1883. int nIndex = nCmdID - ID_OPTION_ADDTOGROUP_START;
  1884. CString strGroupName;
  1885. if (ID_OPTION_ADDTOGROUP_END == nCmdID)
  1886. {
  1887. CSelectGrpDlg dlg;
  1888. dlg.SetMode(CSelectGrpDlg::modeGroup);
  1889. if (IDOK == dlg.DoModal())
  1890. strGroupName = dlg.GetSelectedName();
  1891. else
  1892. return;
  1893. }
  1894. else if (nIndex < container.GetSize())
  1895. {
  1896. CDomain & domain = container.ElementAt(nIndex);
  1897. strGroupName = domain.m_strName;
  1898. }
  1899. else
  1900. {
  1901. ASSERT(FALSE);
  1902. return;
  1903. }
  1904. CSetGroupDlg dlgSetGroup;
  1905. CSPStringArray astrStocks;
  1906. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1907. if (pView && pView->IsKindOf(RUNTIME_CLASS(CSListView)))
  1908. {
  1909. ((CSListView *)pView)->GetSelectedStocks(astrStocks);
  1910. }
  1911. else if (pView && pView->IsKindOf(RUNTIME_CLASS(CSelectorView)))
  1912. {
  1913. ((CSelectorView *)pView)->GetSelectedStocks(astrStocks);
  1914. }
  1915. else if (pView &&
  1916. (pView->IsKindOf(RUNTIME_CLASS(CGraphView))
  1917. || pView->IsKindOf(RUNTIME_CLASS(CBaseView))
  1918. || pView->IsKindOf(RUNTIME_CLASS(CRealTimeView))))
  1919. {
  1920. CStockInfo info;
  1921. if (AfxGetProfile().GetCurrentStock(&info))
  1922. astrStocks.Add(info.GetStockCode());
  1923. }
  1924. dlgSetGroup.SetInitialGroup(strGroupName);
  1925. dlgSetGroup.AddtoGroup(astrStocks);
  1926. dlgSetGroup.DoModal();
  1927. }
  1928. void CMainFrame::OnUpdateOptionAddtogroupRange(CCmdUI* pCmdUI) 
  1929. {
  1930. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1931. if (pView && pView->IsKindOf(RUNTIME_CLASS(CSListView)))
  1932. {
  1933. CSPStringArray astrStocks;
  1934. ((CSListView *)pView)->GetSelectedStocks(astrStocks);
  1935. pCmdUI->Enable(astrStocks.GetSize() > 0);
  1936. }
  1937. else if (pView && pView->IsKindOf(RUNTIME_CLASS(CSelectorView)))
  1938. {
  1939. CSPStringArray astrStocks;
  1940. ((CSelectorView *)pView)->GetSelectedStocks(astrStocks);
  1941. pCmdUI->Enable(astrStocks.GetSize() > 0);
  1942. }
  1943. else if (pView &&
  1944. (pView->IsKindOf(RUNTIME_CLASS(CGraphView))
  1945. || pView->IsKindOf(RUNTIME_CLASS(CBaseView))
  1946. || pView->IsKindOf(RUNTIME_CLASS(CRealTimeView))))
  1947. {
  1948. CStockInfo info;
  1949. pCmdUI->Enable(AfxGetProfile().GetCurrentStock(&info));
  1950. }
  1951. else
  1952. {
  1953. pCmdUI->Enable(FALSE);
  1954. }
  1955. }
  1956. void CMainFrame::OnOptionAddtostrategy()
  1957. {
  1958. CSelectGrpDlg dlg;
  1959. dlg.SetMode(CSelectGrpDlg::modeStrategy);
  1960. if (IDOK != dlg.DoModal())
  1961. return;
  1962. CStrategy * pStrategy = dlg.GetSelectedStrategy();
  1963. if (NULL == pStrategy)
  1964. return;
  1965. // Get Current Stock
  1966. CSPStringArray astrStocks;
  1967. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1968. if (pView && pView->IsKindOf(RUNTIME_CLASS(CSListView)))
  1969. {
  1970. ((CSListView *)pView)->GetSelectedStocks(astrStocks);
  1971. }
  1972. else if (pView && pView->IsKindOf(RUNTIME_CLASS(CSelectorView)))
  1973. {
  1974. ((CSelectorView *)pView)->GetSelectedStocks(astrStocks);
  1975. }
  1976. else if (pView &&
  1977. (pView->IsKindOf(RUNTIME_CLASS(CGraphView))
  1978. || pView->IsKindOf(RUNTIME_CLASS(CBaseView))
  1979. || pView->IsKindOf(RUNTIME_CLASS(CRealTimeView))))
  1980. {
  1981. CStockInfo info;
  1982. if (AfxGetProfile().GetCurrentStock(&info))
  1983. astrStocks.Add(info.GetStockCode());
  1984. }
  1985. CSPStringArray astr;
  1986. astr.Copy(pStrategy->GetStocks());
  1987. astr.Append(astrStocks);
  1988. pStrategy->SetStocks(astr);
  1989. pStrategy->DoFileSave();
  1990. //AfxOnStrategyUpdated(pStrategy, TRUE);
  1991. }
  1992. void CMainFrame::OnUpdateOptionAddtostrategy(CCmdUI* pCmdUI) 
  1993. {
  1994. CView * pView = AfxGetStaticDoc()->GetActiveView();
  1995. if (pView && pView->IsKindOf(RUNTIME_CLASS(CSListView)))
  1996. {
  1997. CSPStringArray astrStocks;
  1998. ((CSListView *)pView)->GetSelectedStocks(astrStocks);
  1999. pCmdUI->Enable(astrStocks.GetSize() > 0);
  2000. }
  2001. else if (pView && pView->IsKindOf(RUNTIME_CLASS(CSelectorView)))
  2002. {
  2003. CSPStringArray astrStocks;
  2004. ((CSelectorView *)pView)->GetSelectedStocks(astrStocks);
  2005. pCmdUI->Enable(astrStocks.GetSize() > 0);
  2006. }
  2007. else if (pView &&
  2008. (pView->IsKindOf(RUNTIME_CLASS(CGraphView))
  2009. || pView->IsKindOf(RUNTIME_CLASS(CBaseView))
  2010. || pView->IsKindOf(RUNTIME_CLASS(CRealTimeView))))
  2011. {
  2012. CStockInfo info;
  2013. pCmdUI->Enable(AfxGetProfile().GetCurrentStock(&info));
  2014. }
  2015. else
  2016. {
  2017. pCmdUI->Enable(FALSE);
  2018. }
  2019. }
  2020. // 选项
  2021. void CMainFrame::OnOptionProxyset()
  2022. {
  2023. AfxDoProxySetting();
  2024. }
  2025. void CMainFrame::OnOptionSelecttrader()
  2026. {
  2027. CSelectTraderDlg dlg;
  2028. dlg.DoModal();
  2029. }
  2030. void CMainFrame::OnOptionColor()
  2031. {
  2032. //CSetColorDlg* dlg = new CSetColorDlg();
  2033. //dlg->Create(CSetColorDlg::IDD, this);
  2034. //dlg->SetAutoDelete(TRUE);
  2035. //dlg->CenterWindow(this);
  2036. //dlg->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOSIZE);
  2037. }
  2038. void CMainFrame::OnOptionFontslist()
  2039. {
  2040. LOGFONT lf;
  2041. memset(&lf, 0, sizeof(lf));
  2042. AfxGetProfile().GetFontSListView(&lf);
  2043. CFontDialog dlg(&lf, CF_SCREENFONTS);
  2044. if (IDOK == dlg.DoModal())
  2045. {
  2046. AfxGetProfile().SetFontSListView(&lf);
  2047. CSListView * pSListView = AfxGetSListView();
  2048. if (pSListView)
  2049. pSListView->SetFont(&lf);
  2050. }
  2051. }
  2052. void CMainFrame::OnOptionFontbase()
  2053. {
  2054. LOGFONT lf;
  2055. memset(&lf, 0, sizeof(lf));
  2056. AfxGetProfile().GetFontBaseView(&lf);
  2057. CFontDialog dlg(&lf, CF_SCREENFONTS);
  2058. if (IDOK == dlg.DoModal())
  2059. {
  2060. AfxGetProfile().SetFontBaseView(&lf);
  2061. CBaseView * pBaseView = AfxGetBaseView();
  2062. if (pBaseView)
  2063. pBaseView->SetFont(&lf);
  2064. }
  2065. }
  2066. void CMainFrame::OnOptionSetgroup() 
  2067. {
  2068. CSetGroupDlg dlg;
  2069. dlg.DoModal();
  2070. }
  2071. ////////////////////////////////////////////////////////////////////////////////
  2072. // “工具”菜单
  2073. // 工具
  2074. void CMainFrame::OnToolTrader() 
  2075. {
  2076. CString strFile = AfxGetProfile().GetTrader();
  2077. if (0 == access(strFile,0))
  2078. ShellExecute(NULL, "open", strFile, NULL, NULL, SW_SHOW);
  2079. else
  2080. OnOptionSelecttrader();
  2081. }
  2082. void CMainFrame::OnToolNote() 
  2083. {
  2084. ShellExecute(NULL, "open", "notepad.exe",
  2085. NULL, AfxGetProfile().GetWorkDirectory(), SW_SHOW);
  2086. }
  2087. void CMainFrame::OnToolCalculator() 
  2088. {
  2089. ShellExecute(NULL, "open", "calc.exe",
  2090. NULL, AfxGetProfile().GetWorkDirectory(), SW_SHOW);
  2091. }
  2092. void CMainFrame::OnToolFilterinfo()
  2093. {
  2094. CFilterInfoDlg dlg;
  2095. dlg.DoModal();
  2096. }
  2097. void CMainFrame::OnToolAlarm()
  2098. {
  2099. CAlarmSettingDlg alarmsetting;
  2100. CAlarmResultDlg alarmresult;
  2101. CPropertySheet sht;
  2102. sht.AddPage(&alarmsetting);
  2103. sht.AddPage(&alarmresult);
  2104. sht.DoModal();
  2105. }
  2106. ////////////////////////////////////////////////////////////////////////////////
  2107. // “帮助”菜单
  2108. // 帮助
  2109. void CMainFrame::OnHelpShowhelp()
  2110. {
  2111. ::HtmlHelp(NULL, "StockAna.chm::/htm/index.htm", HH_DISPLAY_TOPIC, 0);
  2112. }
  2113. void CMainFrame::OnHelpDeclare() 
  2114. {
  2115. CBitmap bmp;
  2116. bmp.LoadBitmap(IDB_DLGLEFTLOGO);
  2117. CString sText;
  2118. HGLOBAL hRead = NULL;
  2119. HRSRC hReSrc = ::FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_TEXT_DECLARE), _T("Text"));
  2120. if (hReSrc)
  2121. hRead = ::LoadResource(AfxGetResourceHandle(), hReSrc);
  2122. if (hRead)
  2123. {
  2124. LPCTSTR lpText = (LPCTSTR)::LockResource(hRead);
  2125. if (lpText)
  2126. sText = lpText;
  2127. ::UnlockResource(hRead);
  2128. }
  2129. CDeclareDlg dlg;
  2130. dlg.SetBitmap((HBITMAP)bmp.GetSafeHandle());
  2131. dlg.SetDeclareText(sText);
  2132. dlg.DoModal();
  2133. }
  2134. void CMainFrame::OnHelpProduct() 
  2135. {
  2136. CString strURL = AfxGetProfile().GetProductURL();
  2137. int result = (int)AfxGotoURL(strURL, SW_SHOW);
  2138. if (result <= HINSTANCE_ERROR)
  2139. {
  2140. MessageBeep(MB_ICONEXCLAMATION);
  2141. }
  2142. }
  2143. void CMainFrame::OnHelpForum()
  2144. {
  2145. CString strURL = /*AfxGetProfile().GetProductURL()*/_T("http://218.67.244.158/forum");
  2146. int result = (int)AfxGotoURL(strURL, SW_SHOW);
  2147. if (result <= HINSTANCE_ERROR)
  2148. {
  2149. MessageBeep(MB_ICONEXCLAMATION);
  2150. }
  2151. }