Click here to Skip to main content
15,917,320 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Convert *.dat to *.bmp Pin
toxcct27-Sep-05 22:44
toxcct27-Sep-05 22:44 
JokeRe: Convert *.dat to *.bmp Pin
Eytukan27-Sep-05 23:41
Eytukan27-Sep-05 23:41 
Questionhow to create dialog based app in win32 without using resource Pin
tamsel27-Sep-05 21:44
tamsel27-Sep-05 21:44 
AnswerRe: how to create dialog based app in win32 without using resource Pin
ThatsAlok27-Sep-05 23:15
ThatsAlok27-Sep-05 23:15 
AnswerRe: how to create dialog based app in win32 without using resource Pin
douglasjordan28-Sep-05 4:11
douglasjordan28-Sep-05 4:11 
GeneralRe: how to create dialog based app in win32 without using resource Pin
ThatsAlok28-Sep-05 20:55
ThatsAlok28-Sep-05 20:55 
QuestionDrawing with MFC on NT4 SP4 Pin
igardoo27-Sep-05 21:37
igardoo27-Sep-05 21:37 
AnswerRe: Drawing with MFC on NT4 SP4 Pin
igardoo28-Sep-05 1:08
igardoo28-Sep-05 1:08 
After a lot of testing I narrowed down the problem. The Problem is not the Loading of the Bitmap. It is the resizing. Drawing the bitmap in its original size works fine.

Here is what I do:

LoadImageFromFile( &lbmpGraphic, fileName );
// lbmpGraphic contains the loaded bitmap (HBITMAP)
// this can be drawn on Windows NT
/*++++++++++++++ Begin Resizeing ++++++++++++++*/
// initialiZE Bitmap pointer
tempDC = CDC::FromHandle( GetDC( lhWnd ));
lpbmObject = new CBitmap;
// CREATE compatible Memory Devicecontext for the target
pCdcDest = new CDC;
pCdcDest->CreateCompatibleDC( tempDC );

// create compatible Memory Devicecontext for the source
pCdcSource = new CDC;
pCdcSource->CreateCompatibleDC( tempDC );

// Create compatible bitmap for the target dc
lpbmObject->CreateCompatibleBitmap( tempDC, lrectTarget.Width(), lrectTarget.Height() );

// Initialize target dc and save old bitmap
lpbmpDestSave = pCdcDest->SelectObject( lpbmObject );

// get bitmap Info for dimensions
GetObject (lbmpGraphic, sizeof (BITMAP), &lbmpTempBitmap);

// Select Bitmap into source DC
lpbmpSourceSave = pCdcSource->SelectObject(CBitmap::FromHandle(lbmpGraphic));
// Set stretchmode
SetStretchBltMode( pCdcDest->operator HDC(), COLORONCOLOR );
// StretchBlt Picture in Dest DC
lnStretchResult = pCdcDest->StretchBlt(
0,
0,
lrectTarget.Width(),
lrectTarget.Height(),
pCdcSource,
0,
0,
lbmpTempBitmap.bmWidth,
lbmpTempBitmap.bmHeight,
SRCCOPY );
if ( !lnStretchResult )
{
test_msg(ERROR, "ERROR in StretchBlt!");
}

// Draw a black frame

pCdcDest->LineTo(lrectTarget.Width() - 1, 0);
pCdcDest->LineTo(lrectTarget.Width() - 1, lrectTarget.Height() - 1);
pCdcDest->LineTo(0, lrectTarget.Height() - 1);
pCdcDest->LineTo(0, 0);

// get bitmap from target dc

lpbmpRes = pCdcDest->SelectObject(lpbmObject);
// make a copy ( lpoutBitmap stores the result of the function )
*lpoutBitmap = (HBITMAP)CopyImage(lpbmpRes->operator HBITMAP(),
IMAGE_BITMAP,0,0, LR_COPYRETURNORG);

//Cleanup
pCdcSource->SelectObject( lpbmpSourceSave );
pCdcDest->SelectObject( lpbmpDestSave );

tempDC->DeleteDC();

DeleteObject( lbmpGraphic );

pCdcDest->DeleteDC();
delete pCdcDest;

pCdcSource->DeleteDC();
delete pCdcSource;

lpbmObject->DeleteObject();
delete lpbmObject;

lpbmpRes->DeleteObject();


Something in this code does not work on NT. Maybe I deleted to much or to less objects or in the wrong order?

Does anyone have a suggestion?
Please help. Cry | :((
GeneralRe: Drawing with MFC on NT4 SP4 Pin
igardoo28-Sep-05 1:49
igardoo28-Sep-05 1:49 
QuestionAcquireCredentialsHandle Pin
sunit527-Sep-05 20:48
sunit527-Sep-05 20:48 
QuestionNeed help with network connection names !!! Pin
Radu Sorin27-Sep-05 20:39
Radu Sorin27-Sep-05 20:39 
AnswerRe: Need help with network connection names !!! Pin
fat_boy28-Sep-05 2:03
fat_boy28-Sep-05 2:03 
AnswerRe: Need help with network connection names !!! Pin
David Crow28-Sep-05 5:12
David Crow28-Sep-05 5:12 
QuestionUnloading third party hooked DLL from a Remote process Pin
Abhishek Karnik27-Sep-05 19:31
Abhishek Karnik27-Sep-05 19:31 
Questionhow a parent window be notified of a child window's mouse move event Pin
followait27-Sep-05 16:05
followait27-Sep-05 16:05 
AnswerRe: how a parent window be notified of a child window's mouse move event Pin
ThatsAlok27-Sep-05 19:03
ThatsAlok27-Sep-05 19:03 
AnswerRe: how a parent window be notified of a child window's mouse move event Pin
douglasjordan28-Sep-05 11:23
douglasjordan28-Sep-05 11:23 
AnswerI post a msg, it's ok, thanks. Pin
followait28-Sep-05 15:12
followait28-Sep-05 15:12 
QuestionAdding header infront of the data Pin
Member 216100427-Sep-05 15:18
Member 216100427-Sep-05 15:18 
AnswerRe: Adding header infront of the data Pin
Marvin M.27-Sep-05 15:35
Marvin M.27-Sep-05 15:35 
GeneralRe: Adding header infront of the data Pin
Member 216100427-Sep-05 15:48
Member 216100427-Sep-05 15:48 
Questionvector: Container problem Pin
Marvin M.27-Sep-05 12:54
Marvin M.27-Sep-05 12:54 
AnswerRe: vector: Container problem Pin
dirtfly27-Sep-05 14:50
dirtfly27-Sep-05 14:50 
GeneralRe: vector: Container problem Pin
Marvin M.27-Sep-05 15:20
Marvin M.27-Sep-05 15:20 
GeneralRe: vector: Container problem Pin
dirtfly27-Sep-05 15:30
dirtfly27-Sep-05 15:30 

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.