OnDraw中
MoveTo
LineTo

解决方案 »

  1.   

    Windows下作图比TC下面Dos作图容易多了。
      

  2.   

    看一下:
    http://www.truevcl.com
      

  3.   

    我给一个例子吧
    以下程序可以在控制台上画个圆并在中间用渐变色画一条带子.最上面是标准的hello world.
    // consoledraw.cpp : Defines the entry point for the console application.
    //#include "stdafx.h"
    #include <windows.h>
    #include <conio.h>HWND GetConsoleHwnd(void);int main(int argc, char* argv[])
    {
    printf("Hello World!\n");
    HWND hwnd=GetConsoleHwnd();
    RECT rectcli,rect;
    GetClientRect(hwnd,&rectcli);
    memcpy(&rect,&rectcli,sizeof(rect));
    rect.bottom =10;
    OffsetRect(&rect,0,(rectcli.bottom -rectcli.top-10)/2);
    HDC hdc=GetDC(hwnd);
    for (int i=rect.left;i<rect.right ;i++){
    HPEN hpen=CreatePen(PS_SOLID,1,RGB(255-(255*i)/(rect.right -rect.left),0,0));
    HPEN hpenOld=(HPEN)SelectObject(hdc,hpen);
    MoveToEx(hdc,i,rect.top,NULL);
    LineTo(hdc,i,rect.bottom );
    SelectObject(hdc,hpenOld);
    DeleteObject(hpen);
    }
    HPEN hpen=CreatePen(PS_SOLID,1,RGB(0,255,0));
    HPEN hpenOld=(HPEN)SelectObject(hdc,hpen);
    LOGBRUSH lb;
    memset(&lb,0,sizeof(lb));
    lb.lbStyle =BS_NULL;
    HBRUSH hbrush=CreateBrushIndirect(&lb);
    HBRUSH hbrOld=(HBRUSH)SelectObject(hdc,hbrush);
    Ellipse(hdc,rectcli.left ,rectcli.top,rectcli.right,rectcli.bottom);
    SelectObject(hdc,hpenOld);
    DeleteObject(hpen);
    SelectObject(hdc,hbrOld);
    DeleteObject(hbrOld);
    ReleaseDC(hwnd,hdc);
    getch();
    return 0;
    }HWND GetConsoleHwnd(void) {     #define MY_BUFSIZE 1024 // buffer size for console window titles
        HWND hwndFound;         // this is what is returned to the caller
        char pszNewWindowTitle[MY_BUFSIZE]; // contains fabricated WindowTitle
        char pszOldWindowTitle[MY_BUFSIZE]; // contains original WindowTitle    // fetch current window title    GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);    // format a "unique" NewWindowTitle    wsprintf(pszNewWindowTitle,"%d/%d",
                    GetTickCount(),
                    GetCurrentProcessId());    // change current window title    SetConsoleTitle(pszNewWindowTitle);    // ensure window title has been updated    Sleep(40);    // look for NewWindowTitle    hwndFound=FindWindow(NULL, pszNewWindowTitle);    // restore original window title    SetConsoleTitle(pszOldWindowTitle);    return(hwndFound);} 
      

  4.   

    TC的程序(使用BGI),完全可以在CONSOLE中运行(窗口或全屏都可以)使用VC窗口方式可以直接调用GDI
    全屏方式,我也不知道怎么办