- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "NoPassword.h"
- #include "MainFrm.h"
- #include "NPView.h"
- #include "NPDoc.h"
- #include "SetupDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_WM_CLOSE()
- ON_COMMAND(IDM_SETUP, OnSetup)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if (!m_SpeedBar.Create(this,IDD_SPEED, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM
- | CBRS_GRIPPER | CBRS_SIZE_DYNAMIC,IDD_SPEED))
- return -1; // fail to create
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- return -1; // fail to create
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- cs.cx = 420;
- cs.cy = 500;
- cs.style &= ~(WS_MAXIMIZEBOX | WS_THICKFRAME);
- return CFrameWnd::PreCreateWindow(cs);
- }
- void CMainFrame::OnClose()
- {
- WSACleanup();
- ((CNPView *)GetActiveView())->KillAllThreads();
- CFrameWnd::OnClose();
- }
- void CMainFrame::UpdateSpeedBarData()
- {
- m_SpeedBar.Add();
- }
- void CMainFrame::OnSetup()
- {
- // TODO: Add your command handler code here
- CSetupDlg dlg;
- dlg.m_AutoShutDown = CNPApp::m_bAutoShutDown;
- dlg.m_Path = CNPApp::m_strSaveFile;
- dlg.m_Sampling.Format("%d",CNPApp::m_Sampling);
- dlg.m_Scale = CNPApp::m_Scale;
- if(dlg.DoModal() == IDOK)
- {
- CNPApp::m_bAutoShutDown = dlg.m_AutoShutDown;
- CNPApp::m_strSaveFile = dlg.m_Path;
- CNPApp::m_Sampling = atoi(dlg.m_Sampling);
- CNPApp::m_Scale = dlg.m_Scale;
- ((CNPApp*)AfxGetApp())->SaveSettings();
- }
- }