// Returns the angle of the surface, probed at the points -radius and +radius // 90 degree == completely even surface global func GetSurfaceAngle(int x, int y, int stepping, int radius) { var left = GetYBorder(x - radius, y, stepping); var right = GetYBorder(x + radius, y, stepping); return Angle(x - radius, left, x+radius, right); }
//初始化消息 BOOL CHintMsgBox::OnInitDialog() { __super::OnInitDialog(); //设置标题 SetWindowText(m_strCaption); //关闭按钮 if((m_uType&MB_DEFBUTTON2)!=0)m_cbButtonState[BST_CLOSE]&=(~BUT_EXIST); else m_cbButtonState[BST_CLOSE]|=BUT_EXIST; //按钮区域 CreateBoxButton(); INT nButtonAreaHeight=SMB_BUTTON_HEIGHT+SMB_BUTTON_TOP+SMB_BUTTON_BUTTOM; INT nButtonAreaWidth=m_nBtCount*SMB_BUTTON_WIDTH+(m_nBtCount+1)*SMB_BUTTON_SPACE+SMB_BUTTON_LEFT+SMB_BUTTON_RIGHT; //字符空间 CClientDC ClientDC(this); CRect rcString(0,0,SMB_STRING_WIDTH,SMB_STRING_HEIGHT); ClientDC.SelectObject(CSkinResourceManager::GetDefaultFont()); ClientDC.DrawText(m_strString,rcString,DT_CALCRECT|DT_EXPANDTABS|DT_NOCLIP|DT_WORD_ELLIPSIS); //字符区域 INT nStringAreaHeight=rcString.Height()+SMB_STRING_TOP; INT nStringAreaWidth=rcString.Width()+SMB_ICON_LEFT+SMB_ICON_WIDTH+SMB_STRING_LEFT+SMB_STRING_RIGHT; //窗口区域 INT nWindowAreaHeight=nStringAreaHeight+nButtonAreaHeight; INT nWindowAreaWidth=__max(SMB_WINDOW_WIDTH,__max(nStringAreaWidth,nButtonAreaWidth)); //输出位置 if (nWindowAreaWidth>nStringAreaWidth) { m_rcString.top=m_SkinAttribute.m_nCaptionHeigth+SMB_STRING_TOP; m_rcString.left=GetXBorder()+SMB_ICON_LEFT+SMB_ICON_WIDTH+SMB_STRING_LEFT+(nWindowAreaWidth-nStringAreaWidth)/2; m_rcString.right=m_rcString.left+rcString.Width(); m_rcString.bottom=m_rcString.top+rcString.Height(); } else { m_rcString.top=m_SkinAttribute.m_nCaptionHeigth+SMB_STRING_TOP; m_rcString.left=GetXBorder()+SMB_ICON_LEFT+SMB_ICON_WIDTH+SMB_STRING_LEFT; m_rcString.right=m_rcString.left+rcString.Width(); m_rcString.bottom=m_rcString.top+rcString.Height(); } //调整窗口 CRect rcWindow(0,0,0,0); rcWindow.right=nWindowAreaWidth+GetXBorder()*2; rcWindow.bottom=nWindowAreaHeight+m_SkinAttribute.m_nCaptionHeigth+GetYBorder(); SetWindowPos(NULL,0,0,rcWindow.Width(),rcWindow.Height(),SWP_NOMOVE|SWP_NOZORDER); //调整按钮 INT nYButton=m_SkinAttribute.m_nCaptionHeigth+nWindowAreaHeight-SMB_BUTTON_BUTTOM-SMB_BUTTON_HEIGHT; INT nXButton=GetXBorder()+(nWindowAreaWidth-m_nBtCount*SMB_BUTTON_WIDTH-(m_nBtCount+1)*SMB_BUTTON_SPACE)/2+SMB_BUTTON_SPACE; for (UINT i=0;i<m_nBtCount;i++) { m_btButton[i].SetWindowPos(NULL,nXButton,nYButton,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW); nXButton+=SMB_BUTTON_SPACE+SMB_BUTTON_WIDTH; } //默认按钮 UINT uDefaultIndex=(m_uType&MB_DEFMASK)>>8; if (uDefaultIndex>=m_nBtCount) uDefaultIndex=0; m_btButton[uDefaultIndex].SetFocus(); m_btButton[uDefaultIndex].SetButtonStyle(m_btButton[uDefaultIndex].GetButtonStyle()|BS_DEFPUSHBUTTON); //居中窗口 CenterWindow(GetParent()); //设置时间 if (m_nElapse!=0) SetTimer(IDI_MESSAGE,1000,NULL); return FALSE; }