Click here to Skip to main content
15,914,780 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: modeless dialog in the client area of MDI-application Pin
David Crow20-Mar-07 5:15
David Crow20-Mar-07 5:15 
AnswerRe: modeless dialog in the client area of MDI-application Pin
Maximilien20-Mar-07 9:10
Maximilien20-Mar-07 9:10 
GeneralRe: modeless dialog in the client area of MDI-application Pin
Franken20-Mar-07 5:27
Franken20-Mar-07 5:27 
AnswerRe: modeless dialog in the client area of MDI-application Pin
Mark Salsbery20-Mar-07 9:20
Mark Salsbery20-Mar-07 9:20 
GeneralRe: modeless dialog in the client area of MDI-application Pin
Franken20-Mar-07 15:13
Franken20-Mar-07 15:13 
GeneralRe: modeless dialog in the client area of MDI-application Pin
Mark Salsbery20-Mar-07 16:15
Mark Salsbery20-Mar-07 16:15 
GeneralRe: modeless dialog in the client area of MDI-application Pin
Mark Salsbery20-Mar-07 16:20
Mark Salsbery20-Mar-07 16:20 
AnswerRe: modeless dialog in the client area of MDI-application Pin
David Crow20-Mar-07 10:03
David Crow20-Mar-07 10:03 
You could do something like:

BOOL CModelessDlg::OnInitDialog() 
{
    CDialog::OnInitDialog();
	
    CRect rc;
    GetWindowRect(rc);
    m_lWidth = rc.Width();
    m_lHeight = rc.Height();
 
    AfxGetMainWnd()->GetWindowRect(m_rcParent);
    
    return TRUE;
}
 
void CModelessDlg::OnMoving(UINT fwSide, LPRECT pRect) 
{
    CDialog::OnMoving(fwSide, pRect);
	
    // keep the child's left edge inside the parent's right edge
    pRect->left = min(pRect->left, m_rcParent.right - m_lWidth);
    // keep the child's left edge inside the parent's left edge
    pRect->left = max(pRect->left, m_rcParent.left);
 
    // keep the child's top edge inside the parent's bottom edge
    pRect->top  = min(pRect->top, m_rcParent.bottom - m_lHeight);
    // keep the child's top edge inside the parent's top edge
    pRect->top  = max(pRect->top, m_rcParent.top);
 
    // keep the child's right edge inside the parent's right edge
    pRect->right = min(pRect->right, m_rcParent.right);
    // keep the child's right edge inside the parent's left edge
    pRect->right = max(pRect->right, m_rcParent.left + m_lWidth);
    
    // keep the child's bottom edge inside the parent's bottom edge
    pRect->bottom = min(pRect->bottom, m_rcParent.bottom);
    // keep the child's bottom edge inside the parent's top edge
    pRect->bottom = max(pRect->bottom, m_rcParent.top + m_lHeight);
}
It works regardless of whether WS_POPUP or WS_CHILD is used. A parent can be specified or not.


"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

"Judge not by the eye but by the heart." - Native American Proverb


QuestionDisplay Problem [modified] Pin
baerten20-Mar-07 1:48
baerten20-Mar-07 1:48 
QuestionRe: Display Problem Pin
baerten20-Mar-07 3:04
baerten20-Mar-07 3:04 
QuestionMultiple CDC::SelectObject() Pin
PatrykDabrowski20-Mar-07 1:34
PatrykDabrowski20-Mar-07 1:34 
AnswerRe: Multiple CDC::SelectObject() Pin
CPallini20-Mar-07 1:39
mveCPallini20-Mar-07 1:39 
GeneralRe: Multiple CDC::SelectObject() Pin
PatrykDabrowski20-Mar-07 1:46
PatrykDabrowski20-Mar-07 1:46 
AnswerRe: Multiple CDC::SelectObject() Pin
pri_skit20-Mar-07 1:54
pri_skit20-Mar-07 1:54 
QuestionRe: Multiple CDC::SelectObject() Pin
PatrykDabrowski20-Mar-07 2:06
PatrykDabrowski20-Mar-07 2:06 
GeneralRe: Multiple CDC::SelectObject() Pin
Parthi_Appu20-Mar-07 2:24
Parthi_Appu20-Mar-07 2:24 
QuestionRe: Multiple CDC::SelectObject() Pin
PatrykDabrowski20-Mar-07 2:39
PatrykDabrowski20-Mar-07 2:39 
JokeRe: Multiple CDC::SelectObject() Pin
CPallini20-Mar-07 2:45
mveCPallini20-Mar-07 2:45 
GeneralRe: Multiple CDC::SelectObject() Pin
toxcct20-Mar-07 3:14
toxcct20-Mar-07 3:14 
GeneralRe: Multiple CDC::SelectObject() Pin
PatrykDabrowski20-Mar-07 3:19
PatrykDabrowski20-Mar-07 3:19 
GeneralRe: Multiple CDC::SelectObject() Pin
toxcct20-Mar-07 3:25
toxcct20-Mar-07 3:25 
GeneralRe: Multiple CDC::SelectObject() Pin
PatrykDabrowski20-Mar-07 3:47
PatrykDabrowski20-Mar-07 3:47 
GeneralRe: Multiple CDC::SelectObject() Pin
toxcct20-Mar-07 3:51
toxcct20-Mar-07 3:51 
AnswerRe: Multiple CDC::SelectObject() Pin
Parthi_Appu20-Mar-07 2:49
Parthi_Appu20-Mar-07 2:49 
QuestionMicrosoft Visual C++ Runtime Library Error Pin
Programm3r20-Mar-07 1:06
Programm3r20-Mar-07 1:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.