Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use QAxWidget to realize a transparent background child UI on windows platform?

How to use QAxWidget to realize a transparent background child UI on windows platform?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 524 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • vilasV Offline
    vilasV Offline
    vilas
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved