Click here to Skip to main content
15,921,643 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDIBitmap Pin
daojinliu15-Oct-05 15:46
daojinliu15-Oct-05 15:46 
AnswerRe: DIBitmap Pin
Chris Losinger15-Oct-05 16:56
professionalChris Losinger15-Oct-05 16:56 
GeneralRe: DIBitmap Pin
daojinliu15-Oct-05 18:24
daojinliu15-Oct-05 18:24 
GeneralRe: DIBitmap Pin
Chris Losinger15-Oct-05 18:45
professionalChris Losinger15-Oct-05 18:45 
GeneralRe: DIBitmap Pin
PJ Arends15-Oct-05 20:54
professionalPJ Arends15-Oct-05 20:54 
GeneralRe: DIBitmap Pin
daojinliu16-Oct-05 0:40
daojinliu16-Oct-05 0:40 
GeneralRe: DIBitmap Pin
PJ Arends16-Oct-05 8:09
professionalPJ Arends16-Oct-05 8:09 
QuestionREQ : Question with message box. Pin
zerofire15-Oct-05 15:42
zerofire15-Oct-05 15:42 
AnswerRe: REQ : Question with message box. Pin
David Crow15-Oct-05 16:15
David Crow15-Oct-05 16:15 
AnswerRe: REQ : Question with message box. Pin
Jack Puppy15-Oct-05 16:19
Jack Puppy15-Oct-05 16:19 
GeneralRe: REQ : Question with message box. Pin
zerofire15-Oct-05 16:27
zerofire15-Oct-05 16:27 
AnswerRe: REQ : Question with message box. Pin
daojinliu16-Oct-05 0:52
daojinliu16-Oct-05 0:52 
QuestionHow to delete a class? Pin
kevincwong15-Oct-05 15:37
kevincwong15-Oct-05 15:37 
AnswerRe: How to delete a class? Pin
daojinliu15-Oct-05 15:56
daojinliu15-Oct-05 15:56 
GeneralRe: How to delete a class? Pin
kevincwong15-Oct-05 16:45
kevincwong15-Oct-05 16:45 
QuestionEnumerate (list) USB Webcams Pin
Howard Anderson15-Oct-05 15:27
Howard Anderson15-Oct-05 15:27 
AnswerRe: Enumerate (list) USB Webcams Pin
FlyingTinman19-Oct-05 16:09
FlyingTinman19-Oct-05 16:09 
GeneralRe: Enumerate (list) USB Webcams Pin
Howard Anderson10-Nov-05 4:31
Howard Anderson10-Nov-05 4:31 
QuestionMenu invokes dialog Pin
kevincwong15-Oct-05 12:52
kevincwong15-Oct-05 12:52 
AnswerRe: Menu invokes dialog Pin
Roger Allen15-Oct-05 13:46
Roger Allen15-Oct-05 13:46 
GeneralRe: Menu invokes dialog Pin
kevincwong15-Oct-05 14:00
kevincwong15-Oct-05 14:00 
GeneralRe: Menu invokes dialog Pin
kevincwong15-Oct-05 15:19
kevincwong15-Oct-05 15:19 
QuestionCBitmap Pin
fjlv200515-Oct-05 11:37
fjlv200515-Oct-05 11:37 
AnswerRe: CBitmap Pin
Prakash Nadar15-Oct-05 19:07
Prakash Nadar15-Oct-05 19:07 
GeneralRe: CBitmap Pin
fjlv200517-Oct-05 14:44
fjlv200517-Oct-05 14:44 
Hello Prakash,

I have declared CBitmap in this,

CMyBitmap mybitmap;
mybitmap.LoadBitmap(IDB_MYBMP);
mybitmap.DrawTransparent(GetDC(),20,50,RGB(255,0,255));

Sorry I was not clear enough in the first place. CMyBitmap is derrived from CBitmap, I have to subclass because i need to make the bitmap transparent. Please help me How I could bring this on top of other controls. Anyway here is the detail of DrawTransparentFunction.(Just research this detail from other articles but it didnt bring the bitmap on top. Its weakness is when there are other control because it is overlapped.)

void CMyBitmap::DrawTransparent(CDC *pDC, int x, int y, COLORREF clrTransparency)
{
BITMAP bm;
GetBitmap (&bm);
CPoint size (bm.bmWidth, bm.bmHeight);
pDC->DPtoLP (&size);

CPoint org (0, 0);
pDC->DPtoLP (&org);
//
// Create a memory DC (dcImage) and select the bitmap into it.
//
CDC dcImage;
dcImage.CreateCompatibleDC (pDC);
CBitmap* pOldBitmapImage = dcImage.SelectObject (this);
//dcImage.SetMapMode (pDC->GetMapMode ());


//
// Create a second memory DC (dcAnd) and in it create an AND mask.
//
CDC dcAnd;
dcAnd.CreateCompatibleDC (pDC);
//dcAnd.SetMapMode (pDC->GetMapMode ());

CBitmap bitmapAnd;
bitmapAnd.CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL);
CBitmap* pOldBitmapAnd = dcAnd.SelectObject (&bitmapAnd);

dcImage.SetBkColor (clrTransparency);
dcAnd.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y, SRCCOPY);

//
// Create a third memory DC (dcXor) and in it create an XOR mask.
//
CDC dcXor;
dcXor.CreateCompatibleDC (pDC);
//dcXor.SetMapMode (pDC->GetMapMode ());

CBitmap bitmapXor;
bitmapXor.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight);
CBitmap* pOldBitmapXor = dcXor.SelectObject (&bitmapXor);
dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y, SRCCOPY);
dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y, 0x220326);

//
// Copy the pixels in the destination rectangle to a temporary
// memory DC (dcTemp).
//
CDC dcTemp;
dcTemp.CreateCompatibleDC (pDC);
//dcTemp.SetMapMode (pDC->GetMapMode ());

CBitmap bitmapTemp;
bitmapTemp.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight);
CBitmap* pOldBitmapTemp = dcTemp.SelectObject (&bitmapTemp);

dcTemp.BitBlt (org.x, org.y, size.x, size.y, pDC, x, y, SRCCOPY);

//
// Generate the final image by applying the AND and XOR masks to
// the image in the temporary memory DC.
//
dcTemp.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y, SRCAND);
dcTemp.BitBlt (org.x, org.y, size.x, size.y, &dcXor, org.x, org.y, SRCINVERT);

//
// Blit the resulting image to the screen.
//
pDC->BitBlt (x, y, size.x, size.y, &dcTemp, org.x, org.y, SRCCOPY);

//
// Restore the default bitmaps.
//
dcTemp.SelectObject (pOldBitmapTemp);
dcXor.SelectObject (pOldBitmapXor);
dcAnd.SelectObject (pOldBitmapAnd);
dcImage.SelectObject (pOldBitmapImage);
}

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.