0

マウスでいくつかのピクセルを描画したいのですが、ペイントと同じように C++ で描画したいのですが、今のところうまくいきません。

私がやった事:

// NewPaint.cpp : main project file.
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <dos.h>
#include <Winuser.h>

int main()
{
    SetConsoleTitle(L"PaintER"); // Set text of the console so you can find the window
    HWND hWnd = GetConsoleWindow(); // Get the HWND
    HDC hdc = GetDC(hWnd); // Get the DC from that HWND
    textbackgroundcolor(WHITE); // Background color
    textcolor(BLACK); // Text color
    POINT p; // Pointer
    while(1) // Smt like  mouse button 1 
    {
        if (ScreenToClient(hWnd, &p)) // Mouse position
        {
            SetPixel(hdc, p.x, p.y, RGB(0,0,0)); // Draw black pixels
        }
    }
    ReleaseDC(hWnd, hdc); // Release the DC
    DeleteDC(hdc); // Delete the DC
    system("pause");
    return 0;
}

これには Visual Studio 2010 を使用し、Windows 7 を使用しています。これらは重要な情報になる可能性があると聞きました..

私はGDI +参照しか持っていないので、これを使用する方法を知っている場合はお知らせください。

コードで指定したように、コーディング例と説明が必要です。

4

0 に答える 0