Memory Device Environment
A memory device environment is an environment in which no device is associated with it. A memory device environment compatible with a standard device environment is generally used to copy a bitmap to the screen. You can do this by creating a memory device environment that is compatible with a standard device environment, then copying the bitmap you want to display into a memory device environment, and finally copying the bitmap from the memory device environment to the real device environment.
eg
void Cmainframe::onbitmapdraw () {cdc* pcdc=getdc ();//Get current device context CBitmap bitmap; Define CBitmap Object Bitmap.loadbitmap (idb_bitmap_1); Loads the specified ID bitmap object CDC MEMDC; Defines the memory context information, which is not created by new, is automatically freed and does not need to display the call RELEASEDCMEMDC.CREATECOMPATIBLEDC (PCDC); Creates a memory context compatible with the specified device //Here is the form memdc.selectobject (&BITMAP);//select object to Memory environment context bitmap BMINFO;//BITMAP structure The BITMAP structure defines the type, width, height, color format, and bit values of a bitmap.bitmap.GetObject (size Of (Bminfo), &bminfo); Retrieve bitmap image information, assign to Bminfo (get image Height-width information) pcdc->bitblt (100,0,bminfo.bmwidth,bminfo.bmheight,&memdc,0,0,srccopy) ;//Copy the Memory Environment mountain context to the device context ReleaseDC (PCDC);}
Visual C + + Print programming technology-memory device environment