Board index » cppbuilder » ListView1: How to get hide the horizontal scrollbar?

ListView1: How to get hide the horizontal scrollbar?


2007-01-06 06:35:51 AM
cppbuilder46
How to get hide the horizontal scrollbar in ListView1?
Is there a ListView1->HScrollBar->Visible = false;
 
 

Re:ListView1: How to get hide the horizontal scrollbar?

"Jeff" < XXXX@XXXXX.COM >wrote in message
Quote
How to get hide the horizontal scrollbar in ListView1?
You can try using the ShowScrollBar() function, ie:
ShowScrollBar(ListView1->Handle, SB_HORZ, FALSE);
Not that it does not work for most view styles, though.
Alternatively, try using Get/SetWindowLong() to remove the WS_HSCROLL
style, ie:
LONG style = GetWindowLong(ListView1->Handle, GWL_STYLE);
if( (style & WS_HSCROLL) != 0 )
SetWindowLong(ListView1->Handle, GWL_STYLE, style &
~WS_HSCROLL);
Or to specify the LVS_NOSCROLL style, ie:
LONG style = GetWindowLong(ListView1->Handle, GWL_STYLE);
SetWindowLong(ListView1->Handle, GWL_STYLE, style | LVS_NOSCROLL);
Quote
Is there a ListView1->HScrollBar->Visible = false;
No.
Gambit
 

Re:ListView1: How to get hide the horizontal scrollbar?

"Jeff" < XXXX@XXXXX.COM >wrote:
Quote

How to get hide the horizontal scrollbar in ListView1?
You need to process it's WM_NCCALCSIZE message. This can be
accomplished by subclassing it's WindowProc or by subclassing
the control and overriding it's WndProc method or subclass
the control and add a message map (message handler) for
WM_NCCALCSIZE. For example, to subclass the WindowProc:
private: // User declarations
TWndMethod OldWndProc;
void __fastcall NewWndProc( TMessage &Message );
public: // User declarations
__fastcall ~TForm1();
//-------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
OldWndProc = ListView1->WindowProc;
ListView1->WindowProc = NewWndProc;
}
//-------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
ListView1->WindowProc = OldWndProc;
}
//-------------------------------------------------------------
void __fastcall TForm1::NewWndProc( TMessage &Message )
{
if( Message.Msg == WM_NCCALCSIZE )
{
LONG Style = ::GetWindowLong( ListView1->Handle, GWL_STYLE );
if( Style & WS_HSCROLL )
{
::SetWindowLong( ListView1->Handle, GWL_STYLE, Style & ~WS_HSCROLL );
}
}
OldWndProc( Message );
}
//-------------------------------------------------------------
Quote
Is there a ListView1->HScrollBar->Visible = false;
No, but if you derive your own component you could add that.
~ JD
 

{smallsort}

Re:ListView1: How to get hide the horizontal scrollbar?

Thanks Gambit and JD. Both work.
Gambit, where do you place
ShowScrollBar(ListView1->Handle, SB_HORZ, FALSE);
in your code?
 

Re:ListView1: How to get hide the horizontal scrollbar?

"Jeff" < XXXX@XXXXX.COM >wrote in message
Quote
Gambit, where do you place
ShowScrollBar(ListView1->Handle, SB_HORZ, FALSE);
in your code?
Anywhere you want.
Gambit