123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517 |
- // Dlg_ToolBar.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "Dlg_ToolBar.h"
- #include "Global.h"
- #include ".\dlg_toolbar.h"
- //#include "ScriptSetDlg.h"
- #include "DlgEditPwd.h"
- #include "SystemParaSetDlg.h"
- #include "MainFrm.h"
- // CDlg_ToolBar 对话框
- IMPLEMENT_DYNAMIC(CDlg_ToolBar, CDialog)
- CDlg_ToolBar::CDlg_ToolBar(CWnd* pParent /*=NULL*/)
- : CDialog(CDlg_ToolBar::IDD, pParent)
- {
- }
- CDlg_ToolBar::~CDlg_ToolBar()
- {
- }
- void CDlg_ToolBar::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_STA_CLOCK, m_clock);
- }
- BEGIN_MESSAGE_MAP(CDlg_ToolBar, CDialog)
- ON_WM_PAINT()
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_TIMER()
- END_MESSAGE_MAP()
- // CDlg_ToolBar 消息处理程序
- BOOL CDlg_ToolBar::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: 在此添加额外的初始化
- char picDir[_MAX_PATH] = {0};
- strcpy(picDir, g_strDirectory);
- strcat(picDir, "\\");
- strcat(picDir, _BITMAPDIR);
- strcat(picDir, "topbar.bmp" );
- DisplayBMP( 0,0,1920,79,picDir,false );
- int screenx=GetSystemMetrics(SM_CXSCREEN);
- int screeny=GetSystemMetrics(SM_CYSCREEN);
- GetDlgItem(IDC_STA_CLOCK)->MoveWindow( CRect(screenx-120,5,screenx,30) );
- CTime time=CTime::GetCurrentTime();
- int nHour=time.GetHour();
- int nMinute=time.GetMinute();
- int nSecond=time.GetSecond();
- m_clock.SetBkColor(RGB(9,52,86));//7,58,103
- m_clock.SetTextColor(RGB(0,255,0));
- m_clock.SetClock(nHour,nMinute,nSecond);
- SetTimer( 1,100,NULL );
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- void CDlg_ToolBar::SetPos( int iWidth,int iHeight )
- {
- CRect rc1;
- rc1.left = 0;
- rc1.right = rc1.left+1920;
- rc1.top = 0;
- rc1.bottom = rc1.top+iHeight;
- this->MoveWindow( rc1 );
- CRect rc2;
- rc2.left = 0;
- rc2.right = 1920;
- rc2.top = 0;
- rc2.bottom = 79;
- GetDlgItem(IDC_STATIC1)->MoveWindow( rc2 );
- //_rtClient = rc1;
- _rtClient.left = 7;
- _rtClient.top = 52;
- _rtClient.right = 825;
- _rtClient.bottom = 79;
- //CRect rc3;
- //rc3.left = 0;
- //rc3.right = iWidth;
- //rc3.top = 85;
- //rc3.bottom = 120;
- //GetDlgItem(IDC_STATIC2)->MoveWindow( rc3 );
- }
- void CDlg_ToolBar::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- // TODO: 在此处添加消息处理程序代码
- // 不为绘图消息调用 CDialog::OnPaint()
- char picDir[_MAX_PATH] = {0};
- strcpy(picDir, g_strDirectory);
- strcat(picDir, "\\");
- strcat(picDir, _BITMAPDIR);
- strcat(picDir, "topbar.bmp" );
- DisplayBMP( 0,0,1920,79,picDir,false );//DisplayBMP( 0,0,2400,106,picDir,false );
- }
- BOOL CDlg_ToolBar::DisplayBMP( int nX1,int nY1,int nXX,int nYY,CString strBMPFile,BOOL bStretch )
- {
- #if 0
- CClientDC dc( this );
- GdiplusStartupInput m_gdiplusStartupInput;
- // ULONG_PTR m_pGdiToken;
- wchar_t m_wstrServerName[255] ;
- MultiByteToWideChar(CP_ACP,0,strBMPFile,-1,m_wstrServerName,256);
- Graphics graphics( dc );
- //wchar_t * p=strJPGFile.AllocSysStrinig();
- Image image( m_wstrServerName, FALSE) ;
- //if(bStretch)
- //{
- // StretchBlt(hDC,nX1,nY1,nXX,nYY,hMemDC,0,0,Width,Height,SRCCOPY);
- //}
- //else
- //{
- // Width = min(Width,nXX);
- // Height = min(Height,nYY);
- // BitBlt(hDC,nX1,nY1,Width,Height,hMemDC,0,0,SRCCOPY);
- //}
- if(bStretch)
- {
- graphics.DrawImage( &image, nX1,nY1,nXX,nYY );
- }
- else
- {
- WORD Width = (WORD)image.GetWidth();
- WORD Height = (WORD)image.GetHeight();
- //Width = min(Width,nXX);
- //Height = min(Height,nYY);
- //graphics.DrawImage( &image, nX1,nY1,Width,Height );
- graphics.DrawImage( &image, nX1,nY1,0,0,nXX,nYY,UnitPixel );
- }
- return true;
- #else
- CClientDC dc( this );
- OFSTRUCT of;
- unsigned fh = OpenFile ((char const*)strBMPFile, &of, OF_READ);
- if(fh==-1) return FALSE;
- DWORD size = (DWORD)(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
- HANDLE hDIBInfo = GlobalAlloc(GMEM_MOVEABLE,size);
- SetStretchBltMode(dc,HALFTONE);
- BITMAPFILEHEADER bf;
- LPBITMAPINFOHEADER lpbi;
- lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIBInfo);
- _lread(fh,(LPSTR)&bf,sizeof (bf));
- _lread(fh,(LPSTR)lpbi,sizeof(BITMAPINFOHEADER));
- WORD nClrs = (WORD)lpbi->biClrUsed;
- size = ((((lpbi->biWidth*lpbi->biBitCount)+31)&~31)>>3)*lpbi->biHeight;
- if(nClrs==0 && lpbi->biBitCount!=24) nClrs = 1<<lpbi->biBitCount;
- if(lpbi->biClrUsed == 0) lpbi->biClrUsed = (DWORD)nClrs;
- if(lpbi->biSizeImage == 0) lpbi->biSizeImage = size;
- WORD Size = (WORD)lpbi->biSize;
- WORD Width = (WORD)lpbi->biWidth;
- WORD Height = (WORD)lpbi->biHeight;
- WORD ClrUsed = (WORD)lpbi->biClrUsed;
- WORD BitCount = (WORD)lpbi->biBitCount;
- DWORD SizeImage = lpbi->biSizeImage;
- WORD SizeRGB = nClrs*sizeof(RGBQUAD);
- WORD SizeHeader = Size+SizeRGB;
- GlobalUnlock(hDIBInfo);
- hDIBInfo = GlobalReAlloc(hDIBInfo,SizeHeader+SizeImage, 0);
- lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIBInfo);
- _lread(fh,(LPSTR)(lpbi)+Size,SizeRGB);
- if(bf.bfOffBits!=0L) _llseek(fh,bf.bfOffBits,SEEK_SET);
- DWORD ul = SizeImage;
- BYTE *hp = (BYTE *)((LPSTR)lpbi + SizeHeader);
- while(ul>30000L)
- {
- _lread(fh,(LPSTR)hp,30000L);
- ul -= 30000L;
- hp += 30000L;
- }
- _lread(fh,(LPSTR)hp,(WORD)ul);
- _lclose(fh);
- HPALETTE hPalette,hOldPal;
- HANDLE hPalHeader = NULL;
- HDC hDC = dc.m_hDC;
- LPBITMAPINFOHEADER lpHeader = lpbi;
- WORD wDIBUse = DIB_RGB_COLORS;
- if(ClrUsed)
- {
- WORD size = sizeof(LOGPALETTE) + ClrUsed * sizeof(PALETTEENTRY);
- NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED,size);
- npPal->palVersion = 0x300;
- npPal->palNumEntries = ClrUsed;
- RGBQUAD FAR *lpRGB = (RGBQUAD FAR *)((LPSTR)lpbi + Size);
- for(WORD i=0;i<ClrUsed;i++,lpRGB++)
- {
- npPal->palPalEntry[i].peRed = lpRGB->rgbRed;
- npPal->palPalEntry[i].peGreen = lpRGB->rgbGreen;
- npPal->palPalEntry[i].peBlue = lpRGB->rgbBlue;
- npPal->palPalEntry[i].peFlags = 0;
- }
- hPalette = CreatePalette((LPLOGPALETTE)npPal);
- LocalFree((HANDLE)npPal);
- hOldPal = SelectPalette(hDC,hPalette,FALSE);
- RealizePalette(hDC);
- if(BitCount!=24)
- {
- size = Size+ClrUsed*sizeof(WORD);
- hPalHeader = GlobalAlloc(GMEM_MOVEABLE,size);
- LPBITMAPINFOHEADER lpPalInfo;
- lpPalInfo = (LPBITMAPINFOHEADER)GlobalLock(hPalHeader);
- *lpPalInfo = *lpbi;
- WORD FAR *lpTable = (WORD FAR *)((LPSTR)lpPalInfo + Size);
- for(WORD i=0;i<ClrUsed;i++) *lpTable++ = i;
- GlobalUnlock(hPalHeader);
- lpHeader = (LPBITMAPINFOHEADER) GlobalLock(hPalHeader);
- wDIBUse = DIB_PAL_COLORS;
- }
- }
- HDC hMemDC = CreateCompatibleDC(hDC);
- HBITMAP hDDBitmap = CreateCompatibleBitmap(hDC,Width,Height);
- SetDIBits(hDC,hDDBitmap,0,Height,(LPSTR)lpbi + SizeHeader,
- (LPBITMAPINFO)lpHeader,wDIBUse);
- HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC,hDDBitmap);
- if(bStretch)
- {
- StretchBlt(hDC,nX1,nY1,nXX,nYY,hMemDC,0,0,Width,Height,SRCCOPY);
- }
- else
- {
- Width = min(Width,nXX);
- Height = min(Height,nYY);
- BitBlt(hDC,nX1,nY1,Width,Height,hMemDC,0,0,SRCCOPY);
- }
- SelectObject(hMemDC,hOldBitmap);
- DeleteDC(hMemDC);
- DeleteObject(hDDBitmap);
- DeleteObject( dc );
- if(ClrUsed)
- {
- SelectPalette(hDC,hOldPal,FALSE);
- DeleteObject(hPalette);
- if(BitCount!=24)
- {
- GlobalUnlock(hPalHeader);
- GlobalFree(hPalHeader);
- }
- }
-
- DeleteObject( hDC );
- GlobalUnlock(hDIBInfo);
- GlobalFree(hDIBInfo);
- int screenx=GetSystemMetrics(SM_CXSCREEN);
- CClientDC dc2( this );
- dc2.SetBkMode( TRANSPARENT );
- dc2.SetTextColor( RGB(62,132,192) );
- CString sShow;
- sShow.Format( "【ver:%s】",g_strVersion );
- dc2.TextOut( screenx-110,58,sShow );
- DeleteObject( dc2 );
- return TRUE;
- #endif
- }
- void CDlg_ToolBar::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- int screenx=GetSystemMetrics(SM_CXSCREEN); // 获取屏幕宽度 [8/27/2013 Zero]
-
- //CRect RectVer(screenx-110,5,screenx,23);
- CRect RectVer(screenx-110,8,screenx,28);
-
- //if( RectVer.PtInRect( point ) )
- if( _rtClient.PtInRect( point ) )
- {
- HCURSOR hCursor;
- hCursor = AfxGetApp() -> LoadCursor(IDC_HANDCUR);
- ::SetCursor(hCursor);
- return;
- }
- CRect rect[10];
- GetDlgItem(IDC_PIC1)->GetWindowRect( rect[0] ); ScreenToClient( &rect[0] );
- GetDlgItem(IDC_PIC2)->GetWindowRect( rect[1] ); ScreenToClient( &rect[1] );
- GetDlgItem(IDC_PIC3)->GetWindowRect( rect[2] ); ScreenToClient( &rect[2] );
- GetDlgItem(IDC_PIC4)->GetWindowRect( rect[3] ); ScreenToClient( &rect[3] );
- GetDlgItem(IDC_PIC5)->GetWindowRect( rect[4] ); ScreenToClient( &rect[4] );
- GetDlgItem(IDC_PIC6)->GetWindowRect( rect[5] ); ScreenToClient( &rect[5] );
- GetDlgItem(IDC_PIC7)->GetWindowRect( rect[6] ); ScreenToClient( &rect[6] );
- GetDlgItem(IDC_PIC8)->GetWindowRect( rect[7] ); ScreenToClient( &rect[7] );
- GetDlgItem(IDC_PIC9)->GetWindowRect( rect[8] ); ScreenToClient( &rect[8] );
- GetDlgItem(IDC_PIC10)->GetWindowRect( rect[9] );ScreenToClient( &rect[9] );
- for( int i=0;i<10;i++ )
- {
- if( rect[i].PtInRect( point ) )
- {
- HCURSOR hCursor;
- hCursor = AfxGetApp() -> LoadCursor(IDC_HANDCUR);
- ::SetCursor(hCursor);
- break;
- }
- }
- CDialog::OnMouseMove(nFlags, point);
- }
- void CDlg_ToolBar::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- int screenx = GetSystemMetrics(SM_CXSCREEN);// 获取屏幕宽度 [8/27/2013 Zero]
-
- CRect RectVer(screenx-110,5,screenx,23);
-
- //if( RectVer.PtInRect( point ) )
- if( _rtClient.PtInRect( point ) )
- {
- HCURSOR hCursor;
- hCursor = AfxGetApp() -> LoadCursor(IDC_HANDCUR);
- ::SetCursor(hCursor);
- return;
- }
- CRect rect[10];
- GetDlgItem(IDC_PIC1)->GetWindowRect( rect[0] ); ScreenToClient( &rect[0] );
- GetDlgItem(IDC_PIC2)->GetWindowRect( rect[1] ); ScreenToClient( &rect[1] );
- GetDlgItem(IDC_PIC3)->GetWindowRect( rect[2] ); ScreenToClient( &rect[2] );
- GetDlgItem(IDC_PIC4)->GetWindowRect( rect[3] ); ScreenToClient( &rect[3] );
- GetDlgItem(IDC_PIC5)->GetWindowRect( rect[4] ); ScreenToClient( &rect[4] );
- GetDlgItem(IDC_PIC6)->GetWindowRect( rect[5] ); ScreenToClient( &rect[5] );
- GetDlgItem(IDC_PIC7)->GetWindowRect( rect[6] ); ScreenToClient( &rect[6] );
- GetDlgItem(IDC_PIC8)->GetWindowRect( rect[7] ); ScreenToClient( &rect[7] );
- GetDlgItem(IDC_PIC9)->GetWindowRect( rect[8] ); ScreenToClient( &rect[8] );
- GetDlgItem(IDC_PIC10)->GetWindowRect( rect[9] );ScreenToClient( &rect[9] );
- for( int i=0;i<10;i++ )
- {
- if( rect[i].PtInRect( point ) )
- {
- HCURSOR hCursor;
- hCursor = AfxGetApp() -> LoadCursor(IDC_CURSOR2);
- ::SetCursor(hCursor);
- break;
- }
- }
- CDialog::OnLButtonDown(nFlags, point);
- }
- void CDlg_ToolBar::OnLButtonUp(UINT nFlags, CPoint point)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- CMainFrame *pMainFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- if( pMainFrm==NULL )
- return;
- int screenx=GetSystemMetrics(SM_CXSCREEN);// 获取屏幕宽度 [8/27/2013 Zero]
-
- CRect RectVer(screenx-110,5,screenx,23);
- //CRect RectVer(7,,screenx,23);
-
- CRect rect[10];
- GetDlgItem(IDC_PIC1)->GetWindowRect( rect[0] );
- ScreenToClient( &rect[0] );
- GetDlgItem(IDC_PIC2)->GetWindowRect( rect[1] );
- ScreenToClient( &rect[1] );
- GetDlgItem(IDC_PIC3)->GetWindowRect( rect[2] );
- ScreenToClient( &rect[2] );
- GetDlgItem(IDC_PIC4)->GetWindowRect( rect[3] );
- ScreenToClient( &rect[3] );
- GetDlgItem(IDC_PIC5)->GetWindowRect( rect[4] );
- ScreenToClient( &rect[4] );
- GetDlgItem(IDC_PIC6)->GetWindowRect( rect[5] );
- ScreenToClient( &rect[5] );
- GetDlgItem(IDC_PIC7)->GetWindowRect( rect[6] );
- ScreenToClient( &rect[6] );
- GetDlgItem(IDC_PIC8)->GetWindowRect( rect[7] );
- ScreenToClient( &rect[7] );
- GetDlgItem(IDC_PIC9)->GetWindowRect( rect[8] );
- ScreenToClient( &rect[8] );
- GetDlgItem(IDC_PIC10)->GetWindowRect( rect[9] );
- ScreenToClient( &rect[9] );
- GetDlgItem(IDC_PIC1)->GetClientRect( rect[0] );
- ClientToScreen(&rect[0]);
- GetDlgItem(IDC_PIC2)->GetClientRect( rect[1] );
- ClientToScreen(&rect[1]);
- GetDlgItem(IDC_PIC3)->GetClientRect( rect[2] );
- ClientToScreen(&rect[2]);
- GetDlgItem(IDC_PIC4)->GetClientRect( rect[3] );
- ClientToScreen(&rect[3]);
- GetDlgItem(IDC_PIC5)->GetClientRect( rect[4] );
- ClientToScreen(&rect[4]);
- GetDlgItem(IDC_PIC6)->GetClientRect( rect[5] );
- ClientToScreen(&rect[5]);
- GetDlgItem(IDC_PIC7)->GetClientRect( rect[6] );
- ClientToScreen(&rect[6]);
- GetDlgItem(IDC_PIC8)->GetClientRect( rect[7] );
- ClientToScreen(&rect[7]);
- GetDlgItem(IDC_PIC9)->GetClientRect( rect[8] );
- ClientToScreen(&rect[8]);
- GetDlgItem(IDC_PIC10)->GetClientRect( rect[9] );
- ClientToScreen(&rect[9]);
- int nType = -1;
- for( int i=0;i<10;i++ )
- {
- if( rect[i].PtInRect( point ) )
- {
- HCURSOR hCursor;
- hCursor = AfxGetApp() -> LoadCursor(IDC_HANDCUR);
- ::SetCursor(hCursor);
- nType = i;
- break;
- }
- }
- switch( nType )
- {
- case 0:
- //{
- // CHAR szMaxID[MAX_ID + 1] = {0};
- // CDBInterface::GetInstancePtr()->GetMaxID("t_data_rec", "id", szMaxID);
- //}
- pMainFrm->OnEvent();
- break;
- case 1:
- pMainFrm->OnNoticeRec();
- break;
- case 2:
- pMainFrm->OnSummaryLog();
- break;
- case 3:
- pMainFrm->OnSystemLog();
- break;
- case 4:
- pMainFrm->OnSingleAnalog();
- break;
- case 5:
- pMainFrm->OnUsers();
- break;
- case 6:
- pMainFrm->OnEditPwdTool();
- break;
- case 7:
- pMainFrm->OnSysPara();
- break;
- case 8:
- pMainFrm->m_hleftDockBar.ShowWindow(SW_SHOW);
- pMainFrm->m_hleftDockBar.SendMessage(WM_MY_INVALIDATE,0,0 );
- break;
- case 9:
- pMainFrm->OnSuperEnd();
- return;
- }
- CDialog::OnLButtonUp(nFlags, point);
- }
- void CDlg_ToolBar::OnTimer(UINT nIDEvent)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- CTime time=CTime::GetCurrentTime();
- int nHour=time.GetHour();
- int nMinute=time.GetMinute();
- int nSecond=time.GetSecond();
- m_clock.SetClock(nHour,nMinute,nSecond);
- CDialog::OnTimer(nIDEvent);
- }
|