我们知道,在往WINDOWS的屏幕上绘制任何内容之前,都必须先取得DC,用完之后必须释放,书上说这是因为DC是一种有限资源。但为什么我在自己的程序中,有时不释放也是可以的没任何问题。不是道DC从原理上来说到底是什么?为什么是一种有限资源?(不要泛泛而谈)

解决方案 »

  1.   

    WINDOWS 限制了可用的设备环境的数目,如果设备环境对象没有被成功删除的话,程序在退出之前有小部分的内存就丢失了。“有时不释放也是可以的没任何问题”你不相信你自己多试一下,不删除GDI对象,多启动几次你的程序,你的WINDOWS肯定挂!!!
      

  2.   

    A device context is a Windows data structure containing information about the drawing attributes of a device such as a display or a printer. All drawing calls are made through a device-context object, which encapsulates the Windows APIs for drawing lines, shapes, and text. Device contexts allow device-independent drawing in Windows. Device contexts can be used to draw to the screen, to the printer, or to a metafile.
      

  3.   

    既然说DC是一块内存区域上存储的数据,那么它是存取在用户空间还是系统空间呢? 
    honey说不释放DC的话,多启动几次程序,WINDOWS就会挂,那是因为什么?存储空间不够吗,还是其它什么原因?