Unsolved How to use QAxWidget to realize a transparent background child UI on windows platform?
-
Hi, all !
My QAxWidget has a parent of QWidget type, the parent UI has a background, i want to use QAxWidget to realize a transparent background child UI .
Here is my code:
- ##>>
QAxWidget *pFlash = new QAxWidget(parent);
pFlash->resize(1280, 768);
pFlash->setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
pFlash->setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}"));
QString strFlashPath = QDir::toNativeSeparators(QApplication::applicationDirPath() + "/1012.swf");
pFlash->dynamicCall("LoadMovie(long, string)", 0, strFlashPath);
pFlash->dynamicCall("WMode", "Transparent");
pFlash->dynamicCall("TotalFrames" ).toString();
pFlash->show();
It seem that "WMode" doesn't work, so I use WinAPI:
*##
pFlash->setAttribute(Qt::WA_TranslucentBackground);
setTransparentBackground(m_pFlash, RGB(255, 255, 255));void setTransparentBackground(QWidget *pWidget, COLORREF crKey)
{
HWND hWnd = (HWND)pWidget->winId();//LONG lStyle = ::GetWindowLong(hWnd, GWL_STYLE); //lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU); //::SetWindowLong(hWnd, GWL_STYLE, lStyle); LONG lExStyle = ::GetWindowLong(hWnd, GWL_EXSTYLE); ::SetWindowLong(hWnd, GWL_EXSTYLE, lExStyle | WS_EX_TRANSPARENT/* | WS_EX_LAYERED | WS_EX_TOPMOST*/); typedef int (WINAPI* LPFUNC)(HWND, COLORREF , BYTE, DWORD); HINSTANCE hInstance = ::LoadLibraryW(L"User32.DLL"); if(hInstance) { LPFUNC func2 = (LPFUNC)GetProcAddress(hInstance, "SetLayeredWindowAttributes"); if(func2) { func2(hWnd, crKey, 0, LWA_COLORKEY); } FreeLibrary(hInstance); }
}
But it still doesn't work. The flash still have a black background !! what can i do? Does someone know?TKS!
- ##>>