• 关于非对话框的透明窗口


    #include "StdAfx.h"

    #include "TransWnd.h"

    CTransWnd::CTransWnd(void)

    {  

    const TCHAR szClassName[] = TEXT ("TransWindow") ;    

    WNDCLASS wndclass ;  

    wndclass.style = CS_HREDRAW | CS_VREDRAW ;  

    wndclass.lpfnWndProc = DefWindowProc ;  

    wndclass.cbClsExtra = 0 ;  

    wndclass.cbWndExtra = 0 ;  

    wndclass.hInstance = ::AfxGetInstanceHandle() ;  

    wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;  

    wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;  

    wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;

     wndclass.lpszMenuName = NULL ;  wndclass.lpszClassName = szClassName ;

     if(!RegisterClass (&wndclass))  

     AfxMessageBox(L"REGISTRE 'TransWindow' CLASS ERROR!");

    }

    CTransWnd::~CTransWnd(void)

    {  

    ::DestroyWindow(m_hwnd);

    }

    void CTransWnd::Create(CRect rc, HWND hParentHwnd)

    {  

    ::DestroyWindow(m_hwnd);  

    m_hwnd = ::CreateWindowEx(      

    WS_EX_LAYERED,      

    TEXT ("TransWindow"), // wndow class name      

    NULL, // window caption      

    WS_POPUP | WS_CHILD, // window style     

     rc.left, // initial x position     

     rc.top, // initial y position     

     rc.Width(), // initial x size      

    rc.Height(), // initial y size      

    NULL, // parent window handle      

    NULL, // window menu handle      

    ::AfxGetInstanceHandle(), // program instance handle     

     NULL) ; // creation parameters

     SetLayeredWindowAttributes(   m_hwnd,   RGB(0,0,0),   100, LWA_ALPHA   );

     ShowWindow(m_hwnd, SW_SHOW);

    }

  • 相关阅读:
    第14周周总结
    第13周周总结
    栈与队列
    前端继承方式汇总
    实现前端资源增量式更新的一种思路
    link和@import引入外部样式的区别
    webSocket
    Java 下载JDK账号
    穿透
    vue.set方法的使用
  • 原文地址:https://www.cnblogs.com/thbCode/p/4200256.html
Copyright © 2020-2023  润新知