SetLayeredWindowAttributes
The SetLayeredWindowAttributes function sets the opacity and transparency color key of a layered window.BOOL SetLayeredWindowAttributes(
  HWND hwnd,           // handle to the layered window
  COLORREF crKey,      // specifies the color key
  BYTE bAlpha,         // value for the blend function
  DWORD dwFlags        // action
);
Parameters
hwnd 
[in] Handle to the layered window. A layered window is created by specifying WS_EX_LAYERED when creating the window with the CreateWindowEx function or by setting WS_EX_LAYERED via SetWindowLong after the window has been created. 
crKey 
[in] Pointer to a COLORREF value that specifies the transparency color key to be used when composing the layered window. All pixels painted by the window in this color will be transparent. To generate a COLORREF, use the RGB macro. 
bAlpha 
[in] Alpha value used to describe the opacity of the layered window. Similar to the SourceConstantAlpha member of the BLENDFUNCTION structure. When bAlpha is 0, the window is completely transparent. When bAlpha is 255, the window is opaque. 
dwFlags 
[in] Specifies an action to take. This parameter can be one or more of the following values. Value Meaning 
LWA_COLORKEY Use crKey as the transparency color.  
LWA_ALPHA Use bAlpha to determine the opacity of the layered window.. 
Return Values
If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError. Res
Note that once SetLayeredWindowAttributes has been called for a layered window, subsequent UpdateLayeredWindow calls will fail until the layering style bit is cleared and set again.For more information, see Layered Windows.

解决方案 »

  1.   

    老大,SetLayeredWindowAttributes好象在2000下才能使,有没有98/ME下的办法?
      

  2.   


        谁有办法在DOS中实现类似金山词霸取词窗的半透明的窗口?与其多灌水,
    不如多干点实事。
      

  3.   

    这是带有mmx cpu的新特性,用汇编写吧!
      

  4.   

    这与cpu无关,而跟操作系统有关。
    win2000才真正支持半透明效果。一个半透明的窗体,能隐约看见它下面窗体的内容。下面窗体内容有改变,也能直接看见。这是操作系统实现的。以前windows中的一些半透明是不完善的。半透明是截获了下面窗体的图像然后由前面的窗体自己合成半透明效果显示。如果下面被盖住的窗体内容有变化,那不会马上反应出来。
      

  5.   

    兄弟不需要看到窗口下面的变化,只要能实现类似金山糍粑的效果就好
    兄弟并不精于VC此道,只是希望能学到些知识才贸然提问(估计很多人也是为了学习才来的吧),故望各位高人能不惜赐教
    先谢过了
    另:
    分数不是问题。8-D
      

  6.   

      基本步骤是:
      先获得窗口RECT。再获得桌面DC对应的兼容BITMAP,然后处理窗口DC的BITMAP与桌面DC的BITMAP,通过图象处理的方法实现。很麻烦,何必呢
      

  7.   

    如果你用AutoAsm()老兄说的方法的话,我这里倒是有从DC取得位图,以及回显的程序。还有详细的细节讲述。
    http://wannaplay.51.net/interfac.html
      

  8.   

    我觉得可以用象在vc中加Splash类似的方法实现,要金山词霸取词窗的半透明的窗口可以把BitBlt的最后的一个参数设成SRCAND就OK了。
      

  9.   

    http://www.csdn.net/expert/topic/106/106294.shtm
      

  10.   

    void CChessBoard::FillMarkedChess(CDC *pDC,CRect rect, COLORREF color)
    {
    //color为半透明的底色
    COLORREF bkcolor;
    int R1,G1,B1,R2,G2,B2;
    R1=color&255;
    G1=(color>>8)&255;
    B1=(color>>16)&255;
    //标记块的左边与右边各多显示一点
    for(int x=rect.left-1;x<=rect.right;x++)
    {
    for(int y=rect.top-1;y<=rect.bottom;y++)
    {
    //nRatio为透光率
    bkcolor=pDC->GetPixel(x,y);
    R2=bkcolor&255;
    G2=(bkcolor>>8)&255;
    B2=(bkcolor>>16)&255;
    R2=R1+(R2-R1)*m_nRatio/100;
    G2=G1+(G2-G1)*m_nRatio/100;
    B2=B1+(B2-B1)*m_nRatio/100;
    pDC->SetPixel(x,y,RGB(R2,G2,B2));
    }
    }
    }
    用好了别忘了给分
      

  11.   

    那些都不是真正的方法,你没有发现那个窗口底色不能变啊,那时mmx技术提供的特征,要实现那个我现在只能用汇编的mmx指令做出来,那些windows编程里的api不是真正的解决方案!
    明白了吗!!~~
    别的软件里可能不是这种方法!