Thread: Tab control: how to calculate a tab display area???

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Question Tab control: how to calculate a tab display area???

    Hello,

    in the tab control parent window procedure I usually do something like the
    following:

    Code:
    case WM_SIZE:
    
      MoveWindow(hTab, ....);
    
      RECT rc;
      GetClientRect(hTab, &rc);
    
      TabCtrl_AdjustRect(hTab, FALSE, &rc);
    
      // resizing windows displayed on the different tabs
      MoveWindow(hChild2, rc.left, rc.top, rc.right - rc.left, rc.bottom - 
    rc.top, TRUE);
      MoveWindow(hChild3, rc.left, rc.top, rc.right - rc.left, rc.bottom - 
    rc.top, TRUE);
      // ....
    
      return 0;

    This works for example using the following styles:

    1) WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS

    2) WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TCS_VERTICAL

    3) WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TCS_BUTTONS

    But it does not work with the following set of styles:

    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TCS_VERTICAL | TCS_BUTTONS

    ... in other words when using buttons (TCS_BUTTONS) and displaying them
    vertically (TCS_VERTICAL).

    Could anyone explain why this is happening???

    How do I get the display area in this case???


    Regards,
    Bob

  2. #2
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    I works for me with GetClientRect(hTab, ...)
    Why? Since the tab is behaving like a "client" for the child windows.
    Although...I recommend to use dialogs instead placing all the controls...so, you can only Show and Destroy the dialog instead of hiding the controls.
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    3
    Have you read my post?

    I'm saying that GetClientRect followed by a call to TabCtrl_AdjustRect does not return the correct client area (or display area) when the tab control styles include both TCS_BUTTONS and TCS_VERTICAL.


    Bob

  4. #4
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    Quote Originally Posted by SundayDeveloper View Post
    Have you read my post?

    I'm saying that GetClientRect followed by a call to TabCtrl_AdjustRect does not return the correct client area (or display area) when the tab control styles include both TCS_BUTTONS and TCS_VERTICAL.


    Bob
    And did you read my post? I'm saying that for me works correctly...so I guess you need calculate the buttons in the bottom by your self...I think is because the tab doesn't count in the RECT the bottom buttons tabs...I suppose that's why msdn says this:
    Remarks

    This message applies only to tab controls that are at the top. It does not apply to tab controls that are on the sides or bottom.
    But I'm sure you already know
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  5. #5
    Registered User
    Join Date
    Sep 2007
    Posts
    3
    I thought that saying "on my machine it works fine" was not allowed as an answer ...


    Bob

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calculate Point in Area
    By ilmarculin in forum C Programming
    Replies: 16
    Last Post: 04-07-2005, 07:03 AM
  2. tab control
    By tyouk in forum Windows Programming
    Replies: 6
    Last Post: 02-07-2005, 11:47 PM
  3. Need help with switch
    By 3kgt in forum C Programming
    Replies: 2
    Last Post: 02-26-2003, 12:43 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Using Tab control to change between dialogs
    By Eado in forum Windows Programming
    Replies: 2
    Last Post: 05-15-2002, 03:43 AM