Same to the title.

解决方案 »

  1.   

    Such as: I have a ListBox with a id IDC_CTCI_MSG in the mainframe; how can I resize its size and position when I change the size of window? 
    I know that it can be done in OnSize, but I do not how to do it.
      

  2.   

    Could you tell me the details about it?
      

  3.   

    void CLogToolDlg::OnSize(UINT nType, int cx, int cy) 
    {
    CDialog::OnSize(nType, cx, cy);

    // set window size
        if(m_bOnSize)
        {
            GetDlgItem(IDC_FRAME_TOOLBAR)->MoveWindow(12, 0, cx - 30, 48, TRUE);
         }
        m_bOnSize = true;
    } /
      

  4.   

    Then, how to change the size of the control?
      

  5.   

    Let me see;
    Onset..名字不记得了这个函数,大概这样,你去MSDN查
      

  6.   

    GetDlgItem(IDC_FRAME_TOOLBAR)->MoveWindow(12, 0, cx - 30, 48, TRUE);
    這個就是改変control的大小和位置
      

  7.   

    Read references about MoveWindow() in MSDN.
      

  8.   

    给个例子。在OnSize函数中:
    CWnd *pwnd;
    CRect rect; pwnd=(CWnd *)GetDlgItem(IDC_RICHEDIT);
    if(pwnd==NULL)return;
    pwnd->GetWindowRect(&rect);
    ScreenToClient(&rect);
    rect.left=cx-20-200;
    rect.right=cx-20;
    rect.bottom=cy-50;
    pwnd->MoveWindow(&rect,TRUE);