DlgOfTop.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. // DlgOfTop.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "IDE.h"
  5. #include "DlgOfTop.h"
  6. #include ".\dlgoftop.h"
  7. //------------------------
  8. #include "Global.h"
  9. //#include "DlgUserManager.h"
  10. //#include "Dlg_GroupManage.h"
  11. //#include "ScriptSetDlg.h"
  12. #include "DlgEditPwd.h"
  13. //#include "DlgQueryWarningRec.h"
  14. //#include "DlgSystemLog.h"
  15. //#include "DlgNoticeRec.h"
  16. #include "SystemParaSetDlg.h"
  17. #include "MainFrm.h"
  18. // CDlgOfTop 对话框
  19. IMPLEMENT_DYNAMIC(CDlgOfTop, CDialog)
  20. CDlgOfTop::CDlgOfTop(CWnd* pParent /*=NULL*/)
  21. : CDialog(CDlgOfTop::IDD, pParent)
  22. {
  23. }
  24. CDlgOfTop::~CDlgOfTop()
  25. {
  26. }
  27. void CDlgOfTop::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. DDX_Control(pDX, STATIC_TOP, m_MainTop);
  31. DDX_Control(pDX, DlgOfTop_Btn_AlarmRecord, _Btn_AlarmRecord);
  32. DDX_Control(pDX, DlgOfTop_Btn_NoticeRecord, _Btn_NoticeRecord);
  33. DDX_Control(pDX, DlgOfTop_Btn_DataRecord, _Btn_DataRecord);
  34. DDX_Control(pDX, DlgOfTop_Btn_SystemRecord, _Btn_SystemRecord);
  35. DDX_Control(pDX, DlgOfTop_Btn_AnalogMgr, _Btn_AnalogMgr);
  36. DDX_Control(pDX, DlgOfTop_Btn_UserMgr, _Btn_UserMgr);
  37. DDX_Control(pDX, DlgOfTop_Btn_ModifyPassWord, _Btn_ModifyPassWord);
  38. DDX_Control(pDX, DlgOfTop_Btn_HomePageConfig, _Btn_HomePageConfig);
  39. DDX_Control(pDX, DlgOfTop_Btn_LeftTree, _Btn_LeftTree);
  40. DDX_Control(pDX, DlgOfTop_Btn_Exit, _Btn_Exit);
  41. }
  42. BEGIN_MESSAGE_MAP(CDlgOfTop, CDialog)
  43. ON_WM_SIZE()
  44. ON_BN_CLICKED(DlgOfTop_Btn_AlarmRecord, OnBnClickedBtnAlarmrecord)
  45. ON_BN_CLICKED(DlgOfTop_Btn_NoticeRecord, OnBnClickedBtnNoticerecord)
  46. ON_BN_CLICKED(DlgOfTop_Btn_DataRecord, OnBnClickedBtnDatarecord)
  47. ON_BN_CLICKED(DlgOfTop_Btn_SystemRecord, OnBnClickedBtnSystemrecord)
  48. ON_BN_CLICKED(DlgOfTop_Btn_AnalogMgr, OnBnClickedBtnAnalogmgr)
  49. ON_BN_CLICKED(DlgOfTop_Btn_UserMgr, OnBnClickedBtnUsermgr)
  50. ON_BN_CLICKED(DlgOfTop_Btn_ModifyPassWord, OnBnClickedBtnModifypassword)
  51. ON_BN_CLICKED(DlgOfTop_Btn_HomePageConfig, OnBnClickedBtnHomepageconfig)
  52. ON_BN_CLICKED(DlgOfTop_Btn_LeftTree, OnBnClickedBtnLefttree)
  53. ON_BN_CLICKED(DlgOfTop_Btn_Exit, OnBnClickedBtnExit)
  54. END_MESSAGE_MAP()
  55. // CDlgOfTop 消息处理程序
  56. BOOL CDlgOfTop::OnInitDialog()
  57. {
  58. CDialog::OnInitDialog();
  59. // TODO: 在此添加额外的初始化
  60. SetWindowPos(NULL,0,0,_ClientSize.cx,_ClientSize.cy,SWP_NOMOVE);
  61. LoadSkin(".\\Themes\\DefaultTheme\\DefaultTheme.ini");
  62. return TRUE; // return TRUE unless you set the focus to a control
  63. // 异常: OCX 属性页应返回 FALSE
  64. }
  65. // 75,805
  66. void CDlgOfTop::CalcWindowRect(const CSize &cs)
  67. {
  68. CRect rtWindow;
  69. rtWindow.left = 0;
  70. rtWindow.top = 0;
  71. rtWindow.right = cs.cx;
  72. rtWindow.bottom = cs.cy;
  73. MoveWindow(rtWindow);
  74. //m_MainTop.RedrawWindow(rtWindow,NULL); // 重绘 [8/29/2013 Z.t]
  75. //LOG4C((LOG_NOTICE,"%d,%d,%d,%d",rtWindow.left,rtWindow.top,rtWindow.right,rtWindow.bottom));
  76. TRACE("----done movewindow----");
  77. LoadSkin(".\\Themes\\DefaultTheme\\DefaultTheme.ini");
  78. }
  79. void CDlgOfTop::OnCancel()
  80. {
  81. // TODO: 在此添加专用代码和/或调用基类
  82. //CDialog::OnCancel();
  83. }
  84. void CDlgOfTop::OnOK()
  85. {
  86. // TODO: 在此添加专用代码和/或调用基类
  87. //CDialog::OnOK();
  88. }
  89. CString CDlgOfTop::GetPathName(const char *filename)
  90. {
  91. char path[MAX_PATH];
  92. strcpy( path, filename );
  93. char *p = path + strlen( path );
  94. for ( ; *p != '\\' && *p != '/' && p > path; p-- );
  95. if ( *p == '\\' || *p == '/')
  96. p++;
  97. *p = 0;
  98. return CString(path);
  99. }
  100. /************************************************************************/
  101. /*
  102. 注意: 左上角坐标为(0,0), 向右为+x, 向下+y;
  103. ①.屏幕分辨率;(x,y)
  104. ②.背景图片尺寸;(x1,y1) ->固定的
  105. ③.被裁图片在背景图片的实际位置;(x2,y2) ->固定的
  106. ④.被裁图片在背景图片的运行位置;(x3,y3)
  107. ⑤.
  108. ⑥.
  109. ⑦⑧⑨⑩
  110. //----------------------------------------------------------------------
  111. A组情况: 背景图片尺寸大于屏幕分辨率;
  112. x3=x2-x-(x1-x);
  113. 示例:
  114. ①.屏幕分辨率 (x=1442, y=900);
  115. ②.背景图片实际尺寸 (x1=1920, y1=79);
  116. ③.被裁图片在背景图片的实际位置 (x2=17, y2=52);
  117. ④.被裁图片在背景图片的运行位置(x3,y3);
  118. x3 = x2-x1-(x-x1) = x2-x = 17-1442 = -1425;
  119. y3 = y2 = 52;
  120. //----------------------------------------------------------------------
  121. B组情况: 背景图片尺寸大于屏幕分辨率;
  122. */
  123. /************************************************************************/
  124. void CDlgOfTop::LoadSkin(CString strFileName)
  125. {
  126. // 1.获取对话框客户区域 [7/21/2013 Zero.t]
  127. CRect rc;
  128. GetClientRect(&rc);
  129. int cx = rc.Width();
  130. int cy = rc.Height();
  131. // 2.获取皮肤主题路径 [7/21/2013 Zero.t]
  132. m_strSkinPathName = GetPathName(strFileName);
  133. static const char *ThemeMetrics = "ThemeMetrics";
  134. static const char *ThemeColors = "ThemeColors";
  135. static const char *ThemeColor = "ThemeColor";
  136. char buf[MAX_PATH];
  137. // 3.加载主背景图片;
  138. m_MainTop.LoadBitmap(m_strSkinPathName+"\\topbar.bmp");
  139. // 4.设置主背景图分割点 [8/28/2013 hero]
  140. m_MainTop.SetExtendPoint(1820,0);
  141. // 5.加载各按钮背景图;
  142. {
  143. //---------------------按钮 图片前5---------------------------------------------------------------------------------
  144. _Btn_AlarmRecord.LoadBitmap(m_strSkinPathName + "\\" +"alarm_log.bmp"); _Btn_AlarmRecord.SetParent(&m_MainTop);
  145. _Btn_NoticeRecord.LoadBitmap(m_strSkinPathName + "\\" +"call_log.bmp"); _Btn_NoticeRecord.SetParent(&m_MainTop);
  146. _Btn_DataRecord.LoadBitmap(m_strSkinPathName + "\\" +"login_log.bmp"); _Btn_DataRecord.SetParent(&m_MainTop);
  147. _Btn_SystemRecord.LoadBitmap(m_strSkinPathName + "\\" +"system_log.bmp"); _Btn_SystemRecord.SetParent(&m_MainTop);
  148. _Btn_AnalogMgr.LoadBitmap(m_strSkinPathName + "\\" +"Alarm_set.bmp"); _Btn_AnalogMgr.SetParent(&m_MainTop);
  149. //--------------------按钮 图片后5---------------------------------------------------------------------------------
  150. _Btn_UserMgr.LoadBitmap(m_strSkinPathName + "\\" +"user_Manage.bmp"); _Btn_UserMgr.SetParent(&m_MainTop);
  151. _Btn_ModifyPassWord.LoadBitmap(m_strSkinPathName + "\\" +"password_modif.bmp"); _Btn_ModifyPassWord.SetParent(&m_MainTop);
  152. _Btn_HomePageConfig.LoadBitmap(m_strSkinPathName + "\\" +"start_set.bmp"); _Btn_HomePageConfig.SetParent(&m_MainTop);
  153. _Btn_LeftTree.LoadBitmap(m_strSkinPathName + "\\" +"ListBox.bmp"); _Btn_LeftTree.SetParent(&m_MainTop);
  154. _Btn_Exit.LoadBitmap(m_strSkinPathName + "\\" +"exit.bmp"); _Btn_Exit.SetParent(&m_MainTop);
  155. }
  156. // 6.加载各按钮位置;
  157. {
  158. //---------------------按钮 位置前5---------------------------------------------------------------------------------
  159. GetPrivateProfileString(ThemeMetrics,"alarm_log","",buf,MAX_PATH,strFileName);_Size_AlarmRecord = GetSize(buf);
  160. GetPrivateProfileString(ThemeMetrics,"call_log","",buf,MAX_PATH,strFileName);_Size_NoticeRecord = GetSize(buf);
  161. GetPrivateProfileString(ThemeMetrics,"login_log","",buf,MAX_PATH,strFileName);_Size_DataRecord = GetSize(buf);
  162. GetPrivateProfileString(ThemeMetrics,"system_log","",buf,MAX_PATH,strFileName);_Size_SystemRecord = GetSize(buf);
  163. GetPrivateProfileString(ThemeMetrics,"Alarm_set","",buf,MAX_PATH,strFileName);_Size_AnalogMgr = GetSize(buf);
  164. //---------------------按钮 位置后5---------------------------------------------------------------------------------
  165. GetPrivateProfileString(ThemeMetrics,"user_Manage","",buf,MAX_PATH,strFileName);_Size_UserMgr = GetSize(buf);
  166. GetPrivateProfileString(ThemeMetrics,"password_modif","",buf,MAX_PATH,strFileName);_Size_ModifyPassWord = GetSize(buf);
  167. GetPrivateProfileString(ThemeMetrics,"start_set","",buf,MAX_PATH,strFileName);_Size_HomePageConfig = GetSize(buf);
  168. GetPrivateProfileString(ThemeMetrics,"ListBox","",buf,MAX_PATH,strFileName);_Sizen_LeftTree = GetSize(buf);
  169. GetPrivateProfileString(ThemeMetrics,"exit","",buf,MAX_PATH,strFileName);_Size_Exit = GetSize(buf);
  170. //----------------------------------------------------------------------------------
  171. }
  172. // 7.设置各按钮在对话框的位置 [8/28/2013 Administrator]
  173. {
  174. _Btn_AlarmRecord.SetWindowPos(NULL, cx+_Size_AlarmRecord.cx, _Size_AlarmRecord.cy, 0, 0, SWP_NOSIZE);
  175. _Btn_NoticeRecord.SetWindowPos(NULL, cx+_Size_NoticeRecord.cx, _Size_NoticeRecord.cy, 0, 0, SWP_NOSIZE);
  176. _Btn_DataRecord.SetWindowPos(NULL, cx+_Size_DataRecord.cx, _Size_DataRecord.cy, 0, 0, SWP_NOSIZE);
  177. _Btn_SystemRecord.SetWindowPos(NULL, cx+_Size_SystemRecord.cx, _Size_SystemRecord.cy, 0, 0, SWP_NOSIZE);
  178. _Btn_AnalogMgr.SetWindowPos(NULL, cx+_Size_AnalogMgr.cx, _Size_AnalogMgr.cy, 0, 0, SWP_NOSIZE);
  179. _Btn_UserMgr.SetWindowPos(NULL, cx+_Size_UserMgr.cx, _Size_UserMgr.cy, 0, 0, SWP_NOSIZE);
  180. _Btn_ModifyPassWord.SetWindowPos(NULL, cx+_Size_ModifyPassWord.cx, _Size_ModifyPassWord.cy, 0, 0, SWP_NOSIZE);
  181. _Btn_HomePageConfig.SetWindowPos(NULL, cx+_Size_HomePageConfig.cx, _Size_HomePageConfig.cy, 0, 0, SWP_NOSIZE);
  182. _Btn_LeftTree.SetWindowPos(NULL, cx+_Sizen_LeftTree.cx, _Sizen_LeftTree.cy, 0, 0, SWP_NOSIZE);
  183. _Btn_Exit.SetWindowPos(NULL, cx+_Size_Exit.cx, _Size_Exit.cy, 0, 0, SWP_NOSIZE);
  184. }
  185. }
  186. CSize CDlgOfTop::GetSize(char *buf)
  187. {
  188. CStringList strList;
  189. SplitString(buf,2,strList);
  190. CSize sz;
  191. sz.cx =atoi(strList.GetAt(strList.FindIndex(0) ));
  192. sz.cy =atoi(strList.GetAt(strList.FindIndex(1) ));
  193. // 在返回前,先减去实际屏幕分辨率_ClientSize [8/29/2013 Z.t]
  194. sz.cx = sz.cx - _ClientSize.cx;
  195. return sz;
  196. }
  197. void CDlgOfTop::SplitString(char *buf,int nCount,CStringList& strList)
  198. {
  199. char *p1=buf;
  200. for (int i=0;i<nCount;i++)
  201. {
  202. char *p2=p1;
  203. while ((*p1 != ',') && (*p1 != '\0'))
  204. {
  205. p1++;
  206. }
  207. CString str(p2);
  208. str=str.Left(p1-p2) ;
  209. strList.AddTail(str);
  210. p1++;
  211. }
  212. }
  213. void CDlgOfTop::OnSize(UINT nType, int cx, int cy)
  214. {
  215. CDialog::OnSize(nType, cx, cy);
  216. if(::IsWindow(m_MainTop))
  217. {
  218. //m_MainTop.RedrawWindow(); // 重绘 [8/29/2013 Z.t]
  219. //m_MainTop.SetWindowPos(NULL,0,0,cx,100, NULL);
  220. CRect rc;
  221. m_MainTop.GetClientRect(rc);
  222. m_MainTop.SetWindowPos(NULL,0,0,cx,cy,NULL);
  223. // 7.设置各按钮在对话框的位置 [8/28/2013 Administrator]
  224. {
  225. _Btn_AlarmRecord.SetWindowPos(NULL, cx+_Size_AlarmRecord.cx, _Size_AlarmRecord.cy, 0, 0, SWP_NOSIZE);
  226. _Btn_NoticeRecord.SetWindowPos(NULL, cx+_Size_NoticeRecord.cx, _Size_NoticeRecord.cy, 0, 0, SWP_NOSIZE);
  227. _Btn_DataRecord.SetWindowPos(NULL, cx+_Size_DataRecord.cx, _Size_DataRecord.cy, 0, 0, SWP_NOSIZE);
  228. _Btn_SystemRecord.SetWindowPos(NULL, cx+_Size_SystemRecord.cx, _Size_SystemRecord.cy, 0, 0, SWP_NOSIZE);
  229. _Btn_AnalogMgr.SetWindowPos(NULL, cx+_Size_AnalogMgr.cx, _Size_AnalogMgr.cy, 0, 0, SWP_NOSIZE);
  230. _Btn_UserMgr.SetWindowPos(NULL, cx+_Size_UserMgr.cx, _Size_UserMgr.cy, 0, 0, SWP_NOSIZE);
  231. _Btn_ModifyPassWord.SetWindowPos(NULL, cx+_Size_ModifyPassWord.cx, _Size_ModifyPassWord.cy, 0, 0, SWP_NOSIZE);
  232. _Btn_HomePageConfig.SetWindowPos(NULL, cx+_Size_HomePageConfig.cx, _Size_HomePageConfig.cy, 0, 0, SWP_NOSIZE);
  233. _Btn_LeftTree.SetWindowPos(NULL, cx+_Sizen_LeftTree.cx, _Sizen_LeftTree.cy, 0, 0, SWP_NOSIZE);
  234. _Btn_Exit.SetWindowPos(NULL, cx+_Size_Exit.cx, _Size_Exit.cy, 0, 0, SWP_NOSIZE);
  235. }
  236. }
  237. }
  238. // 报警记录 [8/29/2013 hero]
  239. void CDlgOfTop::OnBnClickedBtnAlarmrecord()
  240. {
  241. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  242. pMainFrm->OnEvent();
  243. }
  244. // 通知记录 [8/29/2013 hero]
  245. void CDlgOfTop::OnBnClickedBtnNoticerecord()
  246. {
  247. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  248. pMainFrm->OnNoticeRec();
  249. }
  250. // 登陆日志 [8/29/2013 hero]
  251. void CDlgOfTop::OnBnClickedBtnDatarecord()
  252. {
  253. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  254. pMainFrm->OnSummaryLog();
  255. }
  256. // 系统日志 [8/29/2013 hero]
  257. void CDlgOfTop::OnBnClickedBtnSystemrecord()
  258. {
  259. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  260. pMainFrm->OnSystemLog();
  261. }
  262. // 变量管理 [8/29/2013 hero]
  263. void CDlgOfTop::OnBnClickedBtnAnalogmgr()
  264. {
  265. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  266. pMainFrm->OnSingleAnalog();
  267. }
  268. // 用户管理 [8/29/2013 hero]
  269. void CDlgOfTop::OnBnClickedBtnUsermgr()
  270. {
  271. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  272. pMainFrm->OnUsers();
  273. }
  274. // 修改密码 [8/29/2013 hero]
  275. void CDlgOfTop::OnBnClickedBtnModifypassword()
  276. {
  277. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  278. pMainFrm->OnEditPwdTool();
  279. }
  280. // 首页设置 [8/29/2013 hero]
  281. void CDlgOfTop::OnBnClickedBtnHomepageconfig()
  282. {
  283. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  284. pMainFrm->OnSysPara();
  285. }
  286. // 导航树 [8/29/2013 hero]
  287. void CDlgOfTop::OnBnClickedBtnLefttree()
  288. {
  289. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  290. pMainFrm->m_hleftDockBar.ShowWindow(SW_SHOW);
  291. pMainFrm->m_hleftDockBar.SendMessage(WM_MY_INVALIDATE,0,0 );
  292. }
  293. // 退出 [8/29/2013 hero]
  294. void CDlgOfTop::OnBnClickedBtnExit()
  295. {
  296. CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  297. pMainFrm->OnSuperEnd();
  298. }
  299. //BOOL CDlgOfTop::DestroyWindow()
  300. //{
  301. // // TODO: 在此添加专用代码和/或调用基类
  302. //
  303. // return CDialog::DestroyWindow();
  304. //}