// PlotCanvasDlg.cpp : implementation file // #include "stdafx.h" #include ".\App\Pmca.h" #include "PlotCanvasDlg.h" #include ".\PlotCanvasdlg.h" #include ".\App\MainFrm.h" //#include ".\Display\PlotWin.h" //#include ".\DPPDLG\Controls\SpinPos.h" #include ".\App\UserMsgs.h" //#include ".\App\PMCAUserDefines.h" #include ".\Plot\SCommon.h" #include ".\Display\WindowCapture.h" #include ".\DPPDLG\Controls\SpinPos.h" #include // CPlotCanvasDlg dialog IMPLEMENT_DYNAMIC(CPlotCanvasDlg, CDialog) CPlotCanvasDlg::CPlotCanvasDlg(CWnd* pParent /*=NULL*/) : CDialog(CPlotCanvasDlg::IDD, pParent) , m_PersistenceInt(false) , m_ScopeTriggerPositionInt(0) , m_ScopeTriggerSlopeInt(false) //, m_ScopeTimebaseInt(0) , m_AutoReArmInt(FALSE) { m_active = FALSE; m_nMonitorElapsedTime = 500; // update the monitors from status every 1.03sec m_nMonitorEventId = 17; // timer identifier, this value does not change m_nMonitorTimerId = 0; // new timer identifier, is assign only on SetTimer Success } CPlotCanvasDlg::~CPlotCanvasDlg() { m_active = FALSE; } void CPlotCanvasDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_PlotCanvasCTRL, m_PlotCanvasCtrl); DDX_Control(pDX, IDC_ARMTRIGGERBUTTON, m_ArmTriggerButton); DDX_Control(pDX, IDC_AUTOREARMCHECK, m_AutoReArmCheck); DDX_Check(pDX, IDC_AUTOREARMCHECK, m_AutoReArmInt); DDX_Control(pDX, IDC_PERSISTENCECHECK, m_PersistenceCheck); DDX_Check(pDX, IDC_PERSISTENCECHECK, m_PersistenceInt); DDX_Control(pDX, IDC_SCOPETIMEBASECOMBO, m_ScopeTimebaseCombo); //DDX_CBIndex(pDX, IDC_SCOPETIMEBASECOMBO, m_ScopeTimebaseInt); //DDX_Control(pDX, IDC_SCOPETRIGGERPOSITIONCOMBO, m_ScopeTriggerPositionCombo); DDX_CBIndex(pDX, IDC_SCOPETRIGGERPOSITIONCOMBO, m_ScopeTriggerPositionInt); //DDX_Control(pDX, IDC_SCOPETRIGGERSLOPECOMBO, m_ScopeTriggerSlopeCombo); DDX_CBIndex(pDX, IDC_SCOPETRIGGERSLOPECOMBO, m_ScopeTriggerSlopeInt); // CONTROLS ALSO ON MISC DIALOG DDX_Control(pDX, IDC_DACCOMBOOSC, m_DACCombo); //DDX_CBIndex(pDX, IDC_DACCOMBOOSC, m_DACint); //DDX_Text(pDX, IDC_OFFSETEDITOSC, m_OffsetCStr); DDX_Control(pDX, IDC_OFFSETSPINOSC, m_OffsetSpinCtrl); DDX_Control(pDX, IDC_OFFSETEDITOSC, m_OffsetEditCtrl); DDX_Control(pDX, IDC_PX4AUXCOMBOOSC, m_PX4AuxCombo); // CONTROLS ALSO ON GAINPZ DIALOG DDX_Control(pDX, IDC_INPUTOFFSETEDITOSC, m_InputOffsetEdit); DDX_Control(pDX, IDC_INPUTOFFSETSPINOSC, m_InputOffsetSpin); DDX_Control(pDX, IDC_MINIMIZEBUTTON, m_DialogMinimizeButton); DDX_Control(pDX, IDC_CLOSEWINBUTTON, m_DialogCloseWinButton); } BEGIN_MESSAGE_MAP(CPlotCanvasDlg, CDialog) ON_WM_DESTROY() ON_WM_TIMER() ON_BN_CLICKED(IDC_AUTOREARMCHECK, OnBnClickedAutorearmcheck) ON_BN_CLICKED(IDC_ARMTRIGGERBUTTON, OnBnClickedArmtriggerbutton) ON_BN_CLICKED(IDC_PERSISTENCECHECK, OnBnClickedPersistencecheck) ON_CBN_SELCHANGE(IDC_SCOPETIMEBASECOMBO, OnCbnSelchangeScopetimebasecombo) ON_CBN_SELCHANGE(IDC_SCOPETRIGGERPOSITIONCOMBO, OnCbnSelchangeScopetriggerpositioncombo) ON_CBN_SELCHANGE(IDC_SCOPETRIGGERSLOPECOMBO, OnCbnSelchangeScopetriggerslopecombo) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_CLOSE() ON_BN_CLICKED(IDC_CLEARTRACEBUTTON, OnBnClickedCleartracebutton) ON_BN_CLICKED(IDC_MINIMIZEBUTTON, OnBnClickedMinimizebutton) ON_BN_CLICKED(IDC_CLOSEWINBUTTON, OnBnClickedClosewinbutton) ON_WM_LBUTTONDOWN() ON_BN_CLICKED(IDC_SIZEWINBUTTON, OnBnClickedSizewinbutton) ON_BN_CLICKED(IDC_SIZEWINBUTTON2, OnBnClickedSizewinbutton2) ON_BN_CLICKED(IDC_SIZEWINBUTTON3, OnBnClickedSizewinbutton3) ON_WM_SHOWWINDOW() ON_BN_CLICKED(IDC_REFRESHUSBBUTTON, OnBnClickedRefreshusbbutton) ON_BN_CLICKED(IDC_CAPTURETRACEBUTTON, OnBnClickedCapturetracebutton) ON_BN_CLICKED(IDC_CAPTURETRACEBUTTON2, OnBnClickedCapturetracebutton2) // misc control functions ON_CBN_SELCHANGE(IDC_DACCOMBOOSC, OnCbnSelchangeDaccombo) ON_NOTIFY(UDN_DELTAPOS, IDC_OFFSETSPINOSC, OnDeltaposOffsetspin) ON_EN_CHANGE(IDC_OFFSETEDITOSC, OnEnChangeOffsetedit) ON_CBN_SELCHANGE(IDC_PX4AUXCOMBOOSC, OnCbnSelchangePx4auxcombo) // gainpz control functions ON_EN_CHANGE(IDC_INPUTOFFSETEDITOSC, OnEnChangeInputoffsetedit) ON_NOTIFY(UDN_DELTAPOS, IDC_INPUTOFFSETSPINOSC, OnDeltaposInputoffsetspin) END_MESSAGE_MAP() void CPlotCanvasDlg::InitControls() { DAC.cboDAC_Offset_Setup(&m_DACCombo,&m_OffsetSpinCtrl,&m_OffsetEditCtrl); PX4Aux.cboAux_Setup(&m_PX4AuxCombo); InputOffset.InputOffset_SetupOSC(&m_InputOffsetSpin,&m_InputOffsetEdit); } void CPlotCanvasDlg::InitControlValues() { isInit = true; DAC.DPPDACFromVal(s.DppConfig.DAC_Enable,s.DppConfig.DAC); //m_DACint = DAC.GetDACIndex(s.DppConfig.DAC_Enable,s.DppConfig.DAC); int m_DACint; m_DACint = DAC.GetDACIndex(s.DppConfig.DAC_Enable,s.DppConfig.DAC); m_DACCombo.SetCurSel(m_DACint); DAC.SetOffsetFromVal(s.DppConfig.Offset); m_OffsetEditCtrl.SetWindowText(DAC.GetOutputOffsetString()); //m_OffsetCStr = DAC.GetOutputOffsetString(); InputOffset.udInputOffset_Change(s.DppConfig.PX4InputOffset); m_InputOffsetSpin.SetPos(s.DppConfig.PX4InputOffset); PX4Aux.DPPAuxFromVal(s.DppConfig.AuxOut); EnableDppControls(); UpdateData(FALSE); // DDEX from var to cntrl, ie sends var value to control isInit = false; } void CPlotCanvasDlg::OnCbnSelchangeDaccombo() { //UpdateData(true); UpdateData(); DAC.DPPDAC(m_DACCombo.GetCurSel()); UpdateConfigValues(); } //@mfunc get the output DAC offset display string based on given offset value //@rdesc output DAC offset display string //@devnote This is used in clsDPPFile. CString CPlotCanvasDlg::GetOutputOffsetStrFromVal(long OffsetVal) { long lngOffset; CString cstrOffset; lngOffset = (int)(((OffsetVal * 2 + ((OffsetVal * 2) > 127) * -256) * 1000 * 16 / 4096)); cstrOffset.Format("%dmV",lngOffset); return cstrOffset; } void CPlotCanvasDlg::OnDeltaposOffsetspin(NMHDR *pNMHDR, LRESULT *pResult) { LPNMUPDOWN pNMUpDown = reinterpret_cast(pNMHDR); // TODO: Add your control notification handler code here //UpdateData(TRUE); int SpinPos; int spinMin; int spinMax; SpinPos = pNMUpDown->iPos+pNMUpDown->iDelta; m_OffsetSpinCtrl.GetRange32(spinMin,spinMax); //Check for wrap around if (SpinPos < spinMin) { SpinPos = spinMax; // wrap to max } else if (SpinPos > spinMax) { SpinPos = spinMin; // wrap to min } DAC.DPPOffset(SpinPos); //m_OffsetCStr = GetOutputOffsetStrFromVal(SpinPos); UpdateData(FALSE); // DDEX from var to cntrl, ie sends var value to control UpdateConfigValues(); *pResult = 0; } void CPlotCanvasDlg::OnEnChangeOffsetedit() { if (m_OffsetEditCtrl.isEnterKey) { DAC.txtOffset_Click(); m_OffsetEditCtrl.isEnterKey = false; } if (m_OffsetEditCtrl.isLButton) { DAC.txtOffset_Click(); m_OffsetEditCtrl.isLButton = false; } if (!isInit) { UpdateConfigValues(); } } double CPlotCanvasDlg::GetOffsetDisplayValFromCtrl(CString cstrOffset) { int int_strlen; double dblOffsetVal; //get text length,remove "uS", convert text to float cstrOffset.TrimLeft(); // remove whitespace before checking size cstrOffset.TrimRight(); // remove whitespace before checking size cstrOffset = cstrOffset; // remove whitespace before checking size int_strlen = cstrOffset.GetLength(); // get the len to determine substring dblOffsetVal = atof(cstrOffset.Mid(0,int_strlen-2)); // convert the display text to a dbl float return dblOffsetVal; } void CPlotCanvasDlg::OnCbnSelchangePx4auxcombo() { UpdateData(); PX4Aux.DPPAux(m_PX4AuxCombo.GetCurSel()); UpdateConfigValues(); } void CPlotCanvasDlg::UpdateConfigValues() { //DAC.txtOffset_Click(); //m_OffsetEditCtrl.GetWindowText(m_OffsetCStr); s.DppConfig.DAC = DAC.GetDAC(); s.DppConfig.DAC_Enable = DAC.GetDAC_Enable(); s.DppConfig.Offset = DAC.GetOffset(); s.DppConfig.AuxOut = PX4Aux.GetAux(); if (s.profile->device_type == 2) { s.DppConfig.PX4InputOffset = InputOffset.mInputOffset; } if (s.DppConfig.SerialNumber > 0) { s.wndMain->ShortUSBConfig(); } else { s.wndMain->OnMcaConnect(); } s.wndMain->SaveConfigToFile(); } void CPlotCanvasDlg::OnEnChangeInputoffsetedit() { if (m_InputOffsetEdit.isEnterKey) { InputOffset.txtInputOffset_Click(); m_InputOffsetEdit.isEnterKey = false; } if (m_InputOffsetEdit.isLButton) { InputOffset.txtInputOffset_Click(); m_InputOffsetEdit.isLButton = false; } if (!isInit) { UpdateConfigValues(); } } void CPlotCanvasDlg::OnDeltaposInputoffsetspin(NMHDR *pNMHDR, LRESULT *pResult) { LPNMUPDOWN pNMUpDown = reinterpret_cast(pNMHDR); // TODO: Add your control notification handler code here InputOffset.udInputOffset_Change((GetSpinPos(pNMUpDown,&m_InputOffsetSpin,spflWrap) - 2)); *pResult = 0; UpdateConfigValues(); } void CPlotCanvasDlg::EnableDppControls() { BOOL bPX4; bPX4 = (s.profile->device_type == 2); m_InputOffsetSpin.EnableWindow(bPX4); m_InputOffsetEdit.EnableWindow(bPX4); //m_PX4AuxCombo.EnableWindow(bPX4); // this !!!is!!! on the dp4 scope only, (no brd output) } void CPlotCanvasDlg::DoDisplayScopeDlg(void) { if(!m_active) { int stat; m_nMonitorElapsedTime = 500; // update the monitors from status every 1.03sec m_nMonitorEventId = 17; // timer identifier, this value does not change m_nMonitorTimerId = 0; // new timer identifier, is assign only on SetTimer Success m_active = TRUE; stat = Create(CPlotCanvasDlg::IDD, s.wndMain); //stat = Create(CPlotCanvasDlg::IDD, NULL); m_AutoReArmInt = s.profile->ScopeAutoReArm; //stored in app profile (not in dpp) UpdateScopeTimebaseCombo(); m_ScopeTriggerSlopeInt = s.DppConfig.ScopeTriggerFalling; //TriggerSlope // !!! TriggerPosition.Value = 2 ' default to 12% pretrigger m_ScopeTriggerPositionInt = s.DppConfig.ScopeTriggerPosition; //TriggerPosition //m_ScopeTimebaseCombo.SetCurSel(0); ShowWindow(SW_SHOWNORMAL); m_nMonitorTimerId = SetTimer(m_nMonitorEventId, m_nMonitorElapsedTime, NULL); UpdateData(FALSE); // DDEX from var to cntrl, ie sends var value to control m_PlotCanvasCtrl.SetTriggerPosition(s.DppConfig.ScopeTriggerPosition); m_ScopeTimebaseCombo.SetBkColor(ctrlColBtnFace); InitControls(); // init DAC and offset for remote control InitControlValues(); // Create a 'CRgn' object CRgn rgn; CRect rect; GetWindowRect(&rect); rgn.CreateRoundRectRgn(0, 0, rect.Width(), rect.Height(), 30, 30); // Set the windows region SetWindowRgn(static_cast(rgn.GetSafeHandle()), TRUE); // Detach the 'CRgn' object from the region or else the // 'CRgn' destructor would close the 'HRGN' handle when 'rgn' // goes out of scope rgn.Detach(); } // // Select old bitmap into memory dc (selecting out circle bitmap) //// Need to create a temporary pointer to pass to do this //if ((m_hBmpOld != NULL) && (m_dcMem != NULL)) { // m_dcMem.SelectObject( CBitmap::FromHandle(m_hBmpOld) ); // // Need to DeleteObject() the bitmap that was loaded // m_bmpScopeFrame.DeleteObject(); // InitScopeFrame(); //} else { // InitScopeFrame(); //} //InitScopeFrame(); } // CPlotCanvasDlg message handlers void CPlotCanvasDlg::OnDestroy() { CDialog::OnDestroy(); if (m_nMonitorTimerId != 0) { //timer with WM_TIMER/eventid KillTimer(m_nMonitorEventId); m_nMonitorTimerId = 0; } m_active = FALSE; // Select old bitmap into memory dc (selecting out circle bitmap) // Need to create a temporary pointer to pass to do this //ASSERT( m_hBmpOld ); //VERIFY( m_dcMem.SelectObject( CBitmap::FromHandle(m_hBmpOld) ) ); // //// Need to DeleteObject() the bitmap that was loaded //m_bmpScopeFrame.DeleteObject(); // m_dcMem destructor will handle rest of cleanup } void CPlotCanvasDlg::OnOK() { // TODO: Add your specialized code here and/or call the base class CDialog::OnOK(); DestroyWindow(); } void CPlotCanvasDlg::OnCancel() { //put code here CDialog::OnDestroy(); } void CPlotCanvasDlg::OnTimer(UINT nIDEvent) { if (nIDEvent == m_nMonitorEventId) { UpdateMonitors(); } CDialog::OnTimer(nIDEvent); } void CPlotCanvasDlg::UpdateMonitors() { if (s.DppConfig.SerialNumber <= 0) { return; } s.wndMain->DeviceStatusOnly(); // read status for monitor updates here UpdateScopeTimebaseCombo(); if (s.DppConfig.SerialNumber > 0) { // if the serial number is > 0 ,update displays if ((s.DppConfig.FPGA >= 0x35) && ((s.DppConfig.BootStatus & 0x04) == 0x04)) { //Scope supported and scope data available? if (s.DppUSB.GetScopeData(s.DppConfig.Scope) > 0) { // get scope data m_PlotCanvasCtrl.PlotTrace(s.DppConfig.Scope); } } } if (s.profile->ScopeAutoReArm) { // autotrigger s.DppUSB.ArmTrigger(); } } void CPlotCanvasDlg::OnBnClickedAutorearmcheck() { UpdateData(TRUE); // DDEX from var to cntrl, ie gets var value from control s.profile->ScopeAutoReArm = m_AutoReArmInt; //stored in app profile (not in dpp) } void CPlotCanvasDlg::OnBnClickedArmtriggerbutton() { if (s.DppConfig.SerialNumber <= 0) { return; } s.DppUSB.ArmTrigger(); } void CPlotCanvasDlg::OnBnClickedPersistencecheck() { UpdateData(TRUE); m_PlotCanvasCtrl.SetPersistenceMode(m_PersistenceInt); // set scope class persistence } void CPlotCanvasDlg::OnCbnSelchangeScopetimebasecombo() { UpdateData(TRUE); //m_ScopeTimebaseInt } void CPlotCanvasDlg::OnCbnSelchangeScopetriggerpositioncombo() { UpdateData(TRUE); s.DppConfig.ScopeTriggerPosition = m_ScopeTriggerPositionInt; if (s.DppConfig.SerialNumber > 0) { s.wndMain->ShortUSBConfig(); } else { s.wndMain->OnMcaConnect(); } s.wndMain->SaveConfigToFile(); m_PlotCanvasCtrl.SetTriggerPosition(m_ScopeTriggerPositionInt); } void CPlotCanvasDlg::OnCbnSelchangeScopetriggerslopecombo() { UpdateData(TRUE); bool trigSlope; s.DppConfig.ScopeTriggerFalling = (m_ScopeTriggerSlopeInt > 0); if (s.DppConfig.SerialNumber > 0) { s.wndMain->ShortUSBConfig(); } else { s.wndMain->OnMcaConnect(); } s.wndMain->SaveConfigToFile(); } void CPlotCanvasDlg::UpdateScopeTimebaseCombo() { if (s.DppConfig.DAC == 0) { //m_ScopeTimebaseInt = 0; m_ScopeTimebaseCombo.SetCurSel(0); } else if ((s.DppConfig.Avg > 0) && (s.DppConfig.Avg <= 5)) { m_ScopeTimebaseCombo.SetCurSel(s.DppConfig.Avg - 1); //m_ScopeTimebaseInt = s.DppConfig.Avg - 1; } else { //m_ScopeTimebaseInt = 0; m_ScopeTimebaseCombo.SetCurSel(0); } //UpdateData(false); //m_ScopeTimebaseCombo.SetCurSel(m_ScopeTimebaseInt); // 0; 1; 2; 3; 4; //3.2uS/Div;6.4uS/Div;12.8uS/Div;25.6uS/Div;51.2uS/Div; //CString cstrStatus; //CString cstrTimebaseText; //m_ScopeTimebaseCombo.GetWindowText(cstrTimebaseText); //cstrStatus.Format("Avg %d , TimeBase %d , Combo set %d , ComboText %s",s.DppConfig.Avg, m_ScopeTimebaseInt,m_ScopeTimebaseCombo.GetCurSel(),cstrTimebaseText); //GetDlgItem(IDC_SCOPESTATUS)->SetWindowText(cstrStatus); } void CPlotCanvasDlg::OnPaint() { CPaintDC dc(this); // device context for painting ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// CDC m_dcMem; // Compatible Memory DC for dialog CBitmap m_bmpScopeFrame; // Bitmap to display HBITMAP m_hBmpOld; // Handle of old bitmap to save BITMAP m_bmInfo; // Bitmap Information structure CPoint m_pt; // Position for upper left corner of bitmap CSize m_size; // Size (width and height) of bitmap CBitmap * pBmpOld; // Load bitmap resource - remember to call DeleteObject when done. VERIFY( m_bmpScopeFrame.LoadBitmap( IDB_SCOPEFRAME ) ); // Get bitmap information m_bmpScopeFrame.GetObject( sizeof(BITMAP), &m_bmInfo ); m_size.cx = m_bmInfo.bmWidth; m_size.cy = m_bmInfo.bmHeight; // Hard code upper left position to place bitmap m_pt.x = 10; m_pt.y = 10; // Get temporary DC for dialog - Will be released in dc destructor //CClientDC dc(this); // Create compatible memory DC using the dialogs DC VERIFY( m_dcMem.CreateCompatibleDC( &dc ) ); // Selectbitmap into DC. // Get pointer to original bitmap // NOTE! This is temporary - save the handle instead VERIFY( pBmpOld = m_dcMem.SelectObject( &m_bmpScopeFrame ) ); VERIFY( m_hBmpOld = (HBITMAP) pBmpOld->GetSafeHandle() ); ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // BitBlt PlotCanvas bitmap onto dialog dc.BitBlt( m_pt.x, m_pt.y, m_size.cx, m_size.cy, &m_dcMem, 0, 0, SRCCOPY ); /* * First two parameters are upper left position to place bitmap. * Third and fourth parameters are width and height to copy * (could be less than actual size of bitmap) * Sixth and seventh are position in memory dc to start from * SRCCOPY specifies copy. * See BitBlt documentation for more details. */ ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Select old bitmap into memory dc (selecting out circle bitmap) // Need to create a temporary pointer to pass to do this ASSERT( m_hBmpOld ); VERIFY( m_dcMem.SelectObject( CBitmap::FromHandle(m_hBmpOld) ) ); // Need to DeleteObject() the bitmap that was loaded m_bmpScopeFrame.DeleteObject(); // m_dcMem destructor will handle rest of cleanup ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Do not call CDialog::OnPaint() for painting messages //if (IsIconic()) //{ // CPaintDC dc(this); // device context for painting //} //else //{ // CDialog::OnPaint(); //} PaintDone = true; } void CPlotCanvasDlg::OnClose() { // code here DestroyWindow(); //CDialog::OnClose(); } //void CPlotCanvasDlg::GetColor(int CtrlID, COLORREF &target) //{ // int stat; // CColorDialog dlg(m_backgroundColor); // stat = dlg.DoModal(); // if (stat == IDOK) // { // COLORREF color = dlg.GetColor(); // if (color != target) // { // target = color; // InvalidateControl(CtrlID); // } // } // return; //} void CPlotCanvasDlg::OnBnClickedCleartracebutton() { //m_PlotCanvasCtrl.OnRefreshBkgnd(); m_PlotCanvasCtrl.ClearTrace(); } void CPlotCanvasDlg::OnBnClickedMinimizebutton() { ShowWindow(SW_SHOWMINIMIZED); } void CPlotCanvasDlg::OnBnClickedClosewinbutton() { OnOK(); } //*********************************************************************** // CPlotCanvasDlg::InitScopeFrame() // // Purpose: // // Create compatible memory DC for dialog. // Load bitmap resource. Get bitmap size. // Select bitmap into memory DC and store handle to old bitmap. // Calculate position bitmap will be placed in dialog (hardcoded here). // // Parameters: // // None. // // Returns: // // BOOL (TRUE unless focus set to control) // // Comments: // // History: // // Date Comment Initials // ======== ================================================= ======== // Created //*********************************************************************** //BOOL CPlotCanvasDlg::InitScopeFrame() //{ // CBitmap * pBmpOld; // // Load bitmap resource - remember to call DeleteObject when done. // VERIFY( m_bmpScopeFrame.LoadBitmap( IDB_SCOPEFRAME ) ); // // Get bitmap information // m_bmpScopeFrame.GetObject( sizeof(BITMAP), &m_bmInfo ); // m_size.cx = m_bmInfo.bmWidth; // m_size.cy = m_bmInfo.bmHeight; // // Hard code upper left position to place bitmap // m_pt.x = 10; // m_pt.y = 10; // // Get temporary DC for dialog - Will be released in dc destructor // CClientDC dc(this); // // Create compatible memory DC using the dialogs DC // VERIFY( m_dcMem.CreateCompatibleDC( &dc ) ); // // Selectbitmap into DC. // // Get pointer to original bitmap // // NOTE! This is temporary - save the handle instead // VERIFY( pBmpOld = m_dcMem.SelectObject( &m_bmpScopeFrame ) ); // VERIFY( m_hBmpOld = (HBITMAP) pBmpOld->GetSafeHandle() ); // // local CCLientDC destructor for 'dc' will release device context // return TRUE; // return TRUE unless you set the focus to a control //} void CPlotCanvasDlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here // and/or call default CDialog::OnLButtonDown(nFlags, point); /* Emulate the user holding the left button down in the non-client area (the title bar). This will allow the user to drag the dialog box using the left mouse button. */ PostMessage( WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM( point.x, point.y ) ); //CRect rect; //GetWindowRect(&rect); //if (rect.left < 0) { // ::SetWindowPos(this->GetSafeHwnd(), NULL, 10, 10, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); //} //CDialog::OnLButtonDown(nFlags, point); } void CPlotCanvasDlg::OnBnClickedSizewinbutton() { //SetWindowPos(this.GetSafeHwnd(), NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); GetDlgItem(IDC_SMALLWINSIDE)->ShowWindow(SW_HIDE); // Create a 'CRgn' object CRgn rgn; CRect rect; GetWindowRect(&rect); rgn.CreateRoundRectRgn(0, 0, rect.Width(), rect.Height(), 30, 30); // Set the windows region SetWindowRgn(static_cast(rgn.GetSafeHandle()), TRUE); // Detach the 'CRgn' object from the region or else the // 'CRgn' destructor would close the 'HRGN' handle when 'rgn' // goes out of scope rgn.Detach(); //CRect rect; //GetWindowRect(&rect); //if (rect.left < 0) { // ::SetWindowPos(this->GetSafeHwnd(), NULL, LastRect.left, LastRect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); //} } void CPlotCanvasDlg::OnBnClickedSizewinbutton2() { //SetWindowPos(this.GetSafeHwnd(), NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); GetDlgItem(IDC_SMALLWINSIDE)->ShowWindow(SW_SHOW); // Create a 'CRgn' object CRgn rgn; CRect rect; GetWindowRect(&rect); rgn.CreateRoundRectRgn(0, 0, rect.Width()/2, rect.Height(), 30, 30); // Set the windows region SetWindowRgn(static_cast(rgn.GetSafeHandle()), TRUE); // Detach the 'CRgn' object from the region or else the // 'CRgn' destructor would close the 'HRGN' handle when 'rgn' // goes out of scope rgn.Detach(); } void CPlotCanvasDlg::OnBnClickedSizewinbutton3() { //CRect rect; //GetWindowRect(&rect); //LastRect = rect; //::SetWindowPos(this->GetSafeHwnd(), NULL, -1000, -1000, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); ShowWindow(SW_SHOWMINIMIZED); } void CPlotCanvasDlg::OnBnClickedRefreshusbbutton() { GetDlgItem(IDC_REFRESHUSBBUTTON)->EnableWindow(false); s.DppConfig.isCfgChanged = true; s.DppUSB.CloseUSB(); Sleep(200); s.DppUSB.OpenUSB(); Sleep(200); //s.wndMain->ForceShortUSBConfig(); //s.wndMain->SaveConfigToFile(); GetDlgItem(IDC_REFRESHUSBBUTTON)->EnableWindow(true); } void CPlotCanvasDlg::OnWindowCapture() { CString strError; // Save current working directory TCHAR szBuffer[_MAX_PATH]; _getcwd(szBuffer, _MAX_PATH); CString strDefPath = szBuffer; if (strDefPath.Right(1)[0] != '\\') strDefPath += '\\'; CString strTempFile = strDefPath + _T("PX4MCA_OSC-tmp.bmp"); // Look for temp file, and delete it. CFileFind finder; if (finder.FindFile(strTempFile)) ::DeleteFile(strTempFile); UpdateWindow(); // force update to prevent menu from hiding plot 20050331 // Capture window CWindowCapture objWinCapture; int iError = objWinCapture.OnCaptureWindow(this, strTempFile, TRUE); if (iError < 0) strError = _T("PlotCanvas Window capture failed..."); else strError = _T("PlotCanvas Window capture successful..."); } void CPlotCanvasDlg::OnBnClickedCapturetracebutton() { OnWindowCapture(); } void CPlotCanvasDlg::OnBnClickedCapturetracebutton2() { int LoopCounter; OnBnClickedSizewinbutton(); // expand the window PaintDone = false; UpdateWindow(); // force update to prevent plot in background LoopCounter = 0; while ((LoopCounter++ < 100) && (!PaintDone)) { // wait until paint is finished Sleep(100); } OnWindowCapture(); // capture the trace //OnBnClickedSizewinbutton2(); // restore the window size } ////void CSetThresholdDlg::SetCtrlColors(SET_THRESHOLD_STATE_TYPE stCurrentStateIn) ////{ //// //// COLORREF colorSlow; //// COLORREF colorFast; //// COLORREF colorInfo; //// COLORREF colorStatus; //// switch (stCurrentStateIn) { //// case ststReady: //// colorSlow = ctrlColBtnFace; //// colorFast = ctrlColBtnFace; //// colorInfo = ctrlColBtnFace; //// colorStatus = ctrlColLightCyan; //// break; //// case ststSetSlowThresh: //// colorSlow = ctrlColLightCyan; //// colorFast = ctrlColBtnFace; //// colorInfo = ctrlColBtnFace; //// colorStatus = ctrlColInfoBk; //// break; //// case ststSetFastThresh: //// colorSlow = ctrlColBtnFace; //// colorFast = ctrlColLightCyan; //// colorInfo = ctrlColBtnFace; //// colorStatus = ctrlColInfoBk; //// break; //// case ststSetThreshDone: //// colorSlow = ctrlColDefault; //// colorFast = ctrlColDefault; //// colorInfo = ctrlColDefault; //// colorStatus = ctrlColDefault; //// break; //// default: //// colorSlow = ctrlColDefault; //// colorFast = ctrlColDefault; //// colorInfo = ctrlColDefault; //// colorStatus = ctrlColDefault; //// break; //// } //// //// m_SlowThreshEdit.SetBkColor(colorSlow); //// m_SlowThreshChannelsEdit.SetBkColor(colorSlow); //// m_SlowCountsEdit.SetBkColor(colorSlow); //// m_MaxSlowCountsEdit.SetBkColor(colorSlow); //// m_UpperCountFilterCheck.SetBkColor(colorSlow); //// //// m_FastThreshEdit.SetBkColor(colorFast); //// m_FastCountsEdit.SetBkColor(colorFast); //// //// m_ModeEdit.SetBkColor(colorInfo); //// m_StatusEdit.SetBkColor(colorInfo); //// //// m_StatusLabel.SetBkColor(colorStatus); //// ////}