0

問題は&cursorTile.Attributes.
、私が得ているエラーは(argument of type "WORD*" is incompatible with parameter of type "LPCWSTR")
、いくつかの解決策を見つけようとしたことです。マルチバイト文字セットを使用しています。

void CMap::Draw(){
SMALL_RECT drawRect = { 0, 0, MAP_WIDTH - 1, MAP_HEIGHT - 1 };
COORD buffersize = { MAP_WIDTH, MAP_HEIGHT };
COORD zeroZero = { 0, 0 };
DWORD dwResult = 0;
char szCursor[2] = "";

HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);

for (int i = 0; i < (int)m_vTiles.size(); i++){
    m_screenBuffer[i] = m_vTiles[i].GetChar();
}

WriteConsoleOutput(hOutput, m_screenBuffer, buffersize, zeroZero, &drawRect);

if (g_pCursorTile != NULL){
    CHAR_INFO cursorTile = g_pCursorTile->GetChar();
    sprintf(szCursor, "%c", cursorTile.Char);
    WriteConsoleOutputCharacter(hOutput, szCursor, 1, g_cursorPos, &dwResult);
    WriteConsoleOutputCharacter(hOutput, &cursorTile.Attributes, 1, g_cursorPos, &dwResult);
}
4

2 に答える 2

1

これは非常に説明的なエラーです。 WriteConsoleOutputCharacter2 番目の引数として何らかの文字列が必要です。あなたのプログラムが unicode として定義されている場合、それは を期待LPCWSTRwchar_t*ます。

あなたの呼び出しで&cursorTile.Attributesは、 which の型を持つものを渡しますDWORD*(これもまた、醜い型定義unsigned long*です)。unsigned long ポインターの代わりに、ワイド文字列を渡す必要があります。これは、印刷しようとしている文字列です。

于 2015-08-03T10:18:42.793 に答える
0

DWORD: 32 ビットの符号なし整数。範囲は 0 ~ 4294967295 10 進数です。

typedef unsigned long DWORD;

LPCWSTR: 16 ビット Unicode 文字の null で終わる定数文字列へのポインター。

typedef CONST WCHAR *LPCWSTR;

どちらもまったく異なるデータ型です。

于 2015-08-03T10:24:10.773 に答える