1
A
回答
1
這裏的C函數來做到這一點:
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;
}
相關問題
- 1. 獲取控件的寬度ASP.NET
- 2. 獲取未設置寬度的控件寬度
- 3. 的Win32 C++:如何獲得在TreeView控件
- 4. 如何獲取javafx.scene.text.Text控件的寬度和高度?
- 5. 如何獲取WPF中摺疊控件的寬度/高度?
- 6. 如何獲取圖像控件的寬度和高度
- 7. Win32 TreeView AfterSelection
- 8. Win32創建TreeView
- 9. UI控件寬度
- 10. 獲取System.Drawing.Font寬度?
- 11. 獲取appwidget寬度
- 12. 獲取網格控件中某列的寬度C#
- 13. 獲取VB.net中的字體寬度而不測量控件?
- 14. 獲取高度和寬度
- 15. 獲取小部件的寬度
- 16. Win32編輯控件的默認高度
- 17. 獲取DataGrid的寬度
- 18. 獲取ComboBoxItem的寬度
- 19. 獲取ImageView的寬度
- 20. 獲取Monotouch.Dialog UIViewElement的寬度?
- 21. 獲取UIBarButtonSystemItem的寬度
- 22. TreeView控件
- 23. TreeView中的WPF RichTextBox的拉伸寬度
- 24. 從文件中獲取標籤寬度
- 25. 獲取圖像的寬度和高度
- 26. 獲取文檔的寬度和高度
- 27. 如何獲取Canvas的寬度/高度?
- 28. 獲取圖像寬度高度的JavaScript
- 29. 獲取UIElement的高度和寬度?
- 30. 獲取MainWindow的位置/寬度/高度