Click here to Skip to main content
16,010,876 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSocket via firewall Pin
Shamoon27-Aug-02 22:22
Shamoon27-Aug-02 22:22 
GeneralFile transfer (GET) via HTTPS Pin
Jonas Larsson27-Aug-02 21:05
Jonas Larsson27-Aug-02 21:05 
GeneralRe: File transfer (GET) via HTTPS Pin
Andreas Saurwein27-Aug-02 23:36
Andreas Saurwein27-Aug-02 23:36 
GeneralRe: File transfer (GET) via HTTPS Pin
Jonas Larsson28-Aug-02 0:35
Jonas Larsson28-Aug-02 0:35 
GeneralRe: File transfer (GET) via HTTPS Pin
Andreas Saurwein28-Aug-02 1:11
Andreas Saurwein28-Aug-02 1:11 
GeneralRe: File transfer (GET) via HTTPS Pin
Jonas Larsson28-Aug-02 1:24
Jonas Larsson28-Aug-02 1:24 
Generaltransp. blit over background image Pin
TimWallace27-Aug-02 19:25
TimWallace27-Aug-02 19:25 
GeneralRe: transp. blit over background image Pin
Ernest Laurentin27-Aug-02 19:54
Ernest Laurentin27-Aug-02 19:54 
This is the most known method unless you want to use TransparentBlt function. There is not much to say, other than the bitmap 'hBitmap' must not be already selected in another dc (only one dc can select a bitmap at a time!)
void DrawTransparent(HDC hDC, int x, int y, int nWidth, int nHeight, HBITMAP hBitmap, COLORREF crColour)
{
	_ASSERTE(hDC != NULL);
	_ASSERTE(hBitmap != NULL);

	COLORREF crOldBack = SetBkColor(hDC, RGB(255,255,255));
	COLORREF crOldText = SetTextColor(hDC, RGB(0,0,0));

	HDC dcImage, dcMask, dcMem;
	// Create two memory dcs for the image and the mask
	dcImage = CreateCompatibleDC(hDC);
	dcMask  = CreateCompatibleDC(hDC);
	dcMem   = CreateCompatibleDC(hDC);

	HBITMAP hOldMemBitmap = (HBITMAP) SelectObject(dcMem, hBitmap);

	// Create bitmap copy
	HBITMAP hBitmapImage = CreateCompatibleBitmap(hDC, nWidth, nHeight);

	// Select the image into the appropriate dc
	HBITMAP hOldBitmapImage = (HBITMAP) SelectObject(dcImage, hBitmapImage);

	HBITMAP bitmapMask = CreateBitmap(nWidth, nHeight, 1, 1, NULL);

	// Select the mask bitmap into the appropriate dc
	HBITMAP hOldBitmapMask = (HBITMAP) SelectObject(dcMask, bitmapMask);

	// Build mask based on transparent colour
	BitBlt(dcImage, 0, 0, nWidth, nHeight, dcMem, 0, 0, SRCCOPY);

	SetBkColor(dcImage, crColour);
	BitBlt(dcMask, 0, 0, nWidth, nHeight, dcImage, 0, 0, SRCCOPY);

	// Do the work - True Mask method - cool if not actual display
	BitBlt(hDC, x, y, nWidth, nHeight, dcImage, 0, 0, SRCINVERT);
	BitBlt(hDC, x, y, nWidth, nHeight, dcMask,  0, 0, SRCAND);
	BitBlt(hDC, x, y, nWidth, nHeight, dcImage, 0, 0, SRCINVERT);

	// Restore settings
	SelectObject(dcImage, hOldBitmapImage);
	SelectObject(dcMask,  hOldBitmapMask);
	SelectObject(dcMem, hOldMemBitmap);

	DeleteObject(hBitmapImage);
	DeleteObject(bitmapMask);

	DeleteDC( dcMem );
	DeleteDC( dcMask );
	DeleteDC( dcImage );

	SetBkColor(hDC, crOldBack);
	SetTextColor(hDC, crOldText);
}


ÿVOTD: 8 "Love never fails. But where there are prophecies, they will cease;
where there are tongues, they will be stilled; where there is knowledge, it will pass away."
- 1 Cor 13:8 (NIV)


GeneralRe: transp. blit over background image Pin
TimWallace27-Aug-02 20:10
TimWallace27-Aug-02 20:10 
GeneralOS incompatibility problem Pin
G.S.Gupta27-Aug-02 19:17
G.S.Gupta27-Aug-02 19:17 
GeneralRe: OS incompatibility problem Pin
Philip Patrick27-Aug-02 21:19
professionalPhilip Patrick27-Aug-02 21:19 
GeneralRe: OS incompatibility problem Pin
G.S.Gupta29-Aug-02 1:01
G.S.Gupta29-Aug-02 1:01 
GeneralRe: OS incompatibility problem Pin
Philip Patrick29-Aug-02 1:39
professionalPhilip Patrick29-Aug-02 1:39 
GeneralRe: OS incompatibility problem Pin
G.S.Gupta1-Sep-02 19:27
G.S.Gupta1-Sep-02 19:27 
GeneralRe: OS incompatibility problem Pin
Philip Patrick1-Sep-02 20:47
professionalPhilip Patrick1-Sep-02 20:47 
GeneralHELP:Display driver communicate with usermode app. Pin
jerry_hp27-Aug-02 18:46
jerry_hp27-Aug-02 18:46 
GeneralRe: HELP:Display driver communicate with usermode app. Pin
Andreas Saurwein27-Aug-02 23:42
Andreas Saurwein27-Aug-02 23:42 
GeneralRe: HELP:Display driver communicate with usermode app. Pin
jerry_hp28-Aug-02 15:01
jerry_hp28-Aug-02 15:01 
GeneralStrange memory allocation Pin
boon kian27-Aug-02 18:32
boon kian27-Aug-02 18:32 
GeneralRe: Strange memory allocation Pin
Chris Losinger27-Aug-02 18:34
professionalChris Losinger27-Aug-02 18:34 
GeneralRe: Strange memory allocation Pin
boon kian28-Aug-02 7:09
boon kian28-Aug-02 7:09 
GeneralRe: Strange memory allocation Pin
Anonymous27-Aug-02 18:45
Anonymous27-Aug-02 18:45 
GeneralRe: Strange memory allocation Pin
Todd Smith27-Aug-02 20:17
Todd Smith27-Aug-02 20:17 
GeneralRe: Strange memory allocation Pin
markkuk27-Aug-02 21:22
markkuk27-Aug-02 21:22 
GeneralRe: Strange memory allocation Pin
boon kian28-Aug-02 18:52
boon kian28-Aug-02 18:52 

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.