一道简单的c语言题目

mikescofied 2008-12-29 06:40:29
在用vc6.0编写图形的时候,不能使用graphic.h 这个头文件,这是tc中使用的,在vc6.0中的图形函数应该是怎么一回事???
...全文
152 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaojia268115 2008-12-29
  • 打赏
  • 举报
回复
GDI

GDI --图形设备接口
即Graphics Device InterfaceGraphics Interface.通过图形设备接口对图形及文字的属性进行控制。
要在窗口的客户区绘图,可以使用WindowsWindows的图形设备接口(GDIGDI)函数
)GDI的重要部分:设备描述表(DCDC))
每个GDIGDI函数都需要将设备描述表句柄作为函数的第一个参数,例如
hdc= GetDC(hwnd) ; //获得窗口句柄
DrawText( HDC, LPCTSTR, , int, LPRECT, UINT ); //绘图
TextOut(HDC,int,int, LPCTSTR, int); //输出文字
ReleaseDC(hwnd, hdc) ; //释放句柄

luojc714 2008-12-29
  • 打赏
  • 举报
回复
以前学过一点,不过都忘的差不多了!
貌似用GDI函数首先得获得一个HDC(设备环境句柄),这个应该是和窗口相关的,所以要先创建一个窗口。再说了你要画东西不得画在窗口里嘛,MFC就可以用来创建窗口...
如果用OpenGL就没那么麻烦了,OpenGL有一个库函数可以直接创建窗口,然后就爱画啥画啥!
w382120035 2008-12-29
  • 打赏
  • 举报
回复
MFC是微软封装了的API
mikescofied 2008-12-29
  • 打赏
  • 举报
回复
谢谢!这其中与MFC有联系吗???
w382120035 2008-12-29
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 mikescofied 的回复:]
引用 1 楼 w382120035 的回复:
用GDI函数,要不就用DirectX或者OpenGL

那用GDI函数编写图形,这其中与MFC有什么联系没有??
[/Quote]
MFC下可以使用,只要是windows程序都能使用GDI,建议lz看一下《windows程序设计》
ParadoxDilemma 2008-12-29
  • 打赏
  • 举报
回复
我发一段画线的程序吧
msdn里的,你可以自己去查的

画线的函数是 LineTo,就三个参数,
关键是hdc,你可以再去查GetDC()等等
msdn里有例子的


LineTo
The LineTo function draws a line from the current position up to, but not including, the specified point.

BOOL LineTo(
HDC hdc, // device context handle
int nXEnd, // x-coordinate of ending point
int nYEnd // y-coordinate of ending point
);
Parameters
hdc
[in] Handle to a device context.
nXEnd
[in] Specifies the x-coordinate, in logical units, of the line's ending point.
nYEnd
[in] Specifies the y-coordinate, in logical units, of the line's ending point.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT/2000/XP: To get extended error information, call GetLastError.

Remarks
The line is drawn by using the current pen and, if the pen is a geometric pen, the current brush.

If LineTo succeeds, the current position is set to the specified ending point.

Example Code
For an example, see Drawing Markers.

Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.

See Also
Lines and Curves Overview, Line and Curve Functions, MoveToEx, Polyline, PolylineTo


--------------------------------------------------------------------------------

© 2005 Microsoft Corporation. All rights reserved.

Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.
See Also
Lines and Curves Overview, Line and Curve Functions, MoveToEx, Polyline, PolylineTo


--------------------------------------------------------------------------------

© 2005 Microsoft Corporation. All rights reserved.
nullah 2008-12-29
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xiaoyisnail 的回复:]
要用这几个lz可有东西要学了
[/Quote]
呵呵
mikescofied 2008-12-29
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 w382120035 的回复:]
用GDI函数,要不就用DirectX或者OpenGL
[/Quote]
那用GDI函数编写图形,这其中与MFC有什么联系没有??
xiaoyisnail 2008-12-29
  • 打赏
  • 举报
回复
要用这几个lz可有东西要学了
mikescofied 2008-12-29
  • 打赏
  • 举报
回复
你说的这几个能用c编写吗???
lcd5 2008-12-29
  • 打赏
  • 举报
回复
graphic.h是TC的头文件,VC是没有的,
VC里面可以调用GDI函数,一样方便
w382120035 2008-12-29
  • 打赏
  • 举报
回复
用GDI函数,要不就用DirectX或者OpenGL

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧