Modify Scrollbar values

Olivier

Member
Licensed User
Longtime User
Hello,
In a programme, I display a large image with scrollbar. I have a button to view this image in small size. If I make a click to this small image I want to change the scrollbar value to display the portion on the large image corresponding to the small image position click.
For the desktop version I can use a Hscroll and Vscroll objects to keep the scrollbar property HorizontalScroll and VerticalScroll. But for the device it does not work. My question is how is it possible the modifiy the scrollbar position without use an Vscroll and Hscroll object ?

Best regard,
Olivier
 

Olivier

Member
Licensed User
Longtime User
Hello,
In the desktop I can define Vscroll and Hscroll like :

pnl1HScrollobj.Value=pnl1obj.GetProperty("HorizontalScroll")
pnl1VScrollobj.Value=pnl1obj.GetProperty("VerticalScroll")
on the click event on the small image I put :

Sub Image2MouseDown_NewEvent
o.Value=Image2MouseDown.Data
x0=o.GetProperty("X")
y0=o.GetProperty("Y")
Xraport = Int(Image1.Width / Preview.IMAGEPRE.Width)
Yraport = Int(Image1.Height / Preview.IMAGEPRE.Height)
pnl1HScrollobj.SetProperty("Value",x0 * XRaport)
pnl1VScrollobj.SetProperty("Value",y0 * YRaport)
PREVIEW.PREVIEW.Close
End Sub

With this code I can move the scrollbar to place correctly the position corresponding to the click event. But with the device the properties Horizontalscroll and Verticalscroll are not work. So I try to modify the scroll bar position with the AutoScrollPosition method:
pnl1obj.SetProperty("AutoScrollPosition",points(Xraport,Yraport))
But this method need points variables.....
I send you and sample.

Best regards,
Olivier
 

agraham

Expert
Licensed User
Longtime User
I'm afraid that is not possible on the device. The implementation of Panel on the device is different to that on the desktop and the scrollbars are not visible to .NET code. One way of doing what you want is to add and control your own scrollbars from ControlsEx, make the Image control on the panel the same size as the picture and move the required part of the Image into view using negative values for its' Top and Left properties. If Klaus reads this he may have a better solution.

Why are you using AddObject to add things at runtime? If you added them with Tools -> AddObject the IDE would know about them and give you Intellisense help for them.
 

klaus

Expert
Licensed User
Longtime User
I would suggest you to have a look at the http://www.b4x.com/forum/tutorials/5191-graphics-tutorial.html

In the chapter 'Show bitmap' you have an example of showing a bitmap bigger than the screen with 2 ScrollBars objects from the ControlsEx library.
The part of the image is directly copied onto the background of the form.

You can directly use the form's mouse event routines.

With the coordinates of your Form2 you can calculate the values for the scrollbars.
It works on both Desktop and Device.

Best regards.
 

Olivier

Member
Licensed User
Longtime User
Hello,
Thanks.
I put the object in the runtime because when i need the copy/paste a part on source to an other, for me is more easy. But, of course i can't use the interactive help...
Do you know how I can use the property AutoScrollPosition ?
I see with the controlInfo, it is possible :

AutoScrollPosition Gets or sets the location of the auto-scroll position. (Inherited from ScrollableControl.)

But The probleme is how to define variables with type point. I put a link for this property definition.

ScrollableControl.AutoScrollPosition Property (System.Windows.Forms)

Best regards,
Olivier
 

agraham

Expert
Licensed User
Longtime User
B4X:
[COLOR="green"]' making a Point is complicated because the only constructor
' implemented in the Compact Framework takes two parameters[/COLOR]
Obj1.New1(False) [COLOR="green"]' an Object[/COLOR]
Args1.New1(2) [COLOR="green"]' an ObjectArray[/COLOR]
Args1.SetValue(0, 0, "System.Int32")[COLOR="green"] ' X[/COLOR]
Args1.SetValue(1, 0, "System.Int32") [COLOR="green"]' Y[/COLOR]
Obj1.CreateNew2("System.Drawing.Point" & Obj1.System_Drawing, Args1.Value)
[COLOR="green"]' once its created we can alter its properties if we need to [/COLOR]
Obj1.SetProperty("X", 23)
Obj1.SetProperty("Y", 46)
[COLOR="Green"]' We can look what it is[/COLOR]
Msgbox(Obj1.RunMethod("ToString"))
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Here you have two solutions with objects from the ControlsEx and the ImageLibEx libraries based on the 'ShowBitmap' example from the Graphics Tutorial.

On the preview form the image ratio is maintained.

ShowBitmapNew is similar to your example.
In ShowBitmapNew1 you see on the preview form the part of the image that will be shown on the main form.

Best regards.
 

Attachments

  • ShowBitmapNew.sbp
    4.8 KB · Views: 206
  • ShowBitmapNew1.sbp
    5.9 KB · Views: 208
Last edited:

Olivier

Member
Licensed User
Longtime User
Hello,
Thank a lot. I try this samples. For the making point i don't kwon to past the object to the funcion. Normaly i use Borland c++. Do you kwon if is possible to make lib with this product ?

Best regards,
Olivier
 

Olivier

Member
Licensed User
Longtime User
Hello,
Yes I try whi the obj1.value but I have an error:

pnl1obj.SetProperty("AutoScrollPosition",Obj1.Value)
Error:description:
Object of type 'System.String' cannot be converted tp type 'System.Drawing.Point'


Thank for the link. I have the Borland developper studio 2006 with an C# compiler. Do you think i can make lib ?
Thanks,
Olivier
 

agraham

Expert
Licensed User
Longtime User
You should use SetProperty2 for objects, SetProperty assumes a String value.

I thought that the Borland 2006 products were no longer (legally) obtainable. I don't know if they supported Compact Framework development or not. You really need to be able to target Compact Framework 2.0 to make Basic4ppc libraries.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…