Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / Transparent Window Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
roberts

March 13, 2005, 04:20 AM

Hi,
I'm activating Flash Player from C++ to draw Flash movies on the
screen. When I'm trying to draw the Flash movie in transparent window I
encounter the following problem:
- In 32bit it works fine.
- In 16Bit (High Color) , and 256 Color it doesn't work as it was
expected.

Please see below my code that handle this issue:

void CFlashWindow::HandleWindowlessPaint()
{
BLENDFUNCTION blend;
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.SourceConstantAlpha = 255;
blend.AlphaFormat = AC_SRC_ALPHA;

// window size
RECT r;
GetClientRect(m_hwnd, &r);
SIZE NewWinSize = {r.right-r.left, r.bottom-r.top};

HDC hdc = GetDC(0);
HDC hdcOff = CreateCompatibleDC(hdc);

BITMAPINFOHEADER bmih;
VOID * pBits;

ZeroMemory(&bmih, sizeof(bmih));
bmih.biSize = sizeof (BITMAPINFOHEADER) ;
bmih.biWidth = NewWinSize.cx;
bmih.biHeight = NewWinSize.cy;
bmih.biPlanes = 1;
bmih.biBitCount = 32;//8; //32;
bmih.biCompression = BI_RGB;
HBITMAP hbm = CreateDIBSection (NULL, (BITMAPINFO *) &bmih, 0,
&pBits, NULL, 0) ;

HGDIOBJ tempObj = SelectObject(hdcOff, hbm);

Draw(hdcOff);

// New window pos
POINT NewWinPos = {0,0};
ClientToScreen(m_hwnd, &NewWinPos);

// New layer pos
POINT LayerPos = {0,0};

if (UpdateLayeredWindow( m_hwnd, hdc, &NewWinPos, &NewWinSize, hdcOff,
&LayerPos, RGB(0,0,0), &blend, ULW_ALPHA) == 0) {
LPVOID lpMsgBuf;
int gle = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
gle,
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL );

char* t = (char*)lpMsgBuf;
}

SelectObject(hdcOff, tempObj);
DeleteObject(hbm);
DeleteDC(hdcOff);
ReleaseDC(0, hdc);

}

Can you please help me fixing this problem. I'm not a GDI expert, so if
you can fix the code it will be helpfully.

Thanks,
Robert

 
toaster

March 13, 2005, 05:58 AM

Never had any good results with 256, but then, I tried it once and thought, hell, if they're still running with 256 colours, this machine aint for what I want it to be for.

I've never had any difficulty switching between 16 and 32, and at a cursory glance can't see much of a difference between your code and mine.

I do use NULL as the second parameter of UpdateLayeredWindow though... maybe give that a shot.

 
roberts

March 13, 2005, 07:11 AM

Thanks for the reply.
I've tried to use NULL, but still encounter the same problem.

Any other suggestion??

Thanks,
Robert

 
This thread contains 3 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.