// ToolBox.cpp : implementation file // #include "stdafx.h" #include "ToolBox.h" #include "CityLoopDlg.h" #include #ifdef _DEBUG #define new DEBUG_NEW #endif // CToolBox dialog IMPLEMENT_DYNAMIC(CToolBox, CDialog) CToolBox::CToolBox(CWnd* pParent /*=NULL*/) : CDialog(CToolBox::IDD, pParent) { } CToolBox::~CToolBox() { } void CToolBox::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDOK, m_Run); DDX_Control(pDX, IDCANCEL, m_Quit); DDX_Control(pDX, IDC_TIME, m_Slider); } BOOL CToolBox::Create(int offset, CWnd* parent) { m_offset = offset; return CDialog::Create(IDD,parent); } BEGIN_MESSAGE_MAP(CToolBox, CDialog) ON_BN_CLICKED(IDOK, &CToolBox::OnBnClickedOk) ON_BN_CLICKED(IDCANCEL, &CToolBox::OnBnClickedCancel) // ON_NOTIFY(TRBN_THUMBPOSCHANGING, IDC_TIME, &CToolBox::OnTRBNThumbPosChangingTime) ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_TIME, &CToolBox::OnNMReleasedcaptureTime) ON_NOTIFY(NM_CUSTOMDRAW, IDC_TIME, &CToolBox::OnNMCustomdrawTime) END_MESSAGE_MAP() // CToolBox message handlers void CToolBox::OnBnClickedOk() { if(theNetwork->IsRunning()) { theNetwork->Stop(); m_Run.SetWindowText(_T("Run")); } else { theNetwork->Go(); m_Run.SetWindowText(_T("Stop")); } m_Run.Invalidate(); } void CToolBox::Resize() { if(IsWindow(m_hWnd)) { if(GetParent()) { CRect rc; GetParent()->GetClientRect(rc); rc.top = rc.bottom - m_offset; SetWindowPos(NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_NOOWNERZORDER); CRect qrc; m_Quit.GetClientRect(qrc); m_Quit.SetWindowPos(NULL,rc.right - 5 - qrc.Width(),qrc.top+4,0,0,SWP_NOOWNERZORDER | SWP_NOSIZE); Invalidate(); } } } void CToolBox::OnBnClickedCancel() { ((CCityLoopDlg*)GetParent())->Quit(); } //void CToolBox::OnTRBNThumbPosChangingTime(NMHDR *pNMHDR, LRESULT *pResult) //{ // // This feature requires Windows Vista or greater. // // The symbol _WIN32_WINNT must be >= 0x0600. // // TODO: Add your control notification handler code here // // theNetwork->SetSpeed(m_Slider.GetPos()); // // *pResult = 0; //} BOOL CToolBox::OnInitDialog() { CDialog::OnInitDialog(); m_Slider.SetRange(1,10); m_Slider.SetPos(5); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CToolBox::OnNMReleasedcaptureTime(NMHDR *pNMHDR, LRESULT *pResult) { // TODO: Add your control notification handler code here theNetwork->SetSpeed(m_Slider.GetPos()); *pResult = 0; } void CToolBox::OnNMCustomdrawTime(NMHDR *pNMHDR, LRESULT *pResult) { LPNMCUSTOMDRAW pNMCD = reinterpret_cast(pNMHDR); // TODO: Add your control notification handler code here *pResult = 0; }