Thanks for your intrest to my problem.
I've changed the work method and I've used this function
void CWWizard::CreateBMPFile(HWND hwnd, LPTSTR pszFile, std::vector<CString> bmpListBmp, HDC hDC)
{
HANDLE hf;
BITMAPFILEHEADER hdr;
PBITMAPINFOHEADER pbih;
LPBYTE lpBits;
DWORD dwTotal;
DWORD cb;
BYTE *hp;
DWORD dwTmp;
if((int)bmpListBmp.size() > 0)
{
hf = CreateFile(pszFile,
GENERIC_READ | GENERIC_WRITE,
(DWORD) 0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
if (hf == INVALID_HANDLE_VALUE)
errhandler("CreateFile", hwnd);
hdr.bfType = 0x4d42;
for(int nIdImg = 0; nIdImg < (int)bmpListBmp.size(); nIdImg++)
{
HBITMAP hBMP = GetBmpUnifie(bmpListBmp[nIdImg], m_BrosseFondWizard);
PBITMAPINFO pbi = CreateBitmapInfoStruct(this->m_hWnd, hBMP);
pbih = (PBITMAPINFOHEADER) pbi;
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
if (!lpBits)
errhandler("GlobalAlloc", hwnd);
if (!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi, DIB_RGB_COLORS))
{
errhandler("GetDIBits", hwnd);
}
hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) +
pbih->biSize + pbih->biClrUsed
* sizeof(RGBQUAD) + pbih->biSizeImage);
hdr.bfOffBits += (DWORD) sizeof(BITMAPFILEHEADER) +
pbih->biSize + pbih->biClrUsed
* sizeof (RGBQUAD);
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER), (LPDWORD) &dwTmp, NULL))
{
errhandler("WriteFile", hwnd);
}
HBITMAP hBMP = GetBmpUnifie(bmpListBmp[nIdImg], m_BrosseFondWizard);
PBITMAPINFO pbi = CreateBitmapInfoStruct(this->m_hWnd, hBMP);
pbih = (PBITMAPINFOHEADER) pbi;
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER)
+ pbih->biClrUsed * sizeof (RGBQUAD),
(LPDWORD) &dwTmp, ( NULL)))
errhandler("WriteFile", hwnd);
dwTotal = cb = pbih->biSizeImage;
hp = lpBits;
if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL))
errhandler("WriteFile", hwnd);
}
if (!CloseHandle(hf))
errhandler("CloseHandle", hwnd);
GlobalFree((HGLOBAL)lpBits);
}
}
The problem is that only image file displayed. Normaly there's 3 !.
I know I missing something but I don't know where.
Can you help tell me where I'm wrong.
Many thanks again for your help.
Best Regards.
Mourad.