保存位图
主要利用以下的结构和API
结构:BITMAPINFO
API: GetBitmapInfo, GetDIBits
之后按照位图的格式写文件
详细内容察看MSDN

解决方案 »

  1.   

    刷屏用Invalidate( BOOL bErase = TRUE );或InvalidateRect( LPCRECT lpRect, BOOL bErase = TRUE );函数的用法细看MSCN!
      

  2.   

    请详细些!!MemDC.saveas("filename")?
      

  3.   

    对于存图和上面说的一样,屏暮刷新可用以下三个函数
    BOOL GetWindowRect(
      HWND hWnd,      // handle to window
      LPRECT lpRect   // address of structure for window coordinates
    );HWND GetDesktopWindow(VOID);InvalidateRect(
      HWND hWnd,  // handle of window with changed update region
      CONST RECT *lpRect,
                  // address of rectangle coordinates
      BOOL bErase // erase-background flag
    }
      

  4.   

    ------------Method 1-----------
    int iScrWidth = GetSystemMetrics(SM_CXSCREEN);
    int iScrHeight = GetSystemMetrics(SM_CYSCREEN);HDC hdcScreen = GetDC(NULL);BITMAPINFO bmpInfo;
    bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmpInfo.bmiHeader.biWidth              = iScrWidth;
    bmpInfo.bmiHeader.biHeight             = iScrHeight;
    bmpInfo.bmiHeader.biPlanes             = 1;
    bmpInfo.bmiHeader.biBitCount           = 24;
    bmpInfo.bmiHeader.biCompression        = BI_RGB;
    bmpInfo.bmiHeader.biSizeImage          = 0;
    bmpInfo.bmiHeader.biXPelsPerMeter      = 0;
    bmpInfo.bmiHeader.biYPelsPerMeter      = 0;
    bmpInfo.bmiHeader.biClrUsed            = 0;
    bmpInfo.bmiHeader.biClrImportant       = 0;void *pvBits = NULL;
    HBITMAP hBitmap = CreateDIBSection(hdcScreen,&bmpInfo,DIB_RGB_COLORS,&pvBits,NULL,0);
    HDC hdcCompatible = CreateCompatibleDC(hdcScreen);
    HBITMAP hOldBitmap = (HBITMAP)SelectObject(hdcCompatible,hBitmap);
    BOOL b = BitBlt(hdcCompatible,0,0,iScrWidth,iScrHeight,hdcScreen,0,0,SRCCOPY);HANDLE hFile = CreateFile("yourbmp.bmp",GENERIC_WRITE,FILE_SHARE_WRITE,NULL,
               CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
    if (hFile != INVALID_HANDLE_VALUE) 
    {
       DWORD dwCnt;
       char z[14];
       ZeroMemory(z,14);
       strcpy(z,"BM8");
       z[4] = 0x24;
       z[10] = 0x36;
       WriteFile(hFile,z,14,&dwCnt,NULL);
       WriteFile(hFile,(char*)&bmpInfo,sizeof(BITMAPINFO)-4,&dwCnt,NULL);
       WriteFile(hFile,(char*)pvBits,iScrWidth*iScrHeight*3,&dwCnt,NULL);
       CloseHandle(hFile);
    }     
        
    ------------Method 2---------
    CDC * pDC; 
    CBitmap  bmpTmp;
    CBitmap * bmpOld = bmpTmp.CreateCompatibleBitmap(pDC, 640, 480);   
    pDC->SelectObject(bmpTmp);
    pDC->MoveTo(0,0); 
    pDC->LineTo(300,200);
    CBitmap * bmpOut = pDC->SelectObject(bmpOld);----------