CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 1999
    Posts
    32

    Resizing CTabCtrl in a CFormView

    Hi!

    I have a CTabCtrl in a CFormView. When user resizes the view I want to resize CTabCtrl to fit in view.

    How can I do this?

    Regards
    Joacim

  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: Resizing CTabCtrl in a CFormView

    Add a handler in your formview for WM_SIZE, when WM_SIZE is called the window has been sized and you can adjust your tacctrl accordingly.

    ex:
    void ExplorerView::OnSize(UINT nType, int cx, int cy)
    {
    OLIFormView::OnSize(nType, cx, cy);
    if (tabCtrl.GetSafeHwnd()) // On size can be called before your tabCtrl is subclassed
    {

    tabCtrl.MoveWindow(5,5, cx - 10, cy - 10);
    }



  3. #3
    Join Date
    Apr 1999
    Posts
    32

    Re: Resizing CTabCtrl in a CFormView

    Hi!
    My question was a little missleading......

    I use the ResourceEditor to place tabctrl in the form and have some space above tabctrl. When I use your code it takes all the screen.
    How can I keep the upper-left corner fixed and change position of lower-right corner?

    Thanks anyway for your code!

    Regards
    Joacim

  4. #4
    Join Date
    May 1999
    Posts
    667

    Re: Resizing CTabCtrl in a CFormView

    void ExplorerView::OnSize(UINT nType, int cx, int cy)
    {
    CFormView::OnSize(nType, cx, cy);
    CRect rc;
    tabCtrl.GetWindowRect(rc); // Position in Screnn units
    ScreenToClient(rc); // convert to client units
    if (tabCtrl.GetSafeHwnd()) // On size can be called before your tabCtrl is subclassed
    {

    // this holds upper left to a specific pos if you need to keep right side
    // save original window rect (both tabCtrl & dialog) in OnInitDialog
    // & then compare right/bottom margin gap & set set gap here
    tabCtrl.MoveWindow(rc.left,rc.top, cx - 10, cy - 10);
    }

    HTH,
    Chris


  5. #5
    Guest

    Re: Resizing CTabCtrl in a CFormView

    void CFormTestView::OnSize(UINT nType,int cx,int cy)
    {
    CFormView::OnSize(nType,cx,cy);

    CWnd* pWnd=GetDlgItem(IDC_TAB1) // get tab control
    if (pWnd) // make sure the tab control has already been created (possible it hasn't)
    {
    CRect rect;
    pWnd->GetWindowRect(rect); // get position of tab control relative to the upper left corner of the screen
    ScreenToClient(rect); // translate tab position relative to the upper left corner of the view
    rect.right=cx-(rect.left*2); // make right hand margin betwee the tab and frame the same size as the left hand margin.
    // leave the vertical and left hand placement alone. You can perform what ever calculations
    // to determine new position here.
    pWnd->MoveWindow(rect); // Move the tab control to it's new position
    }
    }


  6. #6
    Join Date
    Apr 1999
    Posts
    32

    Re: Resizing CTabCtrl in a CFormView

    Thanks, it work fine after some small changes.
    I did this changes:
    [ccode]
    rect.right = cx-rect.left;
    rect.bottom = cy-10;
    [ccode]

    Regards
    Joacim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured