Click here to Skip to main content
15,891,513 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralEnable/Disable Frame Buttons :: MFC Pin
valikac22-Jun-02 21:30
valikac22-Jun-02 21:30 
GeneralRe: Enable/Disable Frame Buttons :: MFC Pin
Nish Nishant22-Jun-02 22:12
sitebuilderNish Nishant22-Jun-02 22:12 
GeneralRe: Enable/Disable Frame Buttons :: MFC Pin
valikac23-Jun-02 6:39
valikac23-Jun-02 6:39 
GeneralRe: Enable/Disable Frame Buttons :: MFC Pin
Sonu Kapoor23-Jun-02 7:30
Sonu Kapoor23-Jun-02 7:30 
GeneralRe: Enable/Disable Frame Buttons :: MFC Pin
valikac23-Jun-02 7:38
valikac23-Jun-02 7:38 
GeneralRe: Enable/Disable Frame Buttons :: MFC Pin
Nish Nishant23-Jun-02 15:25
sitebuilderNish Nishant23-Jun-02 15:25 
GeneralRe: Enable/Disable Frame Buttons :: MFC Pin
valikac23-Jun-02 16:16
valikac23-Jun-02 16:16 
GeneralProblem with GetDIBits under XP/NT Pin
yarp22-Jun-02 21:00
yarp22-Jun-02 21:00 
I've been using the ::GetDIBits function to convert from HBitmap to DIB in a thumbnailer I'm writing. The idea is to use GetDIBits to convert from any bitmap format to a 32 bpp DIB. I then render the DIB to the screen with ::StrechDiBits.
The code below works fine with W98/WMe but under W2k/XP it sometimes - very often - render transparent bitmaps. I wonder if this a bug from me or a bug from the driver of my video card (ATI Radeon DDR 64), but I got the same problem on another XP machine.
Can anybody tell me if there's something wrong in the code below ? Personnaly I give up, I tried so many things I've no more idea.
1/ We get a HBitmap from Disk
2/ Prepare for our final DIB header (pBMI)
3/ Get bitmaps bits (GetDiBits)
4/ Save the bits in a buffer from our Image class (m_pBits)

void __fastcall CP3dOBmp::CreateFromHBitmap(HBITMAP hBitmap, int Width, int Height)
{
HANDLE hDib;
BITMAPINFO* pBMI;
HDC hDC = ::GetDC(NULL);

// Get bitmap format
//::GetDIBits(hDC, hBitmap, 0, 0, NULL, pBMI, DIB_RGB_COLORS);

Create(Width, Height, 32);

int nMem = sizeof(BITMAPINFOHEADER) +
(((((Width * 32) + 31) & ~31) >> 3) * Height);
hDib = GlobalAlloc(GHND, nMem);
if (!hDib) return;

pBMI = (BITMAPINFO *)GlobalLock(hDib);
BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER *)pBMI;
pBIH->biSize = sizeof(BITMAPINFOHEADER);
pBIH->biWidth = Width;
pBIH->biHeight = Height;
pBIH->biPlanes = 1;
pBIH->biBitCount = 32;
pBIH->biCompression = BI_RGB;
pBIH->biSizeImage = ((((Width * 32) + 31) & ~31) >> 3) * Height;
pBIH->biXPelsPerMeter = 0;
pBIH->biYPelsPerMeter = 0;
pBIH->biClrUsed = 0;
pBIH->biClrImportant = 0;

// Get hBitmap data
if (::GetDIBits(hDC, hBitmap, 0, Height,
(LPBYTE)pBMI->bmiColors, // Pointer to the bits
pBMI,
DIB_RGB_COLORS)) {
memcpy(m_pBits, (LPBYTE)pBMI->bmiColors, (32/8)*Width*Height);
}

GlobalUnlock(hDib);
GlobalFree(hDib);

::ReleaseDC(NULL, hDC);
}

The GetDiBits function obviously returns a blank buffer as I don't initialize the m_pBits one and I get a transaprent bitmap.
Good luck Wink | ;) )

Yarp
GeneralRe: Problem with GetDIBits under XP/NT Pin
Joel Lucsy23-Jun-02 16:26
Joel Lucsy23-Jun-02 16:26 
GeneralRe: Problem with GetDIBits under XP/NT Pin
yarp23-Jun-02 18:59
yarp23-Jun-02 18:59 
GeneralRe: Problem with GetDIBits under XP/NT Pin
yarp24-Jun-02 8:03
yarp24-Jun-02 8:03 
GeneralRe: Problem with GetDIBits under XP/NT Pin
Mike Nordell23-Jun-02 17:22
Mike Nordell23-Jun-02 17:22 
GeneralRe: Problem with GetDIBits under XP/NT Pin
yarp23-Jun-02 18:56
yarp23-Jun-02 18:56 
QuestionHow to remove the "Help" button on property sheet? Pin
Abin22-Jun-02 16:39
Abin22-Jun-02 16:39 
AnswerRe: How to remove the "Help" button on property sheet? Pin
Michael Dunn22-Jun-02 16:58
sitebuilderMichael Dunn22-Jun-02 16:58 
GeneralRe: How to remove the "Help" button on property sheet? Pin
Abin22-Jun-02 17:12
Abin22-Jun-02 17:12 
GeneralGetting text from MFC status-bar (subclassed msctls_statusbar32) Pin
Vitaly Belman22-Jun-02 14:31
Vitaly Belman22-Jun-02 14:31 
GeneralQuestion about MS Script Control Pin
22-Jun-02 14:17
suss22-Jun-02 14:17 
GeneralTerminal Services Client API Pin
StefanM22-Jun-02 14:06
StefanM22-Jun-02 14:06 
GeneralReBar toolbar chevron drop-down menu no icon Pin
Hiusing22-Jun-02 10:11
Hiusing22-Jun-02 10:11 
General_beginthread Pin
22-Jun-02 9:45
suss22-Jun-02 9:45 
GeneralRe: _beginthread Pin
Michael Dunn22-Jun-02 9:55
sitebuilderMichael Dunn22-Jun-02 9:55 
GeneralRe: _beginthread Pin
22-Jun-02 9:56
suss22-Jun-02 9:56 
GeneralShell Extension problem Pin
Hiusing22-Jun-02 9:03
Hiusing22-Jun-02 9:03 
GeneralRe: Shell Extension problem Pin
Michael Dunn22-Jun-02 9:39
sitebuilderMichael Dunn22-Jun-02 9:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.