2016-09-26 12 views
0

ここではCstring.Formatを割り当てています。変換する方法はありますか?私はそれを使用していたとき、私は次のエラーを取得する引数1を 'const char *'から 'const wchar_t *'に変換できません

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); 
} 
+2

にCStringの 'の最初の引数を:: Format'ではありません'char *'ドキュメントを読んで、[examples](https://msdn.microsoft.com/en-us/library/18he3sk6.aspx) – PaulMcKenzie

+1

を見てください。「ここで私はCstring.Formatを割り当てています。 - あなたはそうではありません。 – immibis

答えて

3

同じようにワイド文字列をマークする文字列定数の前にLを追加します。

strTemp.Format(L"Series: %d, Point: %d, X: %d, Y: %d", series, pointVal, x, y); 
関連する問題