现在封装了个资源的dll,里面有jpg,gif,png,bmp,相关的图片,加载进来dll,已经获取到相关图片的句柄,可是呈现的时候,确不知道该如何呈现,附上程序,望大侠帮帮小弟,刚入门。
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
hdcWindow=GetWindowDC(hWnd);
hMod = LoadLibrary(L"Image.dll");
hb1=LoadBitmap(hMod,MAKEINTRESOURCE(IDR_GIF1));
hr=FindResource(hMod,MAKEINTRESOURCE(IDR_GIF1),L"GIF");
hdcWindow=
dwSize=SizeofResource(hMod,hr);
lp=(LPSTR)LockResource(hr);
for(y=0;y<cxClient;y+=cySource)
for(x=0;x<cxClient;x+=cxSource)
{
BitBlt(hdc,x,y,cxSource,cySource,hdcWindow,0,0,SRCCOPY);
}
ReleaseDC(hWnd,hdcWindow);
EndPaint(hWnd,&ps);
FreeResource(hMod);
EndPaint(hWnd, &ps);
break;
不知道怎么获取图片的hdc,望大家指出,给个例子看看,
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
hdcWindow=GetWindowDC(hWnd);
hMod = LoadLibrary(L"Image.dll");
hb1=LoadBitmap(hMod,MAKEINTRESOURCE(IDR_GIF1));
hr=FindResource(hMod,MAKEINTRESOURCE(IDR_GIF1),L"GIF");
hdcWindow=
dwSize=SizeofResource(hMod,hr);
lp=(LPSTR)LockResource(hr);
for(y=0;y<cxClient;y+=cySource)
for(x=0;x<cxClient;x+=cxSource)
{
BitBlt(hdc,x,y,cxSource,cySource,hdcWindow,0,0,SRCCOPY);
}
ReleaseDC(hWnd,hdcWindow);
EndPaint(hWnd,&ps);
FreeResource(hMod);
EndPaint(hWnd, &ps);
break;
不知道怎么获取图片的hdc,望大家指出,给个例子看看,
HMODULE hMod = LoadLibrary("Pic.dll");
//14000为你要加载的图片在dll中的id,在resource。h里面找
HBITMAP hb1=LoadBitmap(hMod,MAKEINTRESOURCE(14000));
CDC *pDC=GetDC();
HDC dDlgDC=pDC->m_hDC;
HDC MemDC1 = CreateCompatibleDC(dDlgDC);
HGDIOBJ hOldBMP1 = ::SelectObject(MemDC1,hb1);
::StretchBlt(dDlgDC,15,15,715,515,MemDC1,0,0,300,300,SRCCOPY);