void ImageViewDialog::SelectCash(int index) { cashIndex_ = index; if (monitor_ != NULL && cashIndex_ != -1) { int cashCount = monitor_->Freeze(); if (cashIndex_ < cashCount) { Cash *cash = monitor_->GetCash(cashIndex_); // draw image. Bitmap *topImage = cash->GetTopImage(); Bitmap *bottomImage = cash->GetBottomImage(); CString title; title.Format(IDS_VIEW_CASH_IMAGE, CA2T(cash->GetSN())); labelTitle_.SetWindowText(title); ASSERT(topImage != NULL && bottomImage != NULL); topImage_ = *topImage; bottomImage_ = *bottomImage; } monitor_->Unfreeze(); } Invalidate(); }
BOOL ImageViewDialog::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { UINT key = pMsg->wParam; if (key == VK_DOWN || key == VK_UP || key == VK_LEFT || key == VK_RIGHT || key == VK_NEXT || key == VK_PRIOR || key == VK_SPACE) { if (monitor_ != NULL && cashIndex_ != -1) { int cashCount = monitor_->Freeze(); int cashIndex = cashIndex_; if (key == VK_DOWN || key == VK_RIGHT || key == VK_NEXT || key == VK_SPACE) { cashIndex++; } else if (key == VK_UP || key == VK_LEFT || key == VK_PRIOR) { cashIndex--; } if (cashIndex < 0) { cashIndex = 0; } if (cashIndex >= cashCount) { cashIndex = cashCount - 1; } if (cashIndex != cashIndex_) { cashIndex_ = cashIndex; Cash *cash = monitor_->GetCash(cashIndex_); // draw image. Bitmap *topImage = cash->GetTopImage(); Bitmap *bottomImage = cash->GetBottomImage(); CString title; title.Format(IDS_VIEW_CASH_IMAGE, CA2T(cash->GetSN())); labelTitle_.SetWindowText(title); ASSERT(topImage != NULL && bottomImage != NULL); topImage_ = *topImage; bottomImage_ = *bottomImage; Invalidate(); } monitor_->Unfreeze(); } } } return CDialog::PreTranslateMessage(pMsg); }