microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++
https://walbourn.github.io/directxtk/
MIT License
2.57k stars 511 forks source link

UI error #345

Closed dudedude1234 closed 1 year ago

dudedude1234 commented 1 year ago

Im setting up the mouse input for the menu

` bool StartScreen::isTextClicked() { auto state = m_mouse->Get().GetState();

RECT rect(state.x, state.y, m_fontPos.x, m_fontPos.y);

return rect(state.x, state.y, m_fontPos.x, m_fontPos.y);

} `

I got this error:

Severity Code Description Project File Line Suppression State Error (active) E0289 no instance of constructor "tagRECT::tagRECT" matches the argument list

walbourn commented 1 year ago

RECT doesn't have a ctor. It's just a generic struct defined in windef.h:

typedef struct tagRECT
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;

There is a D3D11_RECT that is derived that RECT that adds a ctor unless you are building with D3D11_NO_HELPERS.

See https://github.com/microsoft/DirectXTK/wiki/DirectXHelpers

You can use C++11 uniform initialization with the base RECT as follows:

RECT rect = { state.x, state.y, m_fontPos.x, m_fontPos.y };

That said, it's most likely that your font positions are float so you'll get conversion warnings unless you cast them:

RECT rect = {  state.x, state.y, static_cast<long>(m_fontPos.x), static_cast<long>(m_fontPos.y) };