遇到一个棘手的问题,
在做一个和ACDSee里的Slide Show相似的软件,通过options里的选项图像的背景色可以自由设定,我想在全屏放映时把背景色设为透明,程序怎么实现呢? 

解决方案 »

  1.   

    http://www.ccidnet.com/tech/guide/2000/01/19/58_276.html
    http://www.zjonline.com.cn/gb/node2/node195/node56935/node56938/userobject7ai24982.html
      

  2.   

    最简单是用SetLayeredWindowAttributes,背景最好白色
    不过这样图像部分也透明了
    #ifndef WS_EX_LAYERED
    #define WS_EX_LAYERED           0x00080000
    #define LWA_COLORKEY            0x00000001
    #define LWA_ALPHA               0x00000002
    #endif // ndef WS_EX_LAYERED
    // Preparation for the function we want to import from USER32.DLL
    typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
    BOOL Transparent(HWND hWnd, BYTE byAlpha = 150)
    {
    lpfnSetLayeredWindowAttributes pSetLayeredWindowAttributes;
    // Here we import the function from USER32.DLL
    HMODULE hUser32 = GetModuleHandle("USER32.DLL");
    if(hUser32 == NULL)
    return FALSE; pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32, "SetLayeredWindowAttributes");
    // If the import did not succeed, make sure your app can handle it!
    if(pSetLayeredWindowAttributes == NULL)
    return FALSE; //Fail!!! // Check the current state of the dialog, and then add the WS_EX_LAYERED attribute
    SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
    pSetLayeredWindowAttributes(hWnd, 0, byAlpha, LWA_ALPHA);
    return TRUE;
    }
      

  3.   

    这样显然不行,图片部位都透明了;将窗口的区域设置成图片大小可以吗,用setwindowrgn?