123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- // DlgOfTop.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "IDE.h"
- #include "DlgOfTop.h"
- #include ".\dlgoftop.h"
- //------------------------
- #include "Global.h"
- //#include "DlgUserManager.h"
- //#include "Dlg_GroupManage.h"
- //#include "ScriptSetDlg.h"
- #include "DlgEditPwd.h"
- //#include "DlgQueryWarningRec.h"
- //#include "DlgSystemLog.h"
- //#include "DlgNoticeRec.h"
- #include "SystemParaSetDlg.h"
- #include "MainFrm.h"
- // CDlgOfTop 对话框
- IMPLEMENT_DYNAMIC(CDlgOfTop, CDialog)
- CDlgOfTop::CDlgOfTop(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgOfTop::IDD, pParent)
- {
-
- }
- CDlgOfTop::~CDlgOfTop()
- {
- }
- void CDlgOfTop::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, STATIC_TOP, m_MainTop);
- DDX_Control(pDX, DlgOfTop_Btn_AlarmRecord, _Btn_AlarmRecord);
- DDX_Control(pDX, DlgOfTop_Btn_NoticeRecord, _Btn_NoticeRecord);
- DDX_Control(pDX, DlgOfTop_Btn_DataRecord, _Btn_DataRecord);
- DDX_Control(pDX, DlgOfTop_Btn_SystemRecord, _Btn_SystemRecord);
- DDX_Control(pDX, DlgOfTop_Btn_AnalogMgr, _Btn_AnalogMgr);
- DDX_Control(pDX, DlgOfTop_Btn_UserMgr, _Btn_UserMgr);
- DDX_Control(pDX, DlgOfTop_Btn_ModifyPassWord, _Btn_ModifyPassWord);
- DDX_Control(pDX, DlgOfTop_Btn_HomePageConfig, _Btn_HomePageConfig);
- DDX_Control(pDX, DlgOfTop_Btn_LeftTree, _Btn_LeftTree);
- DDX_Control(pDX, DlgOfTop_Btn_Exit, _Btn_Exit);
- }
- BEGIN_MESSAGE_MAP(CDlgOfTop, CDialog)
- ON_WM_SIZE()
- ON_BN_CLICKED(DlgOfTop_Btn_AlarmRecord, OnBnClickedBtnAlarmrecord)
- ON_BN_CLICKED(DlgOfTop_Btn_NoticeRecord, OnBnClickedBtnNoticerecord)
- ON_BN_CLICKED(DlgOfTop_Btn_DataRecord, OnBnClickedBtnDatarecord)
- ON_BN_CLICKED(DlgOfTop_Btn_SystemRecord, OnBnClickedBtnSystemrecord)
- ON_BN_CLICKED(DlgOfTop_Btn_AnalogMgr, OnBnClickedBtnAnalogmgr)
- ON_BN_CLICKED(DlgOfTop_Btn_UserMgr, OnBnClickedBtnUsermgr)
- ON_BN_CLICKED(DlgOfTop_Btn_ModifyPassWord, OnBnClickedBtnModifypassword)
- ON_BN_CLICKED(DlgOfTop_Btn_HomePageConfig, OnBnClickedBtnHomepageconfig)
- ON_BN_CLICKED(DlgOfTop_Btn_LeftTree, OnBnClickedBtnLefttree)
- ON_BN_CLICKED(DlgOfTop_Btn_Exit, OnBnClickedBtnExit)
- END_MESSAGE_MAP()
- // CDlgOfTop 消息处理程序
- BOOL CDlgOfTop::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: 在此添加额外的初始化
- SetWindowPos(NULL,0,0,_ClientSize.cx,_ClientSize.cy,SWP_NOMOVE);
- LoadSkin(".\\Themes\\DefaultTheme\\DefaultTheme.ini");
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- // 75,805
- void CDlgOfTop::CalcWindowRect(const CSize &cs)
- {
- CRect rtWindow;
- rtWindow.left = 0;
- rtWindow.top = 0;
- rtWindow.right = cs.cx;
- rtWindow.bottom = cs.cy;
- MoveWindow(rtWindow);
- //m_MainTop.RedrawWindow(rtWindow,NULL); // 重绘 [8/29/2013 Z.t]
- //LOG4C((LOG_NOTICE,"%d,%d,%d,%d",rtWindow.left,rtWindow.top,rtWindow.right,rtWindow.bottom));
- TRACE("----done movewindow----");
- LoadSkin(".\\Themes\\DefaultTheme\\DefaultTheme.ini");
- }
- void CDlgOfTop::OnCancel()
- {
- // TODO: 在此添加专用代码和/或调用基类
- //CDialog::OnCancel();
- }
- void CDlgOfTop::OnOK()
- {
- // TODO: 在此添加专用代码和/或调用基类
- //CDialog::OnOK();
- }
- CString CDlgOfTop::GetPathName(const char *filename)
- {
- char path[MAX_PATH];
- strcpy( path, filename );
- char *p = path + strlen( path );
- for ( ; *p != '\\' && *p != '/' && p > path; p-- );
- if ( *p == '\\' || *p == '/')
- p++;
- *p = 0;
- return CString(path);
- }
- /************************************************************************/
- /*
- 注意: 左上角坐标为(0,0), 向右为+x, 向下+y;
- ①.屏幕分辨率;(x,y)
- ②.背景图片尺寸;(x1,y1) ->固定的
- ③.被裁图片在背景图片的实际位置;(x2,y2) ->固定的
- ④.被裁图片在背景图片的运行位置;(x3,y3)
- ⑤.
- ⑥.
- ⑦⑧⑨⑩
- //----------------------------------------------------------------------
- A组情况: 背景图片尺寸大于屏幕分辨率;
- x3=x2-x-(x1-x);
- 示例:
- ①.屏幕分辨率 (x=1442, y=900);
- ②.背景图片实际尺寸 (x1=1920, y1=79);
- ③.被裁图片在背景图片的实际位置 (x2=17, y2=52);
- ④.被裁图片在背景图片的运行位置(x3,y3);
- x3 = x2-x1-(x-x1) = x2-x = 17-1442 = -1425;
- y3 = y2 = 52;
- //----------------------------------------------------------------------
- B组情况: 背景图片尺寸大于屏幕分辨率;
- */
- /************************************************************************/
- void CDlgOfTop::LoadSkin(CString strFileName)
- {
- // 1.获取对话框客户区域 [7/21/2013 Zero.t]
- CRect rc;
- GetClientRect(&rc);
- int cx = rc.Width();
- int cy = rc.Height();
- // 2.获取皮肤主题路径 [7/21/2013 Zero.t]
- m_strSkinPathName = GetPathName(strFileName);
- static const char *ThemeMetrics = "ThemeMetrics";
- static const char *ThemeColors = "ThemeColors";
- static const char *ThemeColor = "ThemeColor";
- char buf[MAX_PATH];
- // 3.加载主背景图片;
- m_MainTop.LoadBitmap(m_strSkinPathName+"\\topbar.bmp");
-
- // 4.设置主背景图分割点 [8/28/2013 hero]
- m_MainTop.SetExtendPoint(1820,0);
-
- // 5.加载各按钮背景图;
- {
- //---------------------按钮 图片前5---------------------------------------------------------------------------------
- _Btn_AlarmRecord.LoadBitmap(m_strSkinPathName + "\\" +"alarm_log.bmp"); _Btn_AlarmRecord.SetParent(&m_MainTop);
- _Btn_NoticeRecord.LoadBitmap(m_strSkinPathName + "\\" +"call_log.bmp"); _Btn_NoticeRecord.SetParent(&m_MainTop);
- _Btn_DataRecord.LoadBitmap(m_strSkinPathName + "\\" +"login_log.bmp"); _Btn_DataRecord.SetParent(&m_MainTop);
- _Btn_SystemRecord.LoadBitmap(m_strSkinPathName + "\\" +"system_log.bmp"); _Btn_SystemRecord.SetParent(&m_MainTop);
- _Btn_AnalogMgr.LoadBitmap(m_strSkinPathName + "\\" +"Alarm_set.bmp"); _Btn_AnalogMgr.SetParent(&m_MainTop);
- //--------------------按钮 图片后5---------------------------------------------------------------------------------
- _Btn_UserMgr.LoadBitmap(m_strSkinPathName + "\\" +"user_Manage.bmp"); _Btn_UserMgr.SetParent(&m_MainTop);
- _Btn_ModifyPassWord.LoadBitmap(m_strSkinPathName + "\\" +"password_modif.bmp"); _Btn_ModifyPassWord.SetParent(&m_MainTop);
- _Btn_HomePageConfig.LoadBitmap(m_strSkinPathName + "\\" +"start_set.bmp"); _Btn_HomePageConfig.SetParent(&m_MainTop);
- _Btn_LeftTree.LoadBitmap(m_strSkinPathName + "\\" +"ListBox.bmp"); _Btn_LeftTree.SetParent(&m_MainTop);
- _Btn_Exit.LoadBitmap(m_strSkinPathName + "\\" +"exit.bmp"); _Btn_Exit.SetParent(&m_MainTop);
- }
- // 6.加载各按钮位置;
- {
- //---------------------按钮 位置前5---------------------------------------------------------------------------------
- GetPrivateProfileString(ThemeMetrics,"alarm_log","",buf,MAX_PATH,strFileName);_Size_AlarmRecord = GetSize(buf);
- GetPrivateProfileString(ThemeMetrics,"call_log","",buf,MAX_PATH,strFileName);_Size_NoticeRecord = GetSize(buf);
- GetPrivateProfileString(ThemeMetrics,"login_log","",buf,MAX_PATH,strFileName);_Size_DataRecord = GetSize(buf);
- GetPrivateProfileString(ThemeMetrics,"system_log","",buf,MAX_PATH,strFileName);_Size_SystemRecord = GetSize(buf);
- GetPrivateProfileString(ThemeMetrics,"Alarm_set","",buf,MAX_PATH,strFileName);_Size_AnalogMgr = GetSize(buf);
- //---------------------按钮 位置后5---------------------------------------------------------------------------------
- GetPrivateProfileString(ThemeMetrics,"user_Manage","",buf,MAX_PATH,strFileName);_Size_UserMgr = GetSize(buf);
- GetPrivateProfileString(ThemeMetrics,"password_modif","",buf,MAX_PATH,strFileName);_Size_ModifyPassWord = GetSize(buf);
- GetPrivateProfileString(ThemeMetrics,"start_set","",buf,MAX_PATH,strFileName);_Size_HomePageConfig = GetSize(buf);
- GetPrivateProfileString(ThemeMetrics,"ListBox","",buf,MAX_PATH,strFileName);_Sizen_LeftTree = GetSize(buf);
- GetPrivateProfileString(ThemeMetrics,"exit","",buf,MAX_PATH,strFileName);_Size_Exit = GetSize(buf);
- //----------------------------------------------------------------------------------
- }
- // 7.设置各按钮在对话框的位置 [8/28/2013 Administrator]
- {
- _Btn_AlarmRecord.SetWindowPos(NULL, cx+_Size_AlarmRecord.cx, _Size_AlarmRecord.cy, 0, 0, SWP_NOSIZE);
- _Btn_NoticeRecord.SetWindowPos(NULL, cx+_Size_NoticeRecord.cx, _Size_NoticeRecord.cy, 0, 0, SWP_NOSIZE);
- _Btn_DataRecord.SetWindowPos(NULL, cx+_Size_DataRecord.cx, _Size_DataRecord.cy, 0, 0, SWP_NOSIZE);
- _Btn_SystemRecord.SetWindowPos(NULL, cx+_Size_SystemRecord.cx, _Size_SystemRecord.cy, 0, 0, SWP_NOSIZE);
- _Btn_AnalogMgr.SetWindowPos(NULL, cx+_Size_AnalogMgr.cx, _Size_AnalogMgr.cy, 0, 0, SWP_NOSIZE);
- _Btn_UserMgr.SetWindowPos(NULL, cx+_Size_UserMgr.cx, _Size_UserMgr.cy, 0, 0, SWP_NOSIZE);
- _Btn_ModifyPassWord.SetWindowPos(NULL, cx+_Size_ModifyPassWord.cx, _Size_ModifyPassWord.cy, 0, 0, SWP_NOSIZE);
- _Btn_HomePageConfig.SetWindowPos(NULL, cx+_Size_HomePageConfig.cx, _Size_HomePageConfig.cy, 0, 0, SWP_NOSIZE);
- _Btn_LeftTree.SetWindowPos(NULL, cx+_Sizen_LeftTree.cx, _Sizen_LeftTree.cy, 0, 0, SWP_NOSIZE);
- _Btn_Exit.SetWindowPos(NULL, cx+_Size_Exit.cx, _Size_Exit.cy, 0, 0, SWP_NOSIZE);
- }
- }
- CSize CDlgOfTop::GetSize(char *buf)
- {
- CStringList strList;
- SplitString(buf,2,strList);
- CSize sz;
- sz.cx =atoi(strList.GetAt(strList.FindIndex(0) ));
- sz.cy =atoi(strList.GetAt(strList.FindIndex(1) ));
- // 在返回前,先减去实际屏幕分辨率_ClientSize [8/29/2013 Z.t]
- sz.cx = sz.cx - _ClientSize.cx;
- return sz;
- }
- void CDlgOfTop::SplitString(char *buf,int nCount,CStringList& strList)
- {
- char *p1=buf;
- for (int i=0;i<nCount;i++)
- {
- char *p2=p1;
- while ((*p1 != ',') && (*p1 != '\0'))
- {
- p1++;
- }
- CString str(p2);
- str=str.Left(p1-p2) ;
- strList.AddTail(str);
- p1++;
- }
- }
- void CDlgOfTop::OnSize(UINT nType, int cx, int cy)
- {
- CDialog::OnSize(nType, cx, cy);
- if(::IsWindow(m_MainTop))
- {
- //m_MainTop.RedrawWindow(); // 重绘 [8/29/2013 Z.t]
- //m_MainTop.SetWindowPos(NULL,0,0,cx,100, NULL);
- CRect rc;
- m_MainTop.GetClientRect(rc);
- m_MainTop.SetWindowPos(NULL,0,0,cx,cy,NULL);
- // 7.设置各按钮在对话框的位置 [8/28/2013 Administrator]
- {
- _Btn_AlarmRecord.SetWindowPos(NULL, cx+_Size_AlarmRecord.cx, _Size_AlarmRecord.cy, 0, 0, SWP_NOSIZE);
- _Btn_NoticeRecord.SetWindowPos(NULL, cx+_Size_NoticeRecord.cx, _Size_NoticeRecord.cy, 0, 0, SWP_NOSIZE);
- _Btn_DataRecord.SetWindowPos(NULL, cx+_Size_DataRecord.cx, _Size_DataRecord.cy, 0, 0, SWP_NOSIZE);
- _Btn_SystemRecord.SetWindowPos(NULL, cx+_Size_SystemRecord.cx, _Size_SystemRecord.cy, 0, 0, SWP_NOSIZE);
- _Btn_AnalogMgr.SetWindowPos(NULL, cx+_Size_AnalogMgr.cx, _Size_AnalogMgr.cy, 0, 0, SWP_NOSIZE);
- _Btn_UserMgr.SetWindowPos(NULL, cx+_Size_UserMgr.cx, _Size_UserMgr.cy, 0, 0, SWP_NOSIZE);
- _Btn_ModifyPassWord.SetWindowPos(NULL, cx+_Size_ModifyPassWord.cx, _Size_ModifyPassWord.cy, 0, 0, SWP_NOSIZE);
- _Btn_HomePageConfig.SetWindowPos(NULL, cx+_Size_HomePageConfig.cx, _Size_HomePageConfig.cy, 0, 0, SWP_NOSIZE);
- _Btn_LeftTree.SetWindowPos(NULL, cx+_Sizen_LeftTree.cx, _Sizen_LeftTree.cy, 0, 0, SWP_NOSIZE);
- _Btn_Exit.SetWindowPos(NULL, cx+_Size_Exit.cx, _Size_Exit.cy, 0, 0, SWP_NOSIZE);
- }
- }
-
- }
- // 报警记录 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnAlarmrecord()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnEvent();
- }
- // 通知记录 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnNoticerecord()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnNoticeRec();
- }
- // 登陆日志 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnDatarecord()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnSummaryLog();
- }
- // 系统日志 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnSystemrecord()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnSystemLog();
- }
- // 变量管理 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnAnalogmgr()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnSingleAnalog();
- }
- // 用户管理 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnUsermgr()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnUsers();
- }
- // 修改密码 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnModifypassword()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnEditPwdTool();
- }
- // 首页设置 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnHomepageconfig()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnSysPara();
- }
- // 导航树 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnLefttree()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->m_hleftDockBar.ShowWindow(SW_SHOW);
- pMainFrm->m_hleftDockBar.SendMessage(WM_MY_INVALIDATE,0,0 );
- }
- // 退出 [8/29/2013 hero]
- void CDlgOfTop::OnBnClickedBtnExit()
- {
- CMainFrame *pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnSuperEnd();
- }
- //BOOL CDlgOfTop::DestroyWindow()
- //{
- // // TODO: 在此添加专用代码和/或调用基类
- //
- // return CDialog::DestroyWindow();
- //}
|