하대근
하대근

Reputation: 21

cannot convert argument 1 from 'const char *' to 'const wchar_t *'

Here I'm assigning Cstring.Format. Is there any way to convert? When I'm using it, I get the following error

void Cchart_event_07Dlg::OnMouseDownClientserver1(LPDISPATCH sender, LPDISPATCH args)
{
    /*This Event will display a MessageBox with the series and point information, as well as the XY coordinates.
    This is done when clicking anywhere in the Chart control. */

    Cfx62::_MouseEventArgsXPtr myArgs = (Cfx62::_MouseEventArgsXPtr)args;

    int x = myArgs->X;
    int y = myArgs->Y;
    int pointVal = myArgs->Point + 1;
    int series = myArgs->Series + 1;

    CString strTemp;

    enum Cfx62::HitType _result;
    HRESULT _hr = myArgs->get_HitType(&_result);

    if (_result == Cfx62::HitType_Point)
    {
        strTemp.Format("Series: %d, Point: %d, X: %d, Y: %d", series, pointVal, x, y);
        MessageBox(strTemp, NULL, MB_OK);
    }

    UpdateData(true);
}

Upvotes: 1

Views: 1768

Answers (1)

Anton Malyshev
Anton Malyshev

Reputation: 8861

Just add L before string constant to mark it as wide string:

strTemp.Format(L"Series: %d, Point: %d, X: %d, Y: %d", series, pointVal, x, y);

Upvotes: 4

Related Questions