• 大小: 0.4M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: 其他
  • 标签: 其他  

资源简介

MaskWindow.zip

资源截图

代码片段和文件信息

// MaskWindow.cpp : 实现文件
//

#include “stdafx.h“
#include “MaskWindow.h“


// CMaskWindow
LPCTSTR CMaskWindow::m_lpszClassName=NULL;

IMPLEMENT_DYNAMIC(CMaskWindow CWnd)

CMaskWindow::CMaskWindow()
{
m_bIsBlur=FALSE;
m_bIsMouse=FALSE;
m_hWndControl=NULL;
m_clrMask=0;
m_nMaskAlpha=100;
m_hCacheDC=NULL;
m_hCacheBitmap=NULL;
m_hCacheOldBitmap=NULL;
}

CMaskWindow::~CMaskWindow()
{
DestroyMask();
}


BEGIN_MESSAGE_MAP(CMaskWindow CWnd)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_MOVE()
ON_WM_DESTROY()
END_MESSAGE_MAP()


//创建遮罩窗口(父窗口句柄,是否模糊,是否鼠标穿透,遮罩颜色,遮罩透明度)
BOOL CMaskWindow::CreateMask(HWND hWndParentBOOL bIsBlurBOOL bIsMouseHWND hWndControlCOLORREF clrMaskint nAlpha)
{
if(hWndParent==NULL || !::IsWindow(hWndParent))
{
return FALSE;
}
//------------------------------
DestroyMask();
m_bIsBlur=bIsBlur;
m_bIsMouse=bIsMouse;
m_hWndControl=hWndControl;
m_clrMask=clrMask;
m_nMaskAlpha=nAlpha;
if(m_bIsBlur)
{
m_bIsMouse=FALSE;
}
if(m_nMaskAlpha<0)
{
m_nMaskAlpha=0;
}
else if(m_nMaskAlpha>255)
{
m_nMaskAlpha=255;
}
//------------------------------
DWORD dwstyle = WS_CHILD;
DWORD dwExstyle = NULL;
if(m_bIsMouse)
{
dwstyle = WS_POPUP;
dwExstyle = WS_EX_layerED | WS_EX_TRANSPARENT;
}
if(m_lpszClassName==NULL)
{
m_lpszClassName=AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS
::LoadCursor (NULL IDC_ARROW)
(HBRUSH)::GetStockobject (BLACK_BRUSH)
);
}
if(!CWnd::CreateEx(dwExstylem_lpszClassNameNULLdwstyle0000hWndParent(HMENU)NULL))
{
return FALSE;
}
//------------------------------
AdjustPos();
if(m_bIsMouse)
{
SetlayeredWindowAttributes (m_clrMask m_nMaskAlpha LWA_ALPHA);
}
else
{
DoEvents();
CreateCache();
ShowControl(SW_HIDE);
}
    BringWindowToTop ();
ShowWindow (SW_SHOWNOACTIVATE);
//------------------------------
return TRUE;

}
void CMaskWindow::DestroyMask()
{
ShowControl(SW_SHOWNOACTIVATE);
if(::IsWindow(m_hWnd))
{
::DestroyWindow(m_hWnd);
}
if(m_hCacheDC)
{
Selectobject(m_hCacheDCm_hCacheOldBitmap);
Deleteobject(m_hCacheBitmap);
DeleteDC(m_hCacheDC);
m_hCacheDC=NULL;
m_hCacheBitmap=NULL;
m_hCacheOldBitmap=NULL;
}

}
//显示隐藏子控件
void CMaskWindow::ShowControl(int nCmdShow)
{
HWND hWndOwner=::GetWindow(m_hWndGW_OWNER);
if(!hWndOwner)
{
hWndOwner=::GetParent(m_hWnd);
}
//--------------------------
if(nCmdShow==SW_HIDE)
{
HWND hWndChild=::GetWindow(hWndOwnerGW_CHILD);
while(hWndChild)
{
if(hWndChild!=m_hWnd && hWndChild!=m_hWndControl)
{
if(::IsWindowVisible(hWndChild))
{
::ShowWindow(hWndChildSW_HIDE);
m_hWndChildArray.Add(hWndChild);
}
}
hWndChild=::GetWindow(hWndChildGW_HWNDNEXT);
}
}
else
{
int nCount = m_hWndChildArray.GetCount();
for(int i=0;i {
::ShowWindow(m_hWndChildArray[i]nCmdShow);
}
m_h

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-10-31 20:12  遮罩窗口\
     文件      372736  2016-10-31 20:08  遮罩窗口\MaskWndTest.exe
     目录           0  2016-10-31 20:11  遮罩窗口\VC源码\
     目录           0  2016-10-31 20:11  遮罩窗口\VC源码\MaskWndTest\
     文件        8973  2016-10-31 20:08  遮罩窗口\VC源码\MaskWndTest\MaskWindow.cpp
     文件        1224  2016-10-31 20:08  遮罩窗口\VC源码\MaskWndTest\MaskWindow.h
     文件        1841  2016-10-31 17:30  遮罩窗口\VC源码\MaskWndTest\MaskWndTest.cpp
     文件         506  2016-10-31 17:30  遮罩窗口\VC源码\MaskWndTest\MaskWndTest.h
     文件        5350  2016-10-31 20:04  遮罩窗口\VC源码\MaskWndTest\MaskWndTest.rc
     文件        5709  2016-10-31 20:04  遮罩窗口\VC源码\MaskWndTest\MaskWndTest.vcproj
     文件        4109  2016-10-31 19:02  遮罩窗口\VC源码\MaskWndTest\MaskWndTestDlg.cpp
     文件         864  2016-10-31 18:57  遮罩窗口\VC源码\MaskWndTest\MaskWndTestDlg.h
     文件        2835  2016-10-31 17:30  遮罩窗口\VC源码\MaskWndTest\ReadMe.txt
     目录           0  2016-10-31 20:11  遮罩窗口\VC源码\MaskWndTest\res\
     文件       49078  2016-10-31 20:04  遮罩窗口\VC源码\MaskWndTest\res\banner.bmp
     文件       21630  2005-12-08 14:56  遮罩窗口\VC源码\MaskWndTest\res\MaskWndTest.ico
     文件         367  2016-10-31 17:30  遮罩窗口\VC源码\MaskWndTest\res\MaskWndTest.rc2
     文件         911  2016-10-31 20:04  遮罩窗口\VC源码\MaskWndTest\resource.h
     文件         178  2016-10-31 17:30  遮罩窗口\VC源码\MaskWndTest\stdafx.cpp
     文件        2540  2016-10-31 17:30  遮罩窗口\VC源码\MaskWndTest\stdafx.h
     文件         898  2016-10-31 17:30  遮罩窗口\VC源码\MaskWndTest.sln
     目录           0  2016-10-31 20:11  遮罩窗口\易语言源码\
     文件      143642  2016-10-31 00:15  遮罩窗口\易语言源码\彗星遮罩窗口模块.e
     文件      121426  2016-10-31 00:15  遮罩窗口\易语言源码\彗星遮罩窗口模块.ec
     文件       34776  2016-10-29 22:09  遮罩窗口\易语言源码\遮罩窗口演示.e

评论

共有 条评论