@@ -71,21 +71,6 @@ void CMessageDlg::SetStandarnMessageIcon(StandardIcon standard_icon)
7171		SetMessageIcon (hIcon);
7272}
7373
74- void  CMessageDlg::SetInfoStaticSize (int  cx)
75- {
76-     if  (m_icon != NULL  && m_info_static.GetSafeHwnd () != NULL )
77-     {
78-         CRect rc_info{ m_rc_info };
79- 		// 设置Static控件水平位置,为图标腾出空间
80-         rc_info.left  = m_rc_info.left  + MESSAGE_DLG_ICON_SIZE + theApp.DPI (8 );
81-         if  (cx > 0 )
82-             rc_info.right  = cx;
83- 		// 设置Static控件的垂直位置
84- 		rc_info.MoveToY (rc_info.top  + MESSAGE_DLG_ICON_VERTIAL_MARGIN);
85-         m_info_static.MoveWindow (rc_info);
86-     }
87- }
88- 
8974void  CMessageDlg::DoDataExchange (CDataExchange* pDX)
9075{
9176	CBaseDialog::DoDataExchange (pDX);
@@ -133,31 +118,28 @@ BOOL CMessageDlg::OnInitDialog()
133118    // 设置图标的位置
134119    if  (m_icon != NULL )
135120    {
136- 		CRect rc_edit;
137-         m_message_edit.GetWindowRect (rc_edit);
121+ 		CRect rc_info = GetControlRect (&m_info_static);
122+ 		// 设置Static控件水平位置,为图标腾出空间
123+ 		rc_info.left  = rc_info.left  + MESSAGE_DLG_ICON_SIZE + theApp.DPI (8 );
124+ 		// 设置Static控件的垂直位置
125+ 		rc_info.MoveToY (rc_info.top  + MESSAGE_DLG_ICON_VERTIAL_MARGIN);
126+ 		m_info_static.MoveWindow (rc_info);
127+ 
128+ 		CRect rc_edit = GetControlRect (&m_message_edit);
138129		rc_edit.top  += (MESSAGE_DLG_ICON_VERTIAL_MARGIN * 2 );
139-         ScreenToClient (rc_edit);
140-         m_icon_pos.x  = rc_edit.left ;
141-         m_icon_pos.y  = (rc_edit.top  - MESSAGE_DLG_ICON_SIZE) / 2 ;
130+ 		m_icon_pos.x  = rc_edit.left ;
131+ 		m_icon_pos.y  = (rc_edit.top  - MESSAGE_DLG_ICON_SIZE) / 2 ;
142132		m_message_edit.MoveWindow (rc_edit);
143- 
144-         m_info_static.GetWindowRect (m_rc_info);
145-         ScreenToClient (m_rc_info);
146-         SetInfoStaticSize (0 );
147133    }
148134
149135	// 没有图标,且消息标题为空时,隐藏Static控件
150136	if  (m_icon == NULL  && m_info.IsEmpty ())
151137	{
152- 		CRect rc_edit;
153- 		m_message_edit.GetWindowRect (rc_edit);
154- 		ScreenToClient (rc_edit);
155- 		m_info_static.GetWindowRect (m_rc_info);
156- 		ScreenToClient (m_rc_info);
157- 		rc_edit.top  = m_rc_info.top ;
138+ 		CRect rc_info = GetControlRect (&m_info_static);
139+ 		CRect rc_edit = GetControlRect (&m_message_edit);
140+ 		rc_edit.top  = rc_info.top ;
158141		m_message_edit.MoveWindow (rc_edit);
159142		m_info_static.ShowWindow (SW_HIDE);
160- 
161143	}
162144
163145	return  TRUE ;  //  return TRUE unless you set the focus to a control
@@ -202,6 +184,21 @@ void CMessageDlg::OnSize(UINT nType, int cx, int cy)
202184{
203185    CBaseDialog::OnSize (nType, cx, cy);
204186
205-     //  TODO: 在此处添加消息处理程序代码
206-     SetInfoStaticSize (cx);
187+ 	if  (m_info_static.GetSafeHwnd () != NULL  && m_icon != NULL )
188+ 	{
189+ 		CRect rc_info = GetControlRect (&m_info_static);
190+ 		rc_info.right  = cx;
191+ 		m_info_static.MoveWindow (rc_info);
192+ 	}
193+ 	if  (m_message_edit.GetSafeHwnd () != NULL )
194+ 	{
195+ 		CRect rc_edit = GetControlRect (&m_message_edit);
196+ 		// 设置Edit控件的垂直位置
197+ 		CRect rc_ok = GetControlRect (IDOK);
198+ 		if  (!rc_ok.IsRectEmpty ())
199+ 		{
200+ 			rc_edit.bottom  = rc_ok.top  - theApp.DPI (6 );
201+ 			m_message_edit.MoveWindow (rc_edit);
202+ 		}
203+ 	}
207204}
0 commit comments