LRESULT CScalableLayout::MessageHandler( UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled ) { if (uMsg == WM_MOUSEWHEEL) { WORD fwKeys = LOWORD(wParam); // key flags if (fwKeys != 0) { return 0; } short zDelta = (short) HIWORD(wParam); // wheel rotation POINT pt; pt.x = (short) LOWORD(lParam); // horizontal position of pointer pt.y = (short) HIWORD(lParam); // vertical position of pointer ::ScreenToClient(m_hParentWnd,&pt); if (zDelta > 0) { // zoom in CControlUI *pHit = GetManager()->FindControl(pt); CButtonUI *pHitButton = dynamic_cast<CButtonUI*>(pHit); if (pHitButton == 0) { return 0; } ZoomIn(pHitButton->GetName()); } else { RECT rc = m_pContainer->GetPos(); if (!::PtInRect(&rc,pt)) { return 0; } ZoomOut(); } bHandled = TRUE; return 0; } return 0; }
void CQuizWnd::OnClick(TNotifyUI& msg) { AUTO_LOG_FUNCTION; #ifdef _DEBUG std::wstringstream ss; ss << msg.pSender->GetName().GetData() << std::endl << std::ends; OutputDebugString(ss.str().c_str()); #endif CButtonUI* btn = static_cast<CButtonUI*>(msg.pSender); std::wstring btnName = btn->GetName().GetData(); if (btnName.compare(0, ((wstring)BTN_QUESTION_PREFIX).length(), BTN_QUESTION_PREFIX) == 0) { auto name = btnName.substr(((wstring)BTN_QUESTION_PREFIX).length()); // update buttion ui UpdateButtonUi(btn, name); if (name == L"done") { // exam done(); } else { // show quiz int ndx = std::stoi(name); g_prev_clicked_button_option = nullptr; ShowQuiz(ndx); } } else if (btnName.compare(0, ((wstring)BTN_OPTION_PREFIX).length(), BTN_OPTION_PREFIX) == 0) { auto option = btnName.substr(((wstring)BTN_OPTION_PREFIX).length()); // update option ui UpdateButtonUi2(btn, option); // save user answer if (g_cur_quiz_info) { g_cur_quiz_info->set_user_answer(option); } } return __super::OnClick(msg); }
int ShowMsgBox(HWND hwnd, LPCTSTR lpszText, LPCTSTR lpszCaption, UINT nType) { if(!IsWindow()) { // this->Create(hwnd,lpszCaption,UI_WNDSTYLE_DIALOG,UI_WNDSTYLE_EX_DIALOG); this->Create(hwnd,lpszCaption,UI_WNDSTYLE_DIALOG,0); } CenterWindow(); CTextUI* pTitle = static_cast<CTextUI*>(GetPaintMgr()->FindControl(_T("title"))); CTextUI* pMsg = static_cast<CTextUI*>(GetPaintMgr()->FindControl(_T("msg"))); CButtonUI* pCancelBtn = static_cast<CButtonUI*>(GetPaintMgr()->FindControl(_T("cancel"))); CButtonUI* pOkBtn = static_cast<CButtonUI*>(GetPaintMgr()->FindControl(_T("yes"))); CTabLayoutUI* pTable = static_cast<CTabLayoutUI*>(GetPaintMgr()->FindControl(_T("icon"))); CCheckBoxUI* pCheckBox= static_cast<CCheckBoxUI*>(GetPaintMgr()->FindControl(_T("checkbox"))); ASSERT(pTitle); ASSERT(pMsg); ASSERT(pCancelBtn); ASSERT(pOkBtn); ASSERT(pTable); ASSERT(pCheckBox); if(pTitle) pTitle->SetText((lpszCaption ? lpszCaption : _T(""))); if(pMsg) pMsg->SetText((lpszText ? lpszText : _T(""))); if(pCancelBtn) pCancelBtn->SetFocus(); if(pTable) { if(nType & MBT_INFO) pTable->SelectItem(0); else if(nType & MBT_OK) pTable->SelectItem(1); else if(nType & MBT_WARN) pTable->SelectItem(2); } const bool isShowCancel = (pCancelBtn && ((nType & MBBT_CANCEL) > 0)); const bool isShowOk = (pOkBtn && ((nType & MBBT_OK) > 0)); const bool isShowCheckBox = (pCheckBox &&((nType & MBBT_CHECKBOX) > 0)); const bool isShake = ((nType & MBT_SHAKE) > 0); _bShakeWindow = isShake; pCancelBtn->SetVisible(isShowCancel); pOkBtn->SetVisible(isShowOk); pCheckBox->SetVisible((/*isShowOk && */isShowCheckBox)); if(!isShowCancel && isShowOk) { pCancelBtn->SetVisible(true); pOkBtn->SetVisible(false); pCancelBtn->SetName(pOkBtn->GetName()); pCancelBtn->SetText(pOkBtn->GetText()); pCancelBtn->SetToolTip(pOkBtn->GetToolTip()); pCancelBtn->SetFocus(); } return ShowModal(); }