15,978
社区成员




CRect rect;
GetWindowRect(&rect);
m_listRect.AddTail(rect);//对话框的区域
CWnd* pWnd = GetWindow(GW_CHILD);//获取子窗体
while (pWnd)
{
pWnd->GetWindowRect(rect);//子窗体的区域
m_listRect.AddTail(rect); //CList<CRect,CRect> m_listRect成员变量
pWnd = pWnd->GetWindow(GW_HWNDNEXT);//取下一个子窗体
}
if (m_listRect.GetCount() > 0)
{
CRect dlgNow;
GetWindowRect(&dlgNow);
POSITION pos = m_listRect.GetHeadPosition();//第一个保存的是对话框的Rect
CRect dlgSaved;
dlgSaved = m_listRect.GetNext(pos);
ScreenToClient(dlgNow);
double x = dlgNow.Width() * 1.0 / dlgSaved.Width();//根据当前和之前保存的对话框的宽高求比例
double y = dlgNow.Height() *1.0 / dlgSaved.Height();
ClientToScreen(dlgNow);
CRect childSaved;
CWnd* pWnd = GetWindow(GW_CHILD);
while (pWnd)
{
childSaved = m_listRect.GetNext(pos);//依次获取子窗体的Rect
childSaved.left = LONG(dlgNow.left + (childSaved.left - dlgSaved.left)*x);//根据比例调整控件上下左右距离对话框的距离
childSaved.right = LONG(dlgNow.right + (childSaved.right - dlgSaved.right)*x);
childSaved.top = LONG(dlgNow.top + (childSaved.top - dlgSaved.top)*y);
childSaved.bottom = LONG(dlgNow.bottom + (childSaved.bottom - dlgSaved.bottom)*y);
ScreenToClient(childSaved);
pWnd->MoveWindow(childSaved);
pWnd = pWnd->GetNextWindow();
}
}
// TODO: Add extra initialization here
m_Tab.DeleteAllItems();
char txt[40];
TCITEM TabCtrlItem;
memset(&TabCtrlItem,0,sizeof(TabCtrlItem));
TabCtrlItem.mask= TCIF_TEXT;
TabCtrlItem.cchTextMax=260;
for(int jj=0;jj<5;jj++)
{
sprintf(txt,"Dlg%d",jj);
TabCtrlItem.pszText=txt;//(LPSTR)(LPCSTR)"1";//tabCaption;
m_Tab.InsertItem(jj, &TabCtrlItem);
}
m_Tab.SetCurSel(2);
#ifdef DELETE_BEFORE_CREATE
CreateNewDlg();
#else
CreateAllDlgs();
ShowSelectedDlg();
#endif
CString AnalyseBoxClstr("量化分析");
CString UserSelectClstr("自选股");
m_Maintabctrl.InsertItem(0, MinuteBoxstr);
m_Maintabctrl.InsertItem(1, ThityBoxstr);
m_Maintabctrl.InsertItem(2, SixtyBoxstr);
m_Maintabctrl.InsertItem(3, DayBoxClstr);
m_Maintabctrl.InsertItem(4, WeekBoxClstr);
m_Maintabctrl.InsertItem(5, MoonBoxClstr);
m_Maintabctrl.InsertItem(6, AnalyseBoxClstr);
m_Maintabctrl.InsertItem(7, UserSelectClstr);
CRect rec;
m_Maintabctrl.GetClientRect(&rec);//获得TAB控件的坐标
rec.bottom -= 2;
rec.left += 1;
rec.top += 22;
rec.right -= 3;
//创建子页面
myMinuteBoxCls.Create(IDD_MinuteBox, &m_Maintabctrl);
myThityBoxCls.Create(IDD_ThirtyBox, &m_Maintabctrl);
mySixtyBox.Create(IDD_SixtyBox, &m_Maintabctrl);
myDayBoxCl.Create(IDD_DayBox, &m_Maintabctrl);
myWeekBoxCl.Create(IDD_WeekBox, &m_Maintabctrl);
myMoonBoxCl.Create(IDD_MoonBox, &m_Maintabctrl);
myAnalyseBoxCl.Create(IDD_AnalyseBox, &m_Maintabctrl);
myUserSelectCl.Create(IDD_UserSelectBox, &m_Maintabctrl);
//将子页面移动到指定的位置
myMinuteBoxCls.MoveWindow(&rec);
//创建子页面
myMainFiveTradeCl.Create(IDD_MainFiveTradeBox, &m_FiveTradetabctrl);
myMainHandicapCl.Create(IDD_MainHandicapBox, &m_FiveTradetabctrl);
//将子页面移动到指定的位置
myMainFiveTradeCl.MoveWindow(&Fiverec);
myMainHandicapCl.MoveWindow(&Fiverec);
//显示子页面
myMainFiveTradeCl.ShowWindow(SW_SHOW);
myMainHandicapCl.ShowWindow(SW_HIDE);
m_FiveTradetabctrl.SetCurSel(0);
void MainFiveTradeCl::WindowsZoom()
{
//----------------------窗口等比例缩放
CRect rect;
GetWindowRect(&rect);
m_FiveTradelistRect.AddTail(rect);//对话框的区域
CWnd* pWnd = GetWindow(GW_CHILD);//获取子窗体
while (pWnd)
{
pWnd->GetWindowRect(rect);//子窗体的区域
m_FiveTradelistRect.AddTail(rect); //CList<CRect,CRect> m_listRect成员变量
pWnd = pWnd->GetWindow(GW_HWNDNEXT);//取下一个子窗体
}
//-----------------------End
}
BOOL MainFiveTradeCl::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void MainFiveTradeCl::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
if (m_FiveTradelistRect.GetCount() > 0)
{
CRect dlgNow;
GetWindowRect(&dlgNow);
POSITION pos = m_FiveTradelistRect.GetHeadPosition();//第一个保存的是对话框的Rect
CRect dlgSaved;
dlgSaved = m_FiveTradelistRect.GetNext(pos);
ScreenToClient(dlgNow);
double x = dlgNow.Width() * 1.0 / dlgSaved.Width();//根据当前和之前保存的对话框的宽高求比例
double y = dlgNow.Height() *1.0 / dlgSaved.Height();
ClientToScreen(dlgNow);
CRect childSaved;
CWnd* pWnd = GetWindow(GW_CHILD);
while (pWnd)
{
childSaved = m_FiveTradelistRect.GetNext(pos);//依次获取子窗体的Rect
childSaved.left = LONG(dlgNow.left + (childSaved.left - dlgSaved.left)*x);//根据比例调整控件上下左右距离对话框的距离
childSaved.right = LONG(dlgNow.right + (childSaved.right - dlgSaved.right)*x);
childSaved.top = LONG(dlgNow.top + (childSaved.top - dlgSaved.top)*y);
childSaved.bottom = LONG(dlgNow.bottom + (childSaved.bottom - dlgSaved.bottom)*y);
ScreenToClient(childSaved);
pWnd->MoveWindow(childSaved);
pWnd = pWnd->GetNextWindow();
}
}
}
主窗口代码
BOOL CNewGpSysDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
ShowWindow(SW_NORMAL);
//LoadButtonImage(); //加载按钮图片
InitializeTabPage(); //初始化Tab页面
WindowsZoom(); //窗口等比例缩放
myMainFiveTradeCl.WindowsZoom();
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
void CNewGpSysDlg::OnSize(UINT nType, int cx, int cy)//窗口等比例缩放
{
CDialogEx::OnSize(nType, cx, cy);
myMainFiveTradeCl.OnSize(0, 0, 0);
if (m_listRect.GetCount() > 0)
{
CRect dlgNow;
GetWindowRect(&dlgNow);
POSITION pos = m_listRect.GetHeadPosition();//第一个保存的是对话框的Rect
CRect dlgSaved;
dlgSaved = m_listRect.GetNext(pos);
ScreenToClient(dlgNow);
double x = dlgNow.Width() * 1.0 / dlgSaved.Width();//根据当前和之前保存的对话框的宽高求比例
double y = dlgNow.Height() *1.0 / dlgSaved.Height();
ClientToScreen(dlgNow);
CRect childSaved;
CWnd* pWnd = GetWindow(GW_CHILD);
while (pWnd)
{
childSaved = m_listRect.GetNext(pos);//依次获取子窗体的Rect
childSaved.left = LONG(dlgNow.left + (childSaved.left - dlgSaved.left)*x);//根据比例调整控件上下左右距离对话框的距离
childSaved.right = LONG(dlgNow.right + (childSaved.right - dlgSaved.right)*x);
childSaved.top = LONG(dlgNow.top + (childSaved.top - dlgSaved.top)*y);
childSaved.bottom = LONG(dlgNow.bottom + (childSaved.bottom - dlgSaved.bottom)*y);
ScreenToClient(childSaved);
pWnd->MoveWindow(childSaved);
pWnd = pWnd->GetNextWindow();
}
}
}