Click here to Skip to main content
15,896,154 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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);
}
GeneralRe: CBitmap Pin
Prakash Nadar17-Oct-05 16:30
Prakash Nadar17-Oct-05 16:30 
QuestionTransparent CBitmapButton Pin
fjlv200515-Oct-05 7:27
fjlv200515-Oct-05 7:27 
Questiondbt.h Pin
karmendra_js15-Oct-05 5:33
karmendra_js15-Oct-05 5:33 
AnswerRe: dbt.h Pin
Prakash Nadar15-Oct-05 6:29
Prakash Nadar15-Oct-05 6:29 
QuestionDisable linker warnings Pin
leppie15-Oct-05 5:31
leppie15-Oct-05 5:31 
AnswerRe: Disable linker warnings Pin
Prakash Nadar15-Oct-05 19:13
Prakash Nadar15-Oct-05 19:13 
AnswerRe: Disable linker warnings Pin
ThatsAlok16-Oct-05 18:46
ThatsAlok16-Oct-05 18:46 
QuestionRe: Disable linker warnings Pin
leppie17-Oct-05 1:16
leppie17-Oct-05 1:16 
QuestionExiting an application Pin
karmendra_js15-Oct-05 2:51
karmendra_js15-Oct-05 2:51 
AnswerRe: Exiting an application Pin
sunit515-Oct-05 3:23
sunit515-Oct-05 3:23 
GeneralRe: Exiting an application Pin
sunit515-Oct-05 3:26
sunit515-Oct-05 3:26 
AnswerRe: Exiting an application Pin
ThatsAlok15-Oct-05 4:49
ThatsAlok15-Oct-05 4:49 
QuestionUsing CByteArray storing Image data into Database Pin
snprani15-Oct-05 2:37
snprani15-Oct-05 2:37 
QuestionWindows Startup Pin
extus15-Oct-05 1:00
extus15-Oct-05 1:00 
AnswerRe: Windows Startup Pin
ddmcr15-Oct-05 1:24
ddmcr15-Oct-05 1:24 
AnswerRe: Windows Startup Pin
Fired Fish15-Oct-05 1:29
Fired Fish15-Oct-05 1:29 
AnswerRe: Windows Startup Pin
ThatsAlok15-Oct-05 4:48
ThatsAlok15-Oct-05 4:48 

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.