怎样让我镂空的区域移动呢?在VIEW中获取坐标 控制 FRAM中的镂空
本帖最后由 a8239224 于 2013-09-12 11:14:11 编辑
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
ModifyStyle(WS_CAPTION,0); //去掉标题栏
ModifyStyle(WS_THICKFRAME,0);//去掉边框
SetMenu(NULL); //去掉菜单
//后来添加 用于去掉全屏后的多余的边框
CRect WindowRect;
GetWindowRect(&WindowRect);
CRect ClientRect;
//RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST,reposQuery,&ClientRect);
GetClientRect(&ClientRect);
ClientToScreen(&ClientRect);
int nFullWidth=GetSystemMetrics(SM_CXSCREEN);
int nFullHeight=GetSystemMetrics(SM_CYSCREEN);
m_FullScreenRect.left=WindowRect.left-ClientRect.left-2;
m_FullScreenRect.top=WindowRect.top-ClientRect.top-2;
m_FullScreenRect.right=WindowRect.right-ClientRect.right+nFullWidth+2;
m_FullScreenRect.bottom=WindowRect.bottom-ClientRect.bottom+nFullHeight+2;
m_FullScreen=TRUE;
WINDOWPLACEMENT wndpl;
wndpl.length=sizeof(WINDOWPLACEMENT);
wndpl.flags=0;
wndpl.showCmd=SW_SHOWNORMAL;
wndpl.rcNormalPosition=m_FullScreenRect;
ShowWindow(SW_SHOW);
SetWindowPlacement(&wndpl);
/////////////////////////////镂空的代码
SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE)
& (~(WS_CAPTION | WS_BORDER)));//不重绘边框和标题栏
//
CRgn WindowRgn;
CRgn HoleRgn;
//CRect WindowRect;
GetWindowRect(WindowRect);
//ScreenToClient(WindowRect);
//得到窗口形状
BOOL bWindowSucceed = WindowRgn.CreateRectRgn(0,0,WindowRect.Width()+14,WindowRect.Height());
ASSERT( bWindowSucceed == TRUE );
//初始化洞口区域
//BOOL bHoleSucceeded = HoleRgn.CreateRectRgn(WindowRect.Width()/4,WindowRect.Height()/4,WindowRect.Width()*4/5,WindowRect.Height()*4/5);
BOOL bHoleSucceeded = HoleRgn.CreateRectRgn(m_startPoint.x-m_oldPoint.x, m_startPoint.y-m_oldPoint.y, m_startPoint.x-m_oldPoint.x+300,m_startPoint.y-m_oldPoint.y+300);//m_startPoint是鼠标弹起时的坐标,m_oldPoint是鼠标按下时的坐标
ASSERT( bHoleSucceeded == TRUE );
//合并
WindowRgn.CombineRgn(&HoleRgn,&WindowRgn,RGN_XOR);//RGN_XOR异或
SetWindowRgn((HRGN)WindowRgn.m_hObject/*(HRGN)WindowRgn*/,true);
//以下语句可还原
//SetWindowRgn(NULL,true);
WindowRgn.DeleteObject();
HoleRgn.DeleteObject();
return 0;
}