Hi, I'm creating a custom VScrollBar and I have problem getting the exact Y position of the thumb like the Windows.Forms.VScrollBar, I have searched online and I found some examples of custom scrollbars like:
The problem with these examples are that they don't get the exact top position of the thumb comparing to the windows scrollbar. I am getting a Top position that while scrolling becomes less than the real position
the problem is that the Y position I get is smaller than the position of the Windows Scrollbar.
I tested my custom scrollbar with the Windows scrollbar with the same Maximum, Minimum, LargeChange and SmallChange, and when I get a Y position of 45 the other has a Y position little bit bigger than 45. The difference between the Y positions gets bigger as a set the Maximum value bigger.
I would avoid the decimal type, what you need is either float or double, since ratio could be a very small number; decimal is fine for monetary amounts, not for arbitrary scaling. Have you ever looked at the actual values while debugging?
this is what is inside thumbSize. it works pretty well.
int trackHeight = (Height - (2 * topButton.Height));
int thumbHeight = (LargeChange / Maximum) * trackHeight;
I changed the values fromdecimal to float I'm still getting the same result. the thumb never reaches the bottom. I think there must be something else to add to the thumb position than I'm not adding.
If you can't reach the scroll's bottom, it means ratio is too small. As your math seems OK, I can imagine only two reasons:
1. a rounding down error, probably caused by a bad choice of data type (such as decimal only offering two fractional digits);
2. ThumbSize() returing too large a value; so please check and/or provide the exact code for that method.
Suggestion: take one example, note all the numbers, compare what they are (from logging or interactive debug session) with what they should be (manual calculation), you then should be able to see the error right away!
PS: ClientHeight isn't always the right value, e.g. when a HScrollBar appears, it reduces the VScrollBar's height!
Hello those who are reading, I am a beginner in programmer and currently frequent in C#. I am working on building a cross-platform mobile application and I am confused on what to do. I know what I want my application to do and I am done with making the sketches and connecting them. Now I do not know how to proceed. ANY HELP/ADVICE WILL BE VERY APPRECIATED. THANK YOU.
I am working on building a cross-platform mobile application and I am confused on what to do.
That comes as no surprise. You've taken on a task that's challenging even for an experienced programmer! I suggest you instead focus on learning the basics of programming, select a target platform like Windows command line or Windows Forms, and eventually learn how to program for a mobile platform like iOS or Android. One step at a time.
I started working on a project with some guys who are using Visual Studio Code.
I've not much experience with it, but I'd like to use my VS 2015 as usual because there seems to be all kinds of features lacking from VSC that I use a lot. It seems to have no concept of namespaces, and I can write a class that doesn't exist yet and it won't turn red, etc...
I try to open the folder in Visual Studio 2015 by going to File -> Open Web Site and doing it that way, and then all hell breaks loose. I know it needs to make .sln and csproj which is fine, but Resharper races my CPU for like 5 minutes straight and then there is no project resources area so even main VS has absolutely no idea about the namespaces, classes, etc...
Does anyone know how I could use VS to work on this C# .NET Core project, alternatively if I can get some VS features in VSC? This is sort of baffling my mind how challenging opening this C# project has become. Regards.
How do I implement a Window app to maximize when user moves the window from one display monitor to another. When the move occurs LocationChanged event is triggered and the window state becomes Normal.
I tried this.WindowState=FormWindowState.Maximized in the LocationChanged handler. However, the window does not maximized. Likely because it triggered circular reference. I had also implemented a module Boolean variable to avoid this. However, the window never maximized.
What is the proper way to implement this?
Thank you in advance for your response.
Last Visit: 31-Dec-99 19:00 Last Update: 3-Mar-24 22:20