hello
How i can hide the Scrollbar from Listview?
i'am use following way.
procedure TSkinListView.HideScrollBars(Typ, Which: Integer);
var
ierect: TRect;
cxvs, cyvs: Integer;
iehrgn: HRGN;
begin
GetClientRect(Handle, ierect);
cxvs := GetSystemMetrics(SM_CXVSCROLL); //Get the system metrics - VERT
cyvs := GetSystemMetrics(SM_CYVSCROLL); //Get the system metrics - HORZ
if (Which = SB_HORZ) then
cxvs := 0; //Set VERT to zero when choosen HORZ
if (Which = SB_VERT) then
cyvs := 0; //Set HORZ to zero when choosen VERT
//Here we set the position of the window to the clientrect + the size of the scrollbars
SetWindowPos(Handle, 0, ierect.Left, ierect.Top, ierect.Right + cxvs, ierect.bottom + cyvs,
SWP_NOMOVE or SWP_NOZORDER);
//Her we modify the rect so the right part is subbed from the rect.
if (Which = SB_BOTH) and (Which = SB_HORZ) then
ierect.bottom := ierect.bottom - ierect.Top;
if (Which = SB_BOTH) and (Which = SB_VERT) then
ierect.Right := ierect.Right - ierect.Left;
//Just to be safe that the left/top corner is 0...
ierect.Top := 0;
ierect.Left := 0;
iehrgn := 0;
//The -2 is probably a border of some kind that we also need to remove. I could not find any good
//metrics that gave me an 2 as an answer. So insted we makes it static with -2.
if (Which = SB_BOTH) then
iehrgn := CreateRectRgn(ierect.Left, ierect.Top, ierect.Right - 2, ierect.bottom - 2);
if (Which = SB_HORZ) then
iehrgn := CreateRectRgn(ierect.Left, ierect.Top, ierect.Right, ierect.bottom - 2);
if (Which = SB_VERT) then
iehrgn := CreateRectRgn(ierect.Left, ierect.Top, ierect.Right - 2, ierect.bottom);
//After the range has been made we add it...
SetWindowRgn(Handle, iehrgn, True);
end;
That make Trouble if resize the window..
Any other Idea ?
greets
Emil,
Consider using a Region, to protect from the OS that automatically redraws all the virtual scrollbars from any window class.
But you must first check if they are visible or not, using something like this.
long skCheckScrollBar (IN HWND hWnd) {
// Check if the control's scrollbars are shown.
// Returns zero if (none, 1 if vertical, 2 if horizontal and 3 if both.
RECT rw = {0}, rc = {0};
long nRet = SCROLLBAR_NONE;
if (IsWindowVisible(hWnd)) { // 06-25-2015
GetWindowRect(hWnd, &rw);
GetClientRect(hWnd, &rc);
if (rc.right <= rw.right - rw.left - GetSystemMetrics(SM_CXVSCROLL)) { nRet = SCROLLBAR_VERT; }
if (rc.bottom <= rw.bottom - rw.top - GetSystemMetrics(SM_CXHSCROLL)) { nRet = nRet + SCROLLBAR_HORZ; }
}
return nRet;
}
Thank you..
I will check this.
the Trouble is that the Window is resize not the entire ListView, the width not Changed
if set the scrollbar on my way. to zero
greets