Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Can scrollbars be hidden when in Pan Layout mode?

Hi team

I'm using an SRP picture to create a 28x28 px preview swatch, based on where the user clicks within another SRP Picture. This all works perfectly using the ImageOffset property now.

The user also wants to optionally create a swatch from a single pixel and the only way I could see to achieve this was to Zoom in on the relevant pixel. This works pretty well using Layout, Zoom and ScrollPos, except that then the scrollbars also appear, which means I have to resize the preview swatch and it looks a bit messy.

Can the scrollbars be hidden when Layout = Pan, or alternately is there a way I can "fill" the SRP Picture preview control with a pixel from another image, which would be even better?

TIA

Comments

  • There is no property for disabling scrollbars. If it's just a single pixel, though, would it be sufficient to set the BackgroundColor property of the picture control to that pixels color?
  • Hi Kevin

    Yep that sounds excellent! Is there a way to determine the rgb colour values for the selected pixel within an image?
  • edited March 2019
    Perhaps Kevin knows of a better solution, but Windows Paint has a color picker tool, which provides you with the RGB values for a selected color within an image. You can find a quick how-to here.

    I see now that procedural method of doing so seems to be what was requested.
  • edited March 2019
    Actually, what if you set the Layout to Clip, Zoom to set the zoom level, and use ImageOffset to position the image where you want it?

    I know the documentation for the Zoom property says it only words with the Pan layout, but looking at the code, I don't think it cares at all. Worth a shot.
  • Hi Daniel

    Thanks for the feedback. The colour value for the pixel isn't for me, it's so I can then preview the 28x28 swatch that will subsequently be created for the end user, within the same form. The zoom workaround is not 100% accurate, but is pretty close - but the "real" colour would be perfect.
  • Hi Kevin

    I would have been good, but Zoom doesn't seem to do anything when Layout = Clip for me.
    I should have also mentioned the SRP Picture control is 3.0.7
  • Sadly, you are correct. The Zoom property doesn't care what the layout is, but the rendering engine does. If you need a solution now, the only option I see is to leverage the Win32 API. On the OnZoom event, you'd have to use the HANDLE property to get the control handle, GetWindow to get the correct child control, SetWindowLong to update the style bits to turn off the scroll bars, and SetWindowPos to force the control to redraw itself without those scrollbars. It's pretty involved.

    I'll make a note to add properties to allow you to disable scrollbars, but it will be several weeks due to my workload before such a feature would be made a available.
  • edited March 2019
    Hi Kevin

    No problem - the scrollbars can remain for now, it's just a visual thing. The colour isn't 100% representative in that it seems to blue a bit with surrounding pixels, but it should be good enough - until similarly if i get time I'll add a method to our .NET library to get the rgb from an image + pixel position and use the BackColor property you mentioned.

    p.s. with regard to the more common scenario of cutting out a swatch from an image, the imageoffset property worked liked a charm, so thanks for including all this functionality out of the box.
  • Hi Kevin

    Thanks again for your quick responses. I've implemented this now and the swatches are being created pretty-much as per the preview (via setting the zoom property). If you could add an option to hide the scrollbars sometime that would be great.

    An alternate suggestion would be to add a GetPixel(x,y) or similar method which could return the colour of the pixel. This would have allowed me to just set the background as you suggested above, and means the preview would be 100% representative vs the ultimate swatch that gets created.
Sign In or Register to comment.