码迷,mamicode.com
首页 > 其他好文 > 详细

关于非对话框的透明窗口

时间:2015-01-04 06:22:43      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

#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);

}

关于非对话框的透明窗口

标签:

原文地址:http://www.cnblogs.com/thbCode/p/4200256.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!