我在窗体上作图后,可不可以使窗体背景透明,图形和依旧保存?希望各位高手能帮帮小弟。

解决方案 »

  1.   

    在WIN2K下用SetSetLayeredWindowAttributes
    在WIN9X下用AlphaBlend
    http://www.vckbase.com/document/viewdoc.asp?id=333
      

  2.   

    第一步 定义功能
    typedef BOOL (FAR PASCAL * FUNC1)( 
      HWND hwnd,           // handle to the layered window 
      COLORREF crKey,      // specifies the color key 
      BYTE bAlpha,         // value for the blend function 
      DWORD dwFlags        // action 
    );  第二步 实现代码 在OnInitDialog中加入下列代码 
    ..... 
    HMODULE hModule = GetModuleHandle("user32.dll"); 
    FUNC1 SetLayeredWindowAttributes; 
    SetLayeredWindowAttributes =  (FUNC1) GetProcAddress (hModule,   _T( "SetLayeredWindowAttributes" ) ); 
    // 设置分层扩展标记 
    SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, GetWindowLong(GetSafeHwnd(),
     GWL_EXSTYLE) | 0x80000L); 
    // 70% alpha 
    SetLayeredWindowAttributes(GetSafeHwnd(), 0, (255 * 70) / 100, 0x2);