📄 moinorcentredlg.cpp
字号:
// MoinorCentreDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MoinorCentre.h"
#include "MoinorCentreDlg.h"
#include "jpegmath.h"
#include "wtypes.h"
#include "UserDialog.h"
#include "picset.h"
#include "picnum.h"
#include "DectectSet.h"
#include "SerialDlg.h"
#include "mmsystem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define idle 0
#define s1 1
#define s2 2
#define s3 3
#define s4 4
#define s5 5
#define s6 6
#define s7 7
#define s8 8
#define s9 9
#define scs 10
#define spic 11
#define spic_ff 22
#define spic_ff00 23
#define overhigh 12
#define overlow 13
#define framefinsih 14
#define framehigh 0xff
#define framelow 0x60
#define mode0 0x00
#define mode1 0x0f
#define mode2 0xf0
#define mode3 0xff
#define AllMonitor 400
#define SomeMonitor 500
#define OneMonitor 600
#define OneZoom 100
#define FourDsplay 200
#define NineDsplay 300
#define TurnAll 400
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
WORD siteid[18]={0x81D1,0x8273,0x83A2,0x84E6,0x8537,0x8695,0x8744,0x881D,0x89CC,
0x8A6E,0x8BBF,0x8CFB,0x8D2A,0x8E88,0x8F59,0x903A,0x91EB,0x9249};
int ID_PIC[9]={ID_PIC1,ID_PIC2,ID_PIC3,ID_PIC4,ID_PIC5,ID_PIC6,ID_PIC7,ID_PIC8,ID_PIC9};
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMoinorCentreDlg dialog
CMoinorCentreDlg::CMoinorCentreDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMoinorCentreDlg::IDD, pParent)
{intosize=FALSE;
mst.busy=FALSE;
mst.error=FALSE;
mst.monitortype=0;
mst.mtime=0;
state=idle;
CS=0;
siteidindex=0;
externi=0;
DisplayMode=OneZoom;
picmode=0x3d64;
pic_width=320;
pic_height=240;
filefullname="D:\\jpegfilehead\\320×240分辨率 中等质量 黑白.jpg";
oldsiteindex=255;
m_bkBrush.CreateSolidBrush(RGB(0,0,0));
//{{AFX_DATA_INIT(CMoinorCentreDlg)
m_siteid = _T("");
m_message = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMoinorCentreDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMoinorCentreDlg)
DDX_Control(pDX, IDC_SCLOSE, m_sclose);
DDX_Control(pDX, IDC_SLIDER4, m_slider4);
DDX_Control(pDX, IDC_SLIDER3, m_slider3);
DDX_Control(pDX, IDC_SLIDER2, m_slider2);
DDX_Control(pDX, IDC_COMBO2, m_comb2);
DDX_CBString(pDX, IDC_COMBO2, m_siteid);
DDX_Text(pDX, IDC_EDIT2, m_message);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMoinorCentreDlg, CDialog)
//{{AFX_MSG_MAP(CMoinorCentreDlg)
ON_MESSAGE(WM_COMM_RXCHAR,OnComm)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CTLCOLOR()
ON_WM_SIZE()
ON_BN_CLICKED(IDC_USER, OnUser)
ON_WM_CAPTURECHANGED()
ON_BN_CLICKED(IDC_DATABASE, OnDatabase)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_CBN_SELENDOK(IDC_COMBO2, OnSelendokCombo2)
ON_BN_CLICKED(IDC_PICSET, OnPicset)
ON_BN_CLICKED(IDC_ONE, OnOne)
ON_BN_CLICKED(IDC_FOUR, OnFour)
ON_BN_CLICKED(IDC_NINE, OnNine)
ON_BN_CLICKED(IDC_ZOOM, OnZoom)
ON_WM_MOVE()
ON_BN_CLICKED(IDC_SCLOSE, OnSclose)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER4, OnCustomdrawSlider4)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER1, OnCustomdrawSlider1)
ON_WM_HSCROLL()
ON_BN_CLICKED(IDC_SSET, OnSset)
ON_BN_CLICKED(IDC_INTELLEC, OnIntellec)
ON_BN_CLICKED(IDC_RESET, OnReset)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_MESSAGE(WM_SEND,OnSend)
ON_MESSAGE(WM_DRAW,OnDraw)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMoinorCentreDlg message handlers
BOOL CMoinorCentreDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(1,3000,NULL);
SetTimer(2,200,NULL);
intosize=TRUE;
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//m_bitmap.LoadBitmap(IDB_BITMAP7);
CMoinorCentreApp* pwnd=(CMoinorCentreApp*)(AfxGetApp());
alarmid=10;
for(int u=0;u<255;u++)
{pwnd->alarmst[u].onoff=FALSE;
}
for(u=0;u<100;u++)
{oldjpgload[u]=FALSE;
}
beijing.Load(".//res//dd.bmp");
m_hdib=CopyHandle(beijing.m_hDib);
CRect ff;
GetWindowRect(ff);
beijing.ChangeImageSize(ff.Width(),ff.Height());
//beijing.Display(GetDC(),0,0);
m_brush.CreateDIBPatternBrush(beijing.m_hDib,DIB_PAL_COLORS);
UINT ID_ALARM[9]={IDC_ALARM0,IDC_ALARM1,IDC_ALARM2,IDC_ALARM3,IDC_ALARM4,IDC_ALARM5,IDC_ALARM6,IDC_ALARM7,
IDC_ALARM8};
for(int l=0;l<9;l++)
{
m_alarm[l].m_bShowDisabledBitmap = FALSE;
m_alarm[l].SubclassDlgItem(ID_ALARM[l],this);
m_alarm[l].SetIcon(IDI_GREEN);
m_alarm[l].DrawTransparent(TRUE);
//m_alarm[l].EnableWindow(FALSE);
}
m_btn.SubclassDlgItem(IDC_USER,this);
m_btn.SetIcon(IDI_ICON3);
m_btn.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_btn.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
m_btn.DrawTransparent(TRUE);
m_one.SubclassDlgItem(IDC_ONE,this);
m_one.SetIcon(IDI_ONE);
m_one.DrawTransparent(TRUE);
m_four.SubclassDlgItem(IDC_FOUR,this);
m_four.SetIcon(IDI_FOUR);
m_four.DrawTransparent(TRUE);
m_nine.SubclassDlgItem(IDC_NINE,this);
m_nine.SetIcon(IDI_NINE);
m_nine.DrawTransparent(TRUE);
m_zoom.SubclassDlgItem(IDC_ZOOM,this);
m_zoom.SetIcon(IDI_ZOOM);
m_zoom.DrawTransparent(TRUE);
m_Serset.SubclassDlgItem(IDC_SSET,this);
m_Serset.SetIcon(IDI_SERIAL);
m_Serset.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_Serset.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
m_Serset.DrawTransparent(TRUE);
m_Dataset.SubclassDlgItem(IDC_DATABASE,this);
m_Dataset.SetIcon(IDI_DATABASE);
m_Dataset.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_Dataset.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(246,153,124));
m_Dataset.DrawTransparent(TRUE);
//m_sclose.SubclassDlgItem(IDC_SCLOSE,this);
m_sclose.SetIcon(IDI_SCLOSE);
m_sclose.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_sclose.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
m_sclose.DrawTransparent(TRUE);
m_Monitor.SubclassDlgItem(IDC_INTELLEC,this);
m_Monitor.SetIcon(IDI_INTEL);
m_Monitor.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_Monitor.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
m_Monitor.DrawTransparent(TRUE);
m_Picset.SubclassDlgItem(IDC_PICSET,this);
m_Picset.SetIcon(IDI_PICSET);
m_Picset.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_Picset.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
m_Picset.DrawTransparent(TRUE);
m_exit.SubclassDlgItem(IDOK,this);
m_exit.SetIcon(IDI_EXIT);
m_exit.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_exit.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
m_exit.DrawTransparent(TRUE);
m_slider2.SetRange(-50,50);
m_slider2.SetTicFreq(10);
m_slider2.SetChannelColor(RGB(228,228,228));
m_slider2.SetSelectionColor(RGB(228,228,228));
m_slider2.SetThumbColor(RGB(2, 228, 0));
m_slider3.SetRange(-100,100);
m_slider3.SetTicFreq(5);
m_slider3.SetThumbColor(RGB(2, 228, 0));
m_slider3.SetSelectionColor(RGB(228,228,228));
m_slider3.SetChannelColor(RGB(228,228,228));
m_slider4 .SetRange(-100,100);
m_slider4.SetTicFreq(5);
m_slider4.SetThumbColor(RGB(2, 228, 0));
m_slider4.SetSelectionColor(RGB(228,228,228));
m_slider4.SetChannelColor(RGB(228,228,228));
scnt=0;
cntcmp[0]=0;
cntcmp[1]=0;
//SetTimer(1,500,NULL);
// TODO: Add extra initialization here
if(m_bSerialPort.InitPort(this,1,4800,'N',8,1,EV_RXFLAG|EV_RXCHAR,1024))
{currentport=1;
buad=4800;
stopbit=1;
databit=8;
p='N';
m_bSerialPort.StartMonitoring();
m_bcomOpened=TRUE;
}
CDaoDatabase db;
db.Open("port.mdb");
CDaoTableDef tb(&db);
tb.Open("Site");
CSiteRecord rs;
rs.Open(&tb,dbOpenDynaset);
rs.MoveFirst();
while(!rs.IsEOF())
{
CString id;
id.Format("%d",rs.m_SiteID);
//m_comb1.AddString(id);
m_comb2.AddString(id);
SiteNum.Add(rs.m_SiteID);
rs.MoveNext();
}
rs.Close();
tb.Close();
db.Close();
for(int j=0;j<4;j++)
{
GetDlgItem(ID_PIC[j])->GetWindowRect(picrec[j]);
ScreenToClient(picrec[j]);
}
return TRUE; // return TRUE unless you set the focus to a control
}
void CMoinorCentreDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMoinorCentreDlg::OnPaint()
{
//CDC* dc=GetDC();
//LPBITMAPINFOHEADER lpm=(LPBITMAPINFOHEADER)GlobalLock(kk.m_hDib);
//static int i=0;
//if(i>0)
//{if(!DrawDibUpdate(hdd,dc->m_hDC,0,0))
//DrawDibDraw(hdd,dc->m_hDC,0,0,0,0,NULL,NULL,0,0,0,0,DDF_UPDATE);
// }
//i++;
//
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
PostMessage(WM_DRAW,externi,0);
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMoinorCentreDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
HBRUSH CMoinorCentreDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_DLG)
{
return m_brush;
}
if(nCtlColor == CTLCOLOR_STATIC)
{//if(pWnd->GetDlgCtrlID()!=IDC_SLIDER4 && pWnd->GetDlgCtrlID()!=IDC_SLIDER3 && pWnd->GetDlgCtrlID()!=IDC_SLIDER2)
//{
pDC->SetBkMode(0);
pDC->SetTextColor(RGB(255,100,70));
hbr = (HBRUSH)::GetStockObject(NULL_BRUSH);
return hbr;
//}
//else
//return hbr;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CMoinorCentreDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if(intosize)
{
CRect ff;
GetWindowRect(ff);
beijing.Destroy();
HDIB newdib=CopyHandle(m_hdib);
beijing.Attach(newdib);
beijing.ChangeImageSize(ff.Width(),ff.Height());
m_brush.DeleteObject();
m_brush.CreateDIBPatternBrush(beijing.m_hDib,DIB_PAL_COLORS);
//m_brush.Attach(temp.m_hObject);
Invalidate();
}
// TODO: Add your message handler code here
}
void CMoinorCentreDlg::OnUser()
{
CUserDialog user;
user.DoModal();
}
LONG CMoinorCentreDlg::OnComm(WPARAM ch,LPARAM port)
{//m_data.Format("%x",ch);
//UpdateData(FALSE);
scnt++;
BYTE data=(BYTE)ch;
if(state==idle)
{ CS=CS^data;
if(data==0xff)
state=s1;
else
{state=idle; CS=0;}
return 0;
}
if(state==s1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -