Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Scroll drawn GDI in custom control

Hey guys, I need some help :(

So I have a Custom Control :

PHP Code

<?php 
Public Class RDrawing
    Inherits Control

End 
Class 

And I draw a very large object (It's not really this large)

PHP Code

<?php 
Public Class RDrawing
    Inherits Control

    
Protected Overrides Sub OnPaint(e As PaintEventArgs)
        
MyBase.OnPaint(e)
        
e.Graphics.FillRectangle(Brushes.Red, 10, 10, 1000, 1000)
    
End Sub
End 
Class 

How could I get a scroll bar in order to scroll though the drawn graphics?
Note: The Control will be set at a specified size, ex: (100, 100) <--- Not big enough to see all the drawn graphics, In my case I might need drawn text so I can't resize the drawn graphics.

Thanks ~VmX5.
Either add the v/h scrollbar control as a child control or emulate one yourself with hit-testing.
Draw everything on a bitmap.
Then, clip it to a rectangle which corresponds to your scroll bars and control width ie. the area which you want to show.
FUrther, clip the graphics of your control to the ClientRectangle of the control to avoid unnecessary drawing.
Then draw that bitmap at a location (-x,-y) where x and y are values of the scrollbars. Do this everytime the user scrolls.
(Apr 4, 2017 09:27 PM)hfTP54 Wrote:  Either add the v/h scrollbar control as a child control or emulate one yourself with hit-testing.
Draw everything on a bitmap.
Then, clip it to a rectangle which corresponds to your scroll bars and control width ie. the area which you want to show.
FUrther, clip the graphics of your control to the ClientRectangle of the control to avoid unnecessary drawing.
Then draw that bitmap at a location (-x,-y) where x and y are values of the scrollbars. Do this everytime the user scrolls.

Thanks for the reply, I'll try it out and post back with results soon (Tmrw probs)
I often add a dynamic Y value for my controls and then write a custom scrollbar for this.
Put a panel control with AutoScroll = true; as UserControl container.

Example: https://hackforums.net/showthread.php?tid=5458100


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by ๖ۣۜMephobiaNov 14, 2025 07:54 PM 171 21,480 Nov 14, 2025 07:54 PM
Last Post: ProxyLand
[C#] by ZettabitMar 5, 2023 12:30 AM 7 1,162 Mar 5, 2023 12:30 AM
Last Post: NULL STERN
[.NET] by QuobiAug 6, 2022 02:23 PM 0 407 Aug 6, 2022 02:23 PM
Last Post: Quobi