您的位置首页百科问答

关于graphics. h

问题补充说明:V C++3.0函数库中没有 (图形函数库),只在T C++中有,那怎么才能在VC ++中调用图像函数库呢???

关于graphics. h

TC的graphics.h和graphics.lib只能在TC和DOS下使用,VC里使用GDI。你可以使用MFC类库中的CDC类来画图。附加一个例:才在View类中添加OnLButtonDown和OnLButtonUp函数

相应代码如下,LButtonDown中每一个/**木路最系花的/实现一种功能,是我以前照书上的写的,绝对能运行你自己试下

voidCDrawView::OnLButtonDown(UINTnFlags,CPointpoint)

{

//TODO:Addyourmessagehandlercode车果具率敌脸火却地粉hereand/orcalldefault

m_ptOrigin=point;

CView::OnLButtonDown(nFlags,point);

}

voidCDrawView::OnLButtonUp(UI来自NTnFlags,CPointpoint)

{

//TODO:Addyourmessagehandlercodeherea营张六nd/orcalldefault

/*

HDChdc;

hd套物延硫温游示c=::GetDC360问答(m_hWnd);

MoveToEx(hdc,m_础回东情养哪当助斯ptOrigin.x,m_ptOrigin.y,NULL);

LineTo(hdc,point.x,po频迫吸晶穿路氢队总int.y);

::ReleaseDC(m_hWnd,hdc);*/

/*

CDC*pDC=GetDC();

pDC->MoveTo(m_ptOrigin);

pDC->LineTo(point);

Relea艺屋既行药seDC(pDC);*/

/*

CClientDCdc(妒里由奏据技this);//view??à????

//CClientDCdc(GetParent());//mainFrame务毫武治触静身卷游??à????

dc.MoveTo(m_ptOrig缩考in);

dc.L项历见械口内鱼丝城ineTo(point);投重*/

/*

//CWindowDCdc(this);

//CWindowDC侵试评双病曾查开蛋态克dc(GetPa数甲房消促型费极的rent());//知阶要以·????????°????°ü??¨±ê????????

CWindowDCdc(GetDesktopWindow());//·??????????????????????

dc.MoveTo(m_ptOrigin);

dc.LineTo(point);*/

/*

C行想队全他友均手营路坚Penpen(PS_DASH,1,RGB(0,0,255));//DASHpen

CClientDCdc(this);

CPen*pOldPen=dc.SelectObject(&pen);

dc.MoveTo(m_ptOrigin);

dc.LineTo(point);

dc.SelectObject(pOldPen);*/

/*

CBrushbrush(RGB(0,0,255));//画刷

CClientDCdc(this);

dc.FillRect(CRect(m_ptOrigin,point),&brush);*/

/*

CBitmapbitmap;//位图画刷

bitmap.LoadBitmap(IDB_BITMAP1);

CBrushbrush(&bitmap);

CClientDCdc(this);

dc.FillRect(CRect(m_ptOrigin,point),&brush);*/

CClientDCdc(this);

//dc.Rectangle(CRect(m_ptOrigin,point));//矩形

CBrush*pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));

CBrush*pOldBrush=dc.SelectObject(pBrush);

dc.Rectangle(CRect(m_ptOrigin,point));

dc.SelectObject(pOldBrush);

CView::OnLButtonUp(nFlags,point);//透明矩形

}