//.h
private:
typedef struct Rate//控件位置占比,ID,
{
CWnd *pWndItem;
CRect rc;
UINT uid;
double d_l;
double d_t;
double d_r;
double d_b;
Rate()
{
pWndItem=NULL;
rc.SetRect(0,0,0,0);
uid=0;
d_l=0.0;
d_t=0.0;
d_r=0.0;
d_b=0.0;
}
};
vector<Rate> itemRateVtr;
double cW;
double cH;
CRect rcDlg;
void initItemRect();
public:
virtual BOOL OnInitDialog();
/*******************************************************************************/
//.cpp
BOOL CXXDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
GetClientRect(rcDlg);
cW=(double)rcDlg.Width();
cH=(double)rcDlg.Height();
CWnd *pWndChild=GetWindow(GW_CHILD);
while (pWndChild)
{
Rate mRate;
mRate.pWndItem=pWndChild;
mRate.uid=GetWindowLong(pWndChild->GetSafeHwnd(),GWL_ID);
pWndChild->GetWindowRect(mRate.rc);
ScreenToClient(mRate.rc);
mRate.d_l=mRate.rc.left/ cW;
mRate.d_t=mRate.rc.top/ cH;
mRate.d_r=mRate.rc.right/ cW;
对话框改变大小保持控件比例
于 2024-07-30 16:09:21 首次发布

最低0.47元/天 解锁文章
1127

被折叠的 条评论
为什么被折叠?



