Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Mar : Detect whether VScrollBar is visible in ComboBox?

www.cryer.info
Managed Newsgroup Archive

Detect whether VScrollBar is visible in ComboBox?

Subject:Detect whether VScrollBar is visible in ComboBox?
Posted by:"Dave Atkin" (sepultur..@optusnet.com.au)
Date:Sun, 20 Mar 2005 16:09:58

Hi everyone,

I'm subclassing a TCustomComboBox to display tabular info, using
TabbedTextOut. (a TTabComboBox).
With Win98 items can be right aligned against the tabstop by passing a
negative value in the TabArray.
I need to detect, in the DropDown event of the ComboBox, if a Vertical
ScrollBar will be visible so I can increase the DropDown width by the width
of the VScrollBar to stop clipping of the items captions that are right
aligned.

I thought this would work:

procedure TTabComboBox.DropDown(Sender: TObject);
var
    nScrollBarWidth: integer;
begin

    //get the width of a VScrollBar...
    nScrollBarWidth := GetSystemMetrics(SM_CXVSCROLL)

    //if VScrollBar is visible increase thedropdown width...
    if (GetWindowLong(Handle, GWL_STYLE) and WS_VSCROLL) <> 0 then
        Perform(CB_SETDROPPEDWIDTH, Abs(LongestTab) + nMargin, 0)
    else
        Perform(CB_SETDROPPEDWIDTH, Abs(LongestTab) + nScrollBarWidth +
nMargin, 0)
end;

but it doesn't!  The DropDownWidth is set from LongestTab OK, but the
GetWindowLong call always returns 0 whether the vertical ScrollBar is
visible or not.

Any pointers on how to do this would be greatly appreciated.
I'm using Delphi 6.240 and WIN 98SE.

Regards,
Dave Atkin

Replies:

www.cryer.info
Managed Newsgroup Archive