📄 oscdlg.cpp
字号:
// oscdlg.cpp : implementation file
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "osc.h"
#include "oscdlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg message handlers
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CenterWindow();
return TRUE; // return TRUE unless you set the focus to a control
}
/////////////////////////////////////////////////////////////////////////////
// COscDlg dialog
COscDlg::COscDlg(CWnd* pParent /*=NULL*/)
: CDialog(COscDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COscDlg)
m_nSetting = 0;
m_dato = 1;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void COscDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COscDlg)
DDX_Control(pDX, IDC_OSC, m_OscWnd);
DDX_Radio(pDX, IDC_RADIO1, m_dato);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COscDlg, CDialog)
//{{AFX_MSG_MAP(COscDlg)
ON_WM_HSCROLL()
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_DESTROY()
ON_WM_TIMER()
ON_WM_ACTIVATE()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COscDlg message handlers
BOOL COscDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CenterWindow();
// 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);
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
m_OscWnd.InitOsc(COscWnd::red);
m_uTimerID = SetTimer(0x451,250,NULL); // one screen each 250 mSeg.
m_Apply.EnableWindow( FALSE );
m_bandera=false;
m_enoff=false;
m_apagado=false;
m_radio=1;
return TRUE; // return TRUE unless you set the focus to a control
}
void COscDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void COscDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
}
else
{
CDialog::OnPaint();
}
}
void COscDlg::OnDestroy()
{
CDialog::OnDestroy();
KillTimer(m_uTimerID);
}
void COscDlg::OnTimer(UINT nIDEvent)
{
CDialog::OnTimer(nIDEvent);
m_nvalor=m_brillo.GetPos();
if(m_bandera)
{
if(m_OscWnd.RenderView(m_nvalor)==1)
{
KillTimer(m_uTimerID);
AfxMessageBox(" ATENCION !! No se ha podido leer el puerto, verifique si la electr髇ica del sistema esta funcionando correctamente. Oprima Aceptar para salir del programa ",MB_OK,0);
OnOK();
}
}
m_OscWnd.PaintFlame();
// Eat spurious WM_TIMER messages
MSG msg;
while(::PeekMessage(&msg, m_hWnd, WM_TIMER, WM_TIMER, PM_REMOVE));
}
void COscDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CDialog::OnActivate(nState, pWndOther, bMinimized);
m_OscWnd.SendMessage(WM_QUERYNEWPALETTE); // redo the palette if necessary
}
void COscDlg::OnButton1()
{
// TODO: Add your control notification handler code here
m_bandera=true;
m_enoff=false;
m_apagado=false;
if (m_radio==1)
{
GetDlgItem(IDC_BUTTON1)->SetWindowText("Medir");
}
if (m_radio==0)
{
GetDlgItem(IDC_BUTTON1)->SetWindowText("Test");
}
}
void COscDlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_OscWnd.InitOsc(0);
m_enoff=false;
m_apagado=true;
m_bandera=false;
if (m_radio==1)
{
GetDlgItem(IDC_BUTTON1)->SetWindowText("Prender");
}
if (m_radio==0)
{
GetDlgItem(IDC_BUTTON1)->SetWindowText("On");
}
}
void COscDlg::OnButton3()
{
// TODO: Add your control notification handler code here
m_enoff=false;
m_apagado=false;
OnOK();
}
void COscDlg::OnButton4()
{
// TODO: Add your control notification handler code here
m_bandera=false;
m_enoff=true;
m_apagado=true;
}
void COscDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
if (m_bandera==false)
{
GetDlgItem(IDC_BUTTON1)->SetWindowText("On");
}
if (m_bandera==true)
{
GetDlgItem(IDC_BUTTON1)->SetWindowText("Test");
}
GetDlgItem(IDC_BUTTON2)->SetWindowText("Off");
GetDlgItem(IDC_BUTTON4)->SetWindowText("Pause");
GetDlgItem(IDC_BUTTON3)->SetWindowText("Close");
GetDlgItem(IDC_BUTTON5)->SetWindowText("Save Image");
GetDlgItem(IDC_BUTTON6)->SetWindowText("Load Image");
GetDlgItem(IDC_CUADRO)->SetWindowText("Idioma");
GetDlgItem(IDC_SERV)->SetWindowText("File Services");
m_radio=0;
}
void COscDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
if (m_bandera==false)
{
GetDlgItem(IDC_BUTTON1)->SetWindowText("Prender");
}
if (m_bandera==true)
{
GetDlgItem(IDC_BUTTON1)->SetWindowText("Medir");
}
GetDlgItem(IDC_BUTTON2)->SetWindowText("Apagar");
GetDlgItem(IDC_BUTTON4)->SetWindowText("Pausa");
GetDlgItem(IDC_BUTTON3)->SetWindowText("Cerrar");
GetDlgItem(IDC_BUTTON5)->SetWindowText("Grabar Im醙en");
GetDlgItem(IDC_BUTTON6)->SetWindowText("Cargar Im醙en");
GetDlgItem(IDC_CUADRO)->SetWindowText("Language");
GetDlgItem(IDC_SERV)->SetWindowText("Servicios de Archivo");
m_radio=1;
}
void COscDlg::OnButton5()
{
// TODO: Add your control notification handler code here
if (m_enoff==true && m_apagado==true)
{
m_OscWnd.Grabar_Archivo();
}
else
{
if (m_radio==1)
{
AfxMessageBox("*** ERROR *** Solo puede utilizar esta opci髇, en modo Pausa ");
}
else
{
AfxMessageBox("*** ERROR *** You must click this button only in Pause mode ");
}
}
}
void COscDlg::OnButton6()
{
// TODO: Add your control notification handler code here
if (m_apagado==true)
{
m_OscWnd.Cargar_Archivo();
}
else
{
if (m_radio==1)
{
AfxMessageBox("*** ERROR *** Solo puede utilizar esta opci髇, en modo Pausa o Apagado ");
}
else
{
AfxMessageBox("*** ERROR *** You must click this button only in Pause or Off mode ");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -