Drawing in a Win32 Console on C++?

前端 未结 6 2191
一生所求
一生所求 2020-12-03 13:00

What is the best way to draw things in the Console Window on the Win 32 platform using C++?

I know that you can draw simple art using symbols bu

6条回答
  •  独厮守ぢ
    2020-12-03 13:14

    #include 
    #include 
    
    
    int main()
    {
        // Get window handle to console, and device context
        HWND console_handle = GetConsoleWindow();
        HDC device_context = GetDC(console_handle);
    
        //Here's a 5 pixels wide RED line [from initial 0,0] to 300,300
         HPEN pen =CreatePen(PS_SOLID,5,RGB(255,0,0));
        SelectObject(device_context,pen);
        LineTo(device_context,300, 300);
    
    
        ReleaseDC(console_handle, device_context);
        cin.ignore();
        return 0;
    }
    

提交回复
热议问题