ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Pan
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

John

USA
94 Posts

Posted - Mar 18 2012 :  14:44:23  Show Profile  Reply
Hello

I have a SpeedButton that sets ImageEnView1.MouseInteract := [miScroll]. I would like to enable this SpeedButton only when scrolling is a viable alternative, i.e. when there is either a visible horizontal and/or vertical scroll bar associated with ImageEnView1.

To accomplish the above I need to be able to determine (via code) whether the horizontal and/or vertical scroll bars are visible. Unfortunately, I have been unable to find such a property/function. Does such a property/function exist?

Suggestions?

TIA

John

fab

1310 Posts

Posted - Mar 19 2012 :  00:25:55  Show Profile  Reply
Hello,
this code could help you:
var
  sbi:TSCROLLBARINFO;
begin
  sbi.cbSize := sizeof(TSCROLLBARINFO);

  // check for horizontal scrollbar
  GetScrollBarInfo(ImageEnView1.Handle, OBJID_HSCROLL, sbi);
  if (sbi.rgstate[0] and STATE_SYSTEM_INVISIBLE) = 0 then
    ShowMessage('Horizontal scrollbar visible');

  // check for vertical scrollbar
  GetScrollBarInfo(ImageEnView1.Handle, OBJID_VSCROLL, sbi);
  if (sbi.rgstate[0] and STATE_SYSTEM_INVISIBLE) = 0 then
    ShowMessage('Vertical scrollbar visible');

end;
Go to Top of Page

John

USA
94 Posts

Posted - Mar 19 2012 :  13:30:02  Show Profile  Reply
Fabrizio

Thanks.

I have placed the code as a private procedure in two different forms, each having an ImageEnView1 component. Both ImageEnView1 components have the same properties set and the code works correctly in both forms. However, I get the following compiler error in one of the two forms. [DCC Warning] ViewXrays.pas(1118): W1012 Constant expression violates subrange bounds

Can you suggest why I would get this compiler error from only one of the two forms?

TIA

John
Go to Top of Page

fab

1310 Posts

Posted - Mar 20 2012 :  00:28:40  Show Profile  Reply
John,
unfortunately Delphi defines OBJID_HSCROLL = $FFFFFFFA, but GetScrollBarInfo is defined as:
Function GetScrollBarInfo(hwnd: HWND; idObject: Longint; var psbi: TScrollBarInfo): BOOL; stdcall;

So assigning $FFFFFFFA to Longint raises this warning. You could disable these warnings (for this piece of code) setting:

{$WARNINGS OFF} GetScrollBarInfo(ImageEnView1.Handle, OBJID_HSCROLL, sbi); {$WARNINGS ON}

and

{$WARNINGS OFF} GetScrollBarInfo(ImageEnView1.Handle, OBJID_VSCROLL, sbi); {$WARNINGS ON}

This should not happen with newer versions of Delphi.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: