2012-03-15 74 views
1

我的代碼如下,但背景也不透明..我該怎麼辦?如何通過ActiveX顯示swf並設置透明背景?

QAxWidget *flash = new QAxWidget(0,0);  
flash->resize(200,200); 
flash->setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}")); 
flash->dynamicCall("LoadMovie(long,string)",0,"D:/test.swf"); 
flash->dynamicCall("WMode", "transparent"); 
flash->show(); 

enter image description here

順便說,,在Qt中,有沒有另一種方式來顯示SWF?謝謝....

回答

0

添加

flash->setAutoFillBackground(true) 

如果影片具有透明背景,你會看到小部件的原始backgorund

0

試試這個代碼

QAxWidget *flash = new QAxWidget(0, 0); 
flash->resize(500, 400); 

HWND hWnd = (HWND)flash->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_LAYERED|WS_EX_TOPMOST|WS_EX_TRANSPARENT); 
typedef int (WINAPI* LPFUNC)(HWND, COLORREF , BYTE, DWORD); 
HINSTANCE hins = ::LoadLibraryW(L"User32.DLL"); 
if(!hins) 
    return ; 
LPFUNC func2 = (LPFUNC)GetProcAddress(hins,"SetLayeredWindowAttributes"); 
if(!func2) 
    return ; 
COLORREF clrMask = RGB(255,255,255);  
func2(hWnd, clrMask, 0, LWA_COLORKEY);   
FreeLibrary(hins); 

flash->setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}")); 
flash->dynamicCall("LoadMovie(long,string)", 0, "d:/9023.swf"); 
flash->dynamicCall("WMode", "transparent"); 
flash->show(); 

顯示的ActiveX透明背景。