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

C / C++ / MFC

 
AnswerRe: How to decide if GPRS service is down in a C++ application (UDP socket) Pin
nahitan12-Sep-09 18:16
nahitan12-Sep-09 18:16 
GeneralRe: How to decide if GPRS service is down in a C++ application (UDP socket) Pin
Moak12-Sep-09 22:28
Moak12-Sep-09 22:28 
QuestionProblem with Tooltips for CTabCtrl [modified] Pin
Bob Blean11-Sep-09 14:43
Bob Blean11-Sep-09 14:43 
QuestionHow to use a list ctrl to select an item Pin
Chiman111-Sep-09 10:19
Chiman111-Sep-09 10:19 
AnswerRe: How to use a list ctrl to select an item Pin
David Crow11-Sep-09 14:25
David Crow11-Sep-09 14:25 
AnswerRe: How to use a list ctrl to select an item Pin
«_Superman_»11-Sep-09 20:22
professional«_Superman_»11-Sep-09 20:22 
QuestionTransparent Bitmaps Pin
kylur11-Sep-09 8:48
kylur11-Sep-09 8:48 
AnswerRe: Transparent Bitmaps Pin
Chris Losinger11-Sep-09 9:03
professionalChris Losinger11-Sep-09 9:03 
here's the classic MSDN version:
BOOL DrawTransparentBitmap(HDC hdc, 
		   HBITMAP hBitmap, 
		   __int32 xStart,
		   __int32 yStart, 
		   COLORREF cTransparentColor)
{

	BITMAP     bm;
	COLORREF   cColor;
	HBITMAP    bmAndBack, bmAndObject, bmAndMem, bmSave;			// lots of storage
	HBITMAP    bmBackOld, bmObjectOld, bmMemOld, bmSaveOld, bmTempOld;
	HDC        hdcMem, hdcBack, hdcObject, hdcTemp, hdcSave;		// lots of dc's
	POINT      ptSize;
	
	int iCaps = ::GetDeviceCaps(hdc, RASTERCAPS);
	if ((iCaps & RC_BITBLT) != RC_BITBLT)
	{
		return FALSE;
	}
	
	if ((iCaps & RC_BITMAP64) != RC_BITMAP64)
	{
		return FALSE;
	}
	
	hdcTemp = CreateCompatibleDC(hdc);
	
	if (hdcTemp==NULL) 
        {
		return FALSE;
	}
	
	bmTempOld = (HBITMAP)SelectObject(hdcTemp, hBitmap);   // Select the bitmap
	
	if (GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm) != sizeof(BITMAP))
   {
                DeleteDC(hdcTemp);
		return FALSE;
   }

	ptSize.x = bm.bmWidth;            // Get width of bitmap
	ptSize.y = bm.bmHeight;           // Get height of bitmap
	DPtoLP(hdcTemp, &ptSize, 1);      // Convert from device
	// to logical points
	
	// Create some DCs to hold temporary data.
	hdcBack   = CreateCompatibleDC(hdc);
	hdcObject = CreateCompatibleDC(hdc);
	hdcMem    = CreateCompatibleDC(hdc);
	hdcSave   = CreateCompatibleDC(hdc);
	
	// Create a bitmap for each DC. DCs are required for a number of
	// GDI functions.
	
	// Monochrome DC
	bmAndBack   = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
	
	// Monochrome DC
	bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
	
	bmAndMem    = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
	bmSave      = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
	
	// Each DC must select a bitmap object to store pixel data.
	// (HBITMAP) Casts added by CDL, 3/26/96
	bmBackOld   = (HBITMAP)SelectObject(hdcBack, bmAndBack);
	bmObjectOld = (HBITMAP)SelectObject(hdcObject, bmAndObject);
	bmMemOld    = (HBITMAP)SelectObject(hdcMem, bmAndMem);
	bmSaveOld   = (HBITMAP)SelectObject(hdcSave, bmSave);
	
	// Set proper mapping mode.
	SetMapMode(hdcTemp, GetMapMode(hdc));
	
	// Save the bitmap sent here, because it will be overwritten.
	BitBlt(hdcSave, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY);
	
	// Set the background color of the source DC to the color.
	// contained in the parts of the bitmap that should be transparent
	cColor = SetBkColor(hdcTemp, cTransparentColor);
	
	// Create the object mask for the bitmap by performing a BitBlt
	// from the source bitmap to a monochrome bitmap.
	BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,
		SRCCOPY);
	
	// Set the background color of the source DC back to the original
	// color.
	SetBkColor(hdcTemp, cColor);
	
	// Create the inverse of the object mask.
	BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, NOTSRCCOPY);
	
	// Copy the background of the main DC to the destination.
	BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdc, xStart, yStart, SRCCOPY);
	
	// Mask out the places where the bitmap will be placed.
	BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);
	
	// Mask out the transparent colored pixels on the bitmap.
	BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);
	
	// XOR the bitmap with the background on the destination DC.
	BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT);
	
	// Copy the destination to the screen.
	BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, 0, 0, SRCCOPY);
	
	// Place the original bitmap back into the bitmap sent here.
	BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcSave, 0, 0, SRCCOPY);
	
	// Delete the memory bitmaps.
	DeleteObject(SelectObject(hdcBack, bmBackOld));
	DeleteObject(SelectObject(hdcObject, bmObjectOld));
	DeleteObject(SelectObject(hdcMem, bmMemOld));
	DeleteObject(SelectObject(hdcSave, bmSaveOld));
        SelectObject(hdcTemp, bmTempOld);

	// Delete the memory DCs.
	DeleteDC(hdcMem);
	DeleteDC(hdcBack);
	DeleteDC(hdcObject);
	DeleteDC(hdcSave);
	DeleteDC(hdcTemp);

    return TRUE;
}



GeneralRe: Transparent Bitmaps Pin
kilt14-Sep-09 2:19
kilt14-Sep-09 2:19 
GeneralRe: Transparent Bitmaps Pin
kylur14-Sep-09 2:36
kylur14-Sep-09 2:36 
GeneralRe: Transparent Bitmaps Pin
Chris Losinger14-Sep-09 4:05
professionalChris Losinger14-Sep-09 4:05 
QuestionI need a library file or some program which is similar to bigint() class library in the C++. Pin
nowrocktheworld11-Sep-09 8:32
nowrocktheworld11-Sep-09 8:32 
AnswerRe: I need a library file or some program which is similar to bigint() class library in the C++. Pin
Saurabh.Garg11-Sep-09 22:03
Saurabh.Garg11-Sep-09 22:03 
Question[C++ Error] exception(15): E2141 Declaration syntax error Pin
gordon305611-Sep-09 6:25
gordon305611-Sep-09 6:25 
AnswerRe: [C++ Error] exception(15): E2141 Declaration syntax error Pin
UKM_Student11-Sep-09 6:29
UKM_Student11-Sep-09 6:29 
GeneralRe: [C++ Error] exception(15): E2141 Declaration syntax error Pin
gordon305611-Sep-09 7:52
gordon305611-Sep-09 7:52 
GeneralRe: [C++ Error] exception(15): E2141 Declaration syntax error Pin
UKM_Student11-Sep-09 7:53
UKM_Student11-Sep-09 7:53 
General[C++ Error] exception(15): E2141 Declaration syntax error Pin
gordon305611-Sep-09 8:04
gordon305611-Sep-09 8:04 
GeneralRe: [C++ Error] exception(15): E2141 Declaration syntax error Pin
Maximilien11-Sep-09 8:02
Maximilien11-Sep-09 8:02 
GeneralRe: [C++ Error] exception(15): E2141 Declaration syntax error Pin
Nemanja Trifunovic11-Sep-09 8:06
Nemanja Trifunovic11-Sep-09 8:06 
GeneralThanks to all concerned somehow I got my source labeled variable.cpp.c Pin
gordon305611-Sep-09 8:20
gordon305611-Sep-09 8:20 
GeneralRe: Thanks to all concerned somehow I got my source labeled variable.cpp.c Pin
Nemanja Trifunovic11-Sep-09 8:48
Nemanja Trifunovic11-Sep-09 8:48 
GeneralRe: [C++ Error] exception(15): E2141 Declaration syntax error Pin
UKM_Student11-Sep-09 8:11
UKM_Student11-Sep-09 8:11 
GeneralThanks UKM_Student I'm looking at code blocks right now Pin
gordon305611-Sep-09 8:37
gordon305611-Sep-09 8:37 
QuestionOdd bug in CMFCToolbarComboBoxButton class Pin
Santanu Lahiri11-Sep-09 5:17
Santanu Lahiri11-Sep-09 5:17 

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.