在TImage控件中显示图片时,怎样获得图片的设备上下文hdc,
是不是这个属性TImage.Canvas.Handle;

解决方案 »

  1.   

    to: mikespook
    用了这个参数,在调用VC做的动态库时:动态库导出函数中执行到HDC hdcCompatible = CreateCompatibleDC(hdc)时; (hdc是我从delphi传进去的设备上下文),却总是创建失败,
    我是VC和delphi混合编程,VC做动态库,delphi做应用程序前台界面。
      

  2.   

    IMAGEDATA_API int WINAPI I_ReqPixData(HBITMAP hbm, HDC hdc)
    {
    PBITMAPINFO pbmi;
             int nWidth;
    int nHeight;
    pbmi = CreateBitmapInfoStruct(hbm); 
    nWidth=pbmi->bmiHeader.biWidth;
    nHeight=pbmi->bmiHeader.biHeight; 
    HDC hdcCompatible = CreateCompatibleDC(hdc);
    DWORD err;
    if (hdcCompatible==0) 
    {
                err=GetLastError();  }
        /* Select the bitmaps into the compatible DC. */ 
        
              SelectObject(hdcCompatible, hbm);
    //ShowWindow(SW_HIDE); 

    BitBlt(hdcCompatible, 
                   0,0, 
                   nWidth, nHeight, 
                   hdc, 
                   0,0, 
                   SRCCOPY); 
        
    //ShowWindow(SW_SHOW); 

      
        
    char* strfile="d:\\wqs1.bmp";
    CreateBMPFile(strfile,pbmi,hbm,hdcCompatible);
        return 0;
    }
      

  3.   

    你用Image1.Handle替换一下bitmap的句柄看看~~~~这里的HDC是设备环境句柄~~~不是BITMAP的句柄~~