Manual Horizontal Scroll Bars

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Russell Mason
Version: 4.0.0233
Avatar
Hi

I'm doing a Diff control (actually based on your Diff Text demo app).

I want to be able to sync the horizontal scroll bars in the same way you have the vertical scroll bars.

In a previous post by someone else, 'Overriding scrollbars' 07/11/2006 06:57, you say this is complex and not available through public methods, i.e FirstVisibleX seems to be in pixels rather than characters. You also say this was going to change as part of the version 4 implementation.

Can you give any advice or an example of what you may have implemented in 4.0 to help?

Thanks
Russell Mason

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
FirstVisibleX is still pixel-based and has to be since various fonts have different character widths. For example 'w' is much wider than an 'i' in most fonts.

However yes, v4.0 does allow you to custom render the scrollbars. You would simply create a class that inherits our VisualStudio2005SyntaxEditorRenderer and override some of the methods like DrawScrollBarBackground, DrawScrollBarButton, and DrawScrollBarThumb. That way you can render it by calling your other rendering procedures from these methods.

Then you set your renderer class to the SyntaxEditor.Renderer property.


Actipro Software Support

Posted 13 years ago by Russell Mason
Avatar
Hi

That seems more about the scroll bar style. I think what I need to know is how many pixels the longest line is and use the existing scrollbar Maximum but on an external scrollbar (as you have with the vertical scroll bar in the demo). The thing is that the longest line may or may not have all sorts of formatting, bold, large etc, so I don't think I can just do a simple measure string type calculation.

How do you currently calculate the scrollbar Maximum value? Basically that is all I need for both source and destination text and then I could use the longest on both.

Alternatively if I did override the rendering has the Maximum value been caluculated at this point? I could then just use that value and not render the scroll bar at all (or would that leave a black space where the scroll bar would have been?).

Thanks
Rusell Mason
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We do have properties but they are currently internal. I've exposed them on EditorView for the next maintenance release:
Added the HorizontalScrollBarMaximum and VerticalScrollBarMaximum properties to the EditorView class.

If you do the custom rendering, you will still be using our ScrollBar control but you will be rendering it. So you are simply rendering the background (barrel), buttons (up/down or left/right), and the thumb. Our Draw methods tell you the bounds for each element so you just draw in those and it will look appropriate. You don't even need to worry about max values that way. Also it will hide the scrollbars if they are not being used if you have the property on SyntaxEditor configured to do that.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 9 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.