Click here to Skip to main content
15,923,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How do you Find out(copy filenames) that is in a directory WITHOUT using the CFileDialog in MFC VS2008 C++ Pin
Larry Mills Sr18-May-08 9:34
Larry Mills Sr18-May-08 9:34 
GeneralRe: How do you Find out(copy filenames) that is in a directory WITHOUT using the CFileDialog in MFC VS2008 C++ Pin
Michael Schubert18-May-08 12:20
Michael Schubert18-May-08 12:20 
GeneralRe: How do you Find out(copy filenames) that is in a directory WITHOUT using the CFileDialog in MFC VS2008 C++ Pin
Nelek18-May-08 12:39
protectorNelek18-May-08 12:39 
QuestionRe: How do you Find out(copy filenames) that is in a directory WITHOUT using the CFileDialog in MFC VS2008 C++ Pin
David Crow19-May-08 4:41
David Crow19-May-08 4:41 
AnswerRe: How do you Find out(copy filenames) that is in a directory WITHOUT using the CFileDialog in MFC VS2008 C++ Pin
Larry Mills Sr19-May-08 16:43
Larry Mills Sr19-May-08 16:43 
QuestionDrawing a bitmap on DC created by BYTE* array Pin
TalSt18-May-08 3:29
TalSt18-May-08 3:29 
AnswerRe: Drawing a bitmap on DC created by BYTE* array [modified] Pin
Baltoro18-May-08 12:20
Baltoro18-May-08 12:20 
AnswerRe: Drawing a bitmap on DC created by BYTE* array Pin
Dan18-May-08 13:31
Dan18-May-08 13:31 
Mostly your order is wrong, you do not need to allocate the byte array, CreateDIBSection does that for you, the pbtImageArray pointer you are passing in is the output, not the input

So more along the lines of
#define BPP 32
int nBitPP = BPP / 8;
int nImageWidth = nWidth;
int nImageHeight = nHeight;
int nImageSize = nImageWidth * nImageHeight * nBitPP;

// Populate bitmapinfo header
BITMAPINFO bitmapInfo; // Bitmap info
bitmapInfo.bmiHeader.biSize = nBitmapInfoSize;
bitmapInfo.bmiHeader.biWidth = nImageWidth; 
bitmapInfo.bmiHeader.biHeight = nImageHeight;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biBitCount = BPP;
bitmapInfo.bmiHeader.biSizeImage = nImageSize;
bitmapInfo.bmiHeader.biCompression = BI_RGB;

// Create dib
BYTE* pbtImageArray = NULL;
HBITMAP hbmp = CreateDIBSection( pCDC->GetSafeHdc(), &bitmapInfo, DIB_RGB_COLORS, (void**)&pbtImageArray, NULL, 0);

//Then fill in the data.
for (int i = 0; i < nImageSize - nBitPP; i+=nBitPP)
{
     pbtImageArray[i] = 0x0000;
     pbtImageArray[i+1] = 0x0000;
     pbtImageArray[i+2] = 255;
     pbtImageArray[i+3] = 0x0000;
}
HDC hBitmapDC = CreateCompatibleDC(pCDC->GetSafeHdc() );

HBITMAP hOldBitmap = (HBITMAP)SelectObject(hBitmapDC, hbmp);

StretchBlt( pCDC->GetSafeHdc(), 
            nWindowX, nWindowY, 
            nWindowWidth, nWindowHeight, // Destination 
            hBitmapDC , 
            nRegionX, nRegionY, 
            nRegionWidth, nRegionHeight, // Source
            SRCCOPY);

SelectObject(m_hBitmapDC, hOldBitmap);

AnswerRe: Drawing a bitmap on DC created by BYTE* array Pin
TalSt18-May-08 19:27
TalSt18-May-08 19:27 
Questionfile accessing problem Pin
Chandrasekharan P18-May-08 3:26
Chandrasekharan P18-May-08 3:26 
AnswerRe: file accessing problem Pin
Nelek18-May-08 7:15
protectorNelek18-May-08 7:15 
AnswerRe: file accessing problem Pin
chandu00418-May-08 19:53
chandu00418-May-08 19:53 
QuestionReading Non-Ole File Property Pin
tprakash18-May-08 3:00
tprakash18-May-08 3:00 
AnswerRe: Reading Non-Ole File Property Pin
thonti29-May-08 23:41
thonti29-May-08 23:41 
AnswerRe: Reading Non-Ole File Property Pin
thonti9-Jun-08 3:50
thonti9-Jun-08 3:50 
Questioninvalid number of parameters in ActiveX Pin
samira forooghi18-May-08 0:37
samira forooghi18-May-08 0:37 
AnswerRe: invalid number of parameters in ActiveX Pin
Nelek18-May-08 0:39
protectorNelek18-May-08 0:39 
GeneralRe: invalid number of parameters in ActiveX Pin
samira forooghi19-May-08 1:55
samira forooghi19-May-08 1:55 
AnswerRe: invalid number of parameters in ActiveX Pin
prasad_som18-May-08 1:04
prasad_som18-May-08 1:04 
QuestionGetControlUnknown Pin
subramanyeswari18-May-08 0:08
subramanyeswari18-May-08 0:08 
AnswerRe: GetControlUnknown Pin
JudyL_MD18-May-08 12:39
JudyL_MD18-May-08 12:39 
QuestionDraw on desktop Pin
capint17-May-08 23:06
capint17-May-08 23:06 
AnswerRe: Draw on desktop [modified] Pin
Nelek17-May-08 23:47
protectorNelek17-May-08 23:47 
GeneralRe: Draw on desktop Pin
capint18-May-08 2:07
capint18-May-08 2:07 
GeneralRe: Draw on desktop Pin
Nelek18-May-08 7:04
protectorNelek18-May-08 7:04 

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.