2014년 8월 26일 화요일

윈도우 크게에 따라 컨트롤 크기를 동적으로 변화 시키기

1. 최초 윈도우와 컨트롤들의 넓이와 높이의 비율계산
2. 윈도우의 크기에 계산된 비율을 적용하여 컨트롤 크기 변화

ex)
void dlg::CalSizeRate(void)
{
   CRect rect;
   GetClientRect(rect); //윈도우의 크기
 
   m_widthRatio = width / rect.right;
   m_heightRatio = height / rect.bottom
}

void dlg::OnSIze(UINT nType, int cx, int cy)
{
   _ctrl.GetWindowRect(&rect);
   ScreenToClient(&rect);
   rect.right = rect.left+(cx*m_widthRatio);
   rect.bottom = rect.top+(cy*m_heightRatio);
   _ctrl.MoveWindow(&rect, FALSE);
}

dll을 통하여 다이얼로그 생성[Create()]시 invalid dialog template name

dll프로젝트를 생성 할때 Use MFC in a Static Library로 생성해야 한다.