Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990518
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:30:14+00:00 2026-05-20T06:30:14+00:00

The Win32 TreeView control does not have a built-in message/macro to get its (scrollable)

  • 0

The Win32 TreeView control does not have a built-in message/macro to get its (scrollable) width, e.g. if want to set the TreeView’s width so it won’t need to have a scrollbar.

How can this be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:30:14+00:00Added an answer on May 20, 2026 at 6:30 am

    Here’s a C function to do this:

    int TreeView_GetWidth(HWND hTreeWnd)
    {
        SCROLLINFO scrollInfo;
        SCROLLBARINFO scrollBarInfo;
    
        scrollInfo.cbSize = sizeof(scrollInfo);
        scrollInfo.fMask = SIF_RANGE;
    
        scrollBarInfo.cbSize = sizeof(scrollBarInfo);
    
        // To find the whole (scrollable) width of the tree control,
        // we determine the range of the scrollbar.
        // Unfortunately when a scrollbar isn't needed (and is invisible),
        // its range isn't zero (but rather 0 to 100),
        // so we need to specifically ignore it then.
        if (GetScrollInfo(hTreeWnd, SB_HORZ, &scrollInfo) &&
            GetScrollBarInfo(hTreeWnd, OBJID_HSCROLL, &scrollBarInfo))
        {
            // Only if the scrollbar is displayed
            if ((scrollBarInfo.rgstate[0] & STATE_SYSTEM_INVISIBLE) == 0)
            {
                int scrollBarWidth = GetSystemMetrics(SM_CXVSCROLL);
                // This is a hardcoded value to accomodate some extra pixels.
                // If you can find a cleaner way to account for them (e.g. through
                // some extra calls to GetSystemMetrics), please do so.
                // (Maybe less than 10 is also enough.)
                const int extra = 10;
    
                return (scrollInfo.nMax - scrollInfo.nMin) + scrollBarWidth + extra;
            }
        }
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In win32, how do I setup a callback mechanism for RichEdit I have not
I have successfully implemented this method of using the Win32 API to set the
I have read that Win32 will not allow remote invocation of a process that
In my C++ Win32 program I want to set the current Display Settings to
In Win32, is there any way to get a unique cpu cycle count or
What win32 calls can be used to detect key press events globally (not just
The Win32 GetTimeZoneInformation function returns your systems local time zone as set up in
Win32's CreateFile has FILE_FLAG_DELETE_ON_CLOSE , but I'm on Linux. I want to open a
win32 windows application and want to capture full screen and remove the border of
I have two Win32 API programs written in plain C: Program A and program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.