首页上一页 1 下一页尾页 3 条记录 1/1页
急
发表在C语言图书答疑
2009-08-31
是否精华
是
否
版块置顶:
是
否
我想问一下 预览高度和宽度为什么那样计算?我看不懂 谢谢
BOOL CPanel::CreatePreWnd(UINT uNum)
{
if(uNum == 0)
return FALSE;
m_UnitNum = uNum;
m_Num = pow(uNum,2);
m_pList = new CPreView[m_Num];
CRect rc;
GetClientRect(rc);
//预览窗口的宽度
int width = (rc.Width() - (uNum + 1) * m_Div) / uNum;
//预览窗口的高度
int height = (rc.Height() - (uNum + 1) * m_Div) / uNum;
for (int i =0; i<m_Num; i++)
{
int row = i / uNum + 1;
int col = i % uNum + 1;
int x = col*m_Div + (col - 1) * width;
int y = row*m_Div + (row - 1) * height;
CRect rect(x,y,x+width,y+height);
m_pList[i].Create("",WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_NOTIFY,rect,this);
m_pList[i].m_Index = i;
}
return TRUE;
}
BOOL CPanel::CreatePreWnd(UINT uNum)
{
if(uNum == 0)
return FALSE;
m_UnitNum = uNum;
m_Num = pow(uNum,2);
m_pList = new CPreView[m_Num];
CRect rc;
GetClientRect(rc);
//预览窗口的宽度
int width = (rc.Width() - (uNum + 1) * m_Div) / uNum;
//预览窗口的高度
int height = (rc.Height() - (uNum + 1) * m_Div) / uNum;
for (int i =0; i<m_Num; i++)
{
int row = i / uNum + 1;
int col = i % uNum + 1;
int x = col*m_Div + (col - 1) * width;
int y = row*m_Div + (row - 1) * height;
CRect rect(x,y,x+width,y+height);
m_pList[i].Create("",WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_NOTIFY,rect,this);
m_pList[i].m_Index = i;
}
return TRUE;
}