Determine whether vertical scrollbar is visible

  • Thread starter Thread starter Alain Dekker
  • Start date Start date
A

Alain Dekker

Hi,

Got this code from Google, but it doesn't work:

//...
private const int WS_VSCROLL = 0x200000;
//...

//...
[DllImport("coredll.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int Index);
//...

//...
private static bool IsScrollbarVisible(IntPtr hWnd)
{
// Determines whether the vertical scrollbar is visible for the specified
control
bool bVisible = false;
int nMessage = WS_VSCROLL;
int nStyle = GetWindowLong(hWnd, nMessage);
bVisible = ((nStyle & nMessage) != 0);
return bVisible;
}
//...

//...
bVisible = IsScrollbarVisible(lstAccounts.Handle);
//...

Problem is that bVisible is always false, regardless of whether the vertical
scrollbar is actually displayed or not. nStyle is always 0 above.

This was programmed in VS2005 using the CF .NET v2.0 for Windows CE.

Thanks,
Alain
 
Thanks, I've tried a variant of that (used by the previous developer on
other forms so I guiess there's precedent) of starting a "LoadTimer" at the
end of the FormLoad event. This then does the rest of the GUI work
(including checks for the vertical scrollbar) and (I'm guessing) is
effectively the same as the FormShown event.

Works fine now.

Note that in VS 2005 and C# using .NET 2.0 (specifically the CF version),
there is no shown event for a System.Windows.Form control. Is this a new
form event? The list of events is:
Activated
Click, Closed, Closing, Deactivate, DoubleClick, EnabledChanged, GotFocus,
HelpRequested, KeyDown/Press/Up, Load, LostFocus, MouseDown/Move/Up, Paint,
ParentChanged, Resize, TextChanged, Validated, Validating

The idea of using a timer to complete loading seems reasonable to me.

Thanks again for the help and Merry Christmas.
Alain
 
thanks.

i have been wondering why my ancient suggestion doesn't get into the browser. i submitted long ago with minimal response and no reply.

any how, windows is just that a window ontop of GNU (unix) microkernels.
 
Back
Top