Ejemplo n.º 1
0
        void NRenderStatus::DrawStatus()
        {
            DWORD currentTime = ::GetTickCount();

            Base::NString status;
            if(currentTime <= lastTime_)
                status.Format(_T("Index: %d\r\nFPS: MAX"), ++ index_);
            else
                status.Format(_T("Index: %d\r\nFPS: %.2f"), ++ index_, (double)1000 / (currentTime - lastTime_));

            lastTime_ = currentTime;

            Base::NRect rcClient;
            ::GetClientRect(hWnd_, rcClient);

            HDC hDc = ::GetDC(hWnd_);

            Base::NRect rcText(rcClient);
            ::DrawText(hDc, status.GetData(), status.GetLength(), rcText, DT_EDITCONTROL | DT_CALCRECT);
            rcText.Offset(rcClient.Width() - rcText.Width() - 8, 8);

            CAlphaDC alphaDc;
            if(alphaDc.Init(hDc, rcText, rcClient.GetSize(), true))
            {
                ::SetBkColor(alphaDc, RGB(255, 255, 0));
                ::SetBkMode(alphaDc, OPAQUE);
                ::DrawText(alphaDc, status.GetData(), status.GetLength(), rcText, DT_EDITCONTROL);

                alphaDc.EndDraw(255);
            }
            ::ReleaseDC(hWnd_, hDc);
        }
Ejemplo n.º 2
0
        NEdit* NEdit::ShowTooltip(TooltipIconType iconType, LPCTSTR szTitle, LPCTSTR szText)
        {
            NAssertError(IsWndValid(), _T("call parent->AddChild first"));
            if(!IsWndValid())
                return this;

            nui::Base::NInstPtr<nui::Data::NStringBundle> stringBundle(MemToolParam);
            Base::NString strTitle = stringBundle->GetString(szTitle);
            Base::NString strText = stringBundle->GetString(szText);

            EDITBALLOONTIP tip = {sizeof(EDITBALLOONTIP)};
            tip.pszText = strText.GetData();
            tip.pszTitle = strTitle.GetData();
            tip.ttiIcon = iconType;
            ::SendMessage(realWindow_, EM_SHOWBALLOONTIP, 0, (LPARAM)&tip);
            return this;
        }