I cannot detect if the scrollbars of a form are visible.
Googleing the Internet shows that the code below should work. Everybody uses it:
function VertScrollBarVisible(WindowHandle: THandle): Boolean;
begin
Result:= (GetWindowlong(WindowHandle, GWL_STYLE) AND WS_VSCROLL) <> 0
end;
I call it like this:
procedure TFrmBaser.Button1Click(Sender: TObject);
begin
if VertScrollBarVisible(MainForm.Handle)
then Caption:= 'visible';
end;
It returns False all the time, even is the scrollbars are visible. They are made visible by some MDI child forms that I drag a bit out of screen.
Delphi 7, Win XP SP3, Themes on
This
shows that the form you are having problems with is a MDI parent form (
FormStyleisfsMDIForm).MDI parent forms are different from normal forms in that they create a special client window that fills the whole client area of the form, and which manages the MDI child windows / forms. The MDI client window will never be larger than the client area of its parent, so the parent form will never show scrollbars. This explains that the code in your question always returns false.
The scrollbars you see are part of the MDI client window. Modify your code to check the window style of the client window, its handle can be accessed with the
ClientHandleproperty of the MDI parent form:For more information about MDI at the Windows API level see About the Multiple Document Interface on MSDN.