Win32API スクリーンバッファの指定した座標から文字を書き込む FillConsoleOutputCharacter

スクリーンバッファの指定した座標から文字を書き込むには、FillConsoleOutputCharacter関数を用いる。


  • FileConsoleOutputCharacterのプロトタイプ
  • BOOL FillConsoleOutputCharacter(
      HANDLE hConsoleOutput,  // スクリーンバッファのハンドル
      TCHAR cCharacter,       // 書き込む文字
      DWORD nLength,          // 書き込み先文字セル数
      COORD dwWriteCoord,     // 先頭のセルの X 座標と Y 座標
      LPDWORD lpNumberOfCharsWritten
                              // 書き込まれたセル数へのポインタ
    );



  • 使用例
  • #include <windows.h>
    #include <stdio.h>
    
    int main()
    {
    	DWORD dwWritten;
    	COORD coord = {10, 10};
    	wchar_t ch = L'あ';
    
    	FillConsoleOutputCharacterW(
    		GetStdHandle(STD_OUTPUT_HANDLE), 
    		ch, 
    		sizeof(ch)*10, 
    		coord, 
    		&dwWritten);
    
    	return 0;
    }


  • 実行結果



  • 参考
    http://msdn.microsoft.com/ja-jp/library/cc429221.aspx