怎么在EVC里创建一个不规则的窗口

tom1980 2005-04-15 12:21:30
rt
...全文
41 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
红牛哥110 2005-04-15
  • 打赏
  • 举报
回复
试试这个:
HRGN BitmapToRegion (HBITMAP hBmp, COLORREF cTransparentColor, COLORREF cTolerance)
{
HRGN hRgn = NULL;

ASSERT(hBmp);
if (hBmp)
{
// Create a memory DC inside which we will scan the bitmap content
HDC hMemDC = CreateCompatibleDC(NULL);
ASSERT(hMemDC);
if (hMemDC)
{
// Get bitmap siz
BITMAP bm;
GetObject(hBmp, sizeof(bm), &bm);

// Create a 32 bits depth bitmap and select it into the memory DC
BITMAPINFOHEADER RGB32BITSBITMAPINFO = {
sizeof(BITMAPINFOHEADER), // biSize
bm.bmWidth, // biWidth;
bm.bmHeight, // biHeight;
1, // biPlanes;
32, // biBitCount
BI_RGB, // biCompression;
0, // biSizeImage;
0, // biXPelsPerMeter;
0, // biYPelsPerMeter;
0, // biClrUsed;
0 // biClrImportant;
};
VOID * pbits32;
HBITMAP hbm32 = CreateDIBSection(hMemDC, (BITMAPINFO *)&RGB32BITSBITMAPINFO,
DIB_RGB_COLORS, &pbits32, NULL, 0);
ASSERT(hbm32);
if (hbm32)
{
HBITMAP holdBmp = (HBITMAP)SelectObject(hMemDC, hbm32);
// Create a DC just to copy the bitmap into the memory DC
HDC hDC = CreateCompatibleDC(hMemDC);
ASSERT(hDC);
if (hDC)
{
// Get how many bytes per row we have for the bitmap bits (rounded up to 32 bits
BITMAP bm32;
VERIFY(GetObject(hbm32, sizeof(bm32), &bm32));
while (bm32.bmWidthBytes % 4)
bm32.bmWidthBytes++;

// Copy the bitmap into the memory DC
HBITMAP holdBmp = (HBITMAP)SelectObject(hDC, hBmp);
cTransparentColor = ::GetPixel(hDC, 0, 0);
TRACE("%d, %d, %d : Color R G B\n",GetRValue(cTransparentColor),
GetGValue(cTransparentColor),
GetBValue(cTransparentColor)
);
VERIFY(BitBlt(hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, hDC, 0, 0, SRCCOPY));

// For better performances, we will use the ExtCreateRegion() function to create the
// region. This function take a RGNDATA structure on entry. We will add rectangles b
// amount of ALLOC_UNIT number in this structure
#define ALLOC_UNIT 100
DWORD maxRects = ALLOC_UNIT;
HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects));
RGNDATA *pData = (RGNDATA *)GlobalLock(hData);
pData->rdh.dwSize = sizeof(RGNDATAHEADER);
pData->rdh.iType = RDH_RECTANGLES;
pData->rdh.nCount = pData->rdh.nRgnSize = 0;
SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0);

// Scan each bitmap row from bottom to top (the bitmap is inverted vertically
BYTE *p32 = (BYTE *)bm32.bmBits + (bm32.bmHeight - 1) * bm32.bmWidthBytes; // go to bottom
for (int y = 0; y < bm.bmHeight; y++)
{
// Scan each bitmap pixel from left to righ
for (int x = 0; x < bm.bmWidth; x++)
{
// Search for a continuous range of "non transparent pixels"
int x0 = x;
LONG *p = (LONG *)p32 + x;
while (x < bm.bmWidth)
{
if(*p == cTransparentColor)
break;
p++;
x++;
}

if (x > x0) // the first pixel is not transparent color
{
// Add the pixels (x0, y) to (x, y+1) as a new rectangle in the regio
if (pData->rdh.nCount >= maxRects)
{
GlobalUnlock(hData);
maxRects += ALLOC_UNIT;
VERIFY(hData = GlobalReAlloc(hData, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), GMEM_MOVEABLE));
pData = (RGNDATA *)GlobalLock(hData);
ASSERT(pData);
}
RECT *pr = (RECT *)&pData->Buffer;
SetRect(&pr[pData->rdh.nCount], x0, y, x, y+1);
// follow lines may be never occured
if (x0 < pData->rdh.rcBound.left)
pData->rdh.rcBound.left = x0;
if (y < pData->rdh.rcBound.top)
pData->rdh.rcBound.top = y;
if (x > pData->rdh.rcBound.right)
pData->rdh.rcBound.right = x;
if (y+1 > pData->rdh.rcBound.bottom)
pData->rdh.rcBound.bottom = y+1;
// above lines may be never occured
pData->rdh.nCount++;

// On Windows98, ExtCreateRegion() may fail if the number of rectangles is to
// large (ie: > 4000). Therefore, we have to create the region by multiple steps
if (pData->rdh.nCount == 2000)
{
HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), pData);
ASSERT(h);
if (hRgn)
{
CombineRgn(hRgn, hRgn, h, RGN_OR);
DeleteObject(h);
}
else
hRgn = h;
pData->rdh.nCount = 0;
SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0);
}
}
}

// Go to next row (remember, the bitmap is inverted vertically
p32 -= bm32.bmWidthBytes;
}

// Create or extend the region with the remaining rectangle
HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), pData);
ASSERT(h);
if (hRgn)
{
// AfxMessageBox("Not null");
CombineRgn(hRgn, hRgn, h, RGN_OR);
DeleteObject(h);
}
else
{
// AfxMessageBox("hrgn is null");
hRgn = h;
}

// Clean u
GlobalFree(hData);
SelectObject(hDC, holdBmp);
DeleteDC(hDC);
}

DeleteObject(SelectObject(hMemDC, holdBmp));
}

DeleteDC(hMemDC);
}
}

return hRgn;
}

《企业级 VMware vSphere 6.7虚拟化技术配置与管理》课程共分为“上集”和“下集”两部分,本套视频为“下集”部分,“上集”部分已经对VMware vSphere 6.7的计算资源、网络资源、存储资源、虚拟机配置与管理等进行了详细讲解,“下集”部分以“上集”为基础进行技术延伸,全面对vMotion、DRS、HA、FT、性能监控、VDP备份等特性进行理论讲解和实战配置。 通过本课程学习,可以全面掌握vMotion、资源池、DRS、HA、FT、VDP、监控等高可用性运维技能。 《企业级 VMware vSphere虚拟化技术配置与管理》下集部分具体课程章节如下。 第1章 《VMware vSphere 6.7 vMotion配置与管理》主要内容本章我们详细介绍了冷迁移、通过 vMotion 迁移、通过 Storage vMotion 迁移、CPU 兼容性和 EVC、在 vSphere Client中迁移已关闭电源或已挂起的虚拟机、将开机状态的虚拟机迁移至新计算资源和存储、关于迁移兼容性检查等内容。希望大家在掌握理论的基础上,跟做课程中涉及的每一个实验,达到融会贯通的效果。 第2章 《VMware vSphere 6.7 资源和DRS配置与管理》主要内容本章我们主要讲解了CPU虚拟化资源管理知识、内存虚拟化资源管理知识、存储虚拟化资源管理知识、资源池、DRS群集、Storage I/O Control、科学合理的进行资源分配相关理论和操作。希望大家在掌握理论的基础上,跟做课程中涉及的每一个实验,达到融会贯通的效果。 第3章 《VMware vSphere 6.7 HA配置与管理》主要内容本章我们主要讲解了业务连续性和最小化停机时间、vSphere HA 的工作原理、vSphere HA 准入控制、vSphere HA 互操作性等知识。通过实践操作,可以掌握创建 vSphere HA 群集,配置 vSphere HA群集,配置 Proactive HA。为了提高vCenter Server的高可用性,讲解了vCenter High Availability知识。希望大家在掌握理论的基础上,跟做课程中涉及的每一个实验,达到融会贯通的效果。 第4章 《VMware vSphere 6.7 FT配置与管理》主要内容本章我们从理论上讲解了Fault Tolerance 的工作原理、Fault Tolerance工作用例、Fault Tolerance 环境要求、限制和许可、Fault Tolerance 互操作性。以理论为基础,实践了打开Fault Tolerance功能、测试Fault Tolerance故障切换、迁移辅助虚拟机、挂起Fault Tolerance、恢复Fault Tolerance、关闭Fault Tolerance等内容。最后总结了使用Fault Tolerance的科学做法、Fault Tolerance的故障排除方法。希望大家在掌握理论的基础上,跟做课程中涉及的每一个实验,达到融会贯通的效果。 第5章 《VMware vSphere Data Protection(VDP)》 主要内容本章我们从理论上讲解vSphere Data Protection的基本功能、体系架构。演示了VDP的安装和配置,讲解了怎样正确使用VDP以及使用VDP进行管理备份,自动备份验证,管理恢复,复制作业,文件级恢复,紧急恢复,VDP代理等相关功能,最后针对VDP常见故障进行了总结分析。希望大家在掌握理论的基础上,跟做课程中涉及的每一个实验,达到融会贯通的效果。 第6章 《VMware vSphere 6.7 监控和性能》 主要内容本章我们从理论上讲解了vSphere监控、性能、日志等相关基本知识。实践操作了使用性能图表监控清单对象、监控事件和警报、系统日志文件的配置。希望大家在掌握理论的基础上,跟做课程中涉及的每一个实验,达到融会贯通的效果。 企业级 VMware vSphere 6.7虚拟化技术配置与管理(上集)视频课程:https://edu.csdn.net/course/detail/35162企业级 VMware vSphere 6.7虚拟化技术配置与管理(下集)视频课程:https://edu.csdn.net/course/detail/35171

19,502

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧