|
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!
|
|
|
|
|
I just solved the problem. it was the data type getting a rounding down error. You were right. Thanks for your help 
|
|
|
|
|
You're welcome
|
|
|
|
|
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.
|
|
|
|
|
Member 12929001 wrote: 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.
Good luck!
/ravi
|
|
|
|
|
|
And in addition to what Ravi says, posting the same "question" in multiple places doesn't get you a better answer: it just duplicates work and annoys people.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
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.
|
|
|
|
|
It states that Visual Studio Code supports only a "limited subset" of VS project types.
If you "guys" are going to succeed at working together, you better agree on a common IDE and source code manager / version control.
|
|
|
|
|
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.
|
|
|
|
|
While the mouse button is down, as far as the system is concerned, the window is still moving. I would look at setting a flag in the LocationChanged event to let you know that the window is moving, and then set the FormWindowState in the MouseUp event (and then resetting that flag too, of course).
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
I think the ResizeBegin and ResizeEnd events will help you. The naming is misleading as the purpose of these events is to indicate when the form is showing the resizing border. Click and hold on the form border or caption bar and the ResizeBegin event is raised. ResizeEnd is seen on release whether or not any resizing has occurred.
Here is a trivial (and annoying) modification to a form to make it maximise when it is moved without having changed it's size.
private Rectangle? lastBounds;
protected override void OnResizeBegin(EventArgs e) {
base.OnResizeBegin(e);
System.Diagnostics.Debug.Print("EVENT ResizeBegin");
lastBounds = Bounds;
}
protected override void OnResizeEnd(EventArgs e) {
base.OnResizeBegin(e);
System.Diagnostics.Debug.Print("EVENT ResizeEnd");
if (lastBounds.HasValue) {
Rectangle previous = lastBounds.Value;
if (previous != Bounds && previous.Size == Bounds.Size) {
WindowState = FormWindowState.Maximized;
}
lastBounds = null;
}
}
In your case it would be necessary to detect the System.Windows.Forms.Screen containing the form in ResizeBegin and test for the desired destination Screen in ResizeEnd.
Alan.
|
|
|
|
|
Hi Mick, Alan
MouseUp and ResizeBegin/End works wonderfully. Thank you and Happy New Year.
|
|
|
|
|
I am attempting to simulate a mouse scroll on the desktop screen (Windows 10) and use the following:
SendMessage
(
GetDesktopWindow(),
WM_MOUSEWHEEL,
MakeWParam
(
LowWord((uint)MK_CONTROL),
HighWord
(
(uint)System.Windows.Forms.SystemInformation.MouseWheelScrollDelta
)
),
MakeLParam(0, 0)
);
const int WM_MOUSEWHEEL = 0x020A;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = false)]
static extern IntPtr GetDesktopWindow();
public static ushort LowWord(uint val)
{
return (ushort)val;
}
public static ushort HighWord(uint val)
{
return (ushort)(val >> 16);
}
private int MakeLParam(int p, int p_2)
{
return ((p_2 << 16) | (p & 0xFFFF));
}
public static uint MakeWParam(ushort low, ushort high)
{
return ((uint)high << 16) | (uint)low;
}
I get stuck because I do not know what to replace MK_CONTROL constant with, which is used to create a "low word." I've searched far and wide, but can't find anything as it relates to WM_MOUSEWHEEL .
I got the algorithm itself from this page, but it's all in C++...
Ultimately, I found this article, but it does not suggest it is a constant of any kind or how to use it with SendMessage method.
|
|
|
|
|
|
I am trying to understand the DbContext class by going to its definition and look at its members.
I am confused by what I saw in DbContext's definition, all of the methods in the DbContext class only have method signatures but no body (no implementation). Please see some of the methods below.
public virtual int SaveChanges();
public virtual DbSet Set(Type entityType);
Can someone please explain why all of the methods in the DbContext class look like they are abstract methods in an abstract class or methods in an interface. If these are concrete methods why don't they have implementations?
modified 31-Dec-16 12:28pm.
|
|
|
|
|
I don't know what you're looking at but those do have implementations. They're overridable, but they do have default implementations.
Examine the source for DbContext here[^].
|
|
|
|
|
Can you give us the whole structure of the class you are looking at? You are looking at wrong place I guess.
|
|
|
|
|
Hi, thank you for replying. I have a class that inherits from the DbContext class and to go to DbContext class definition, I placed the cursor on DbContext and pressed F12.
For the most part the definition of DbContext that I saw looked like the one shown in the link provided by Dave Kreskowiak above. The only problem is that none of the methods have implementations.
modified 30-Dec-16 12:11pm.
|
|
|
|
|
You're looking at the peek definition window. It shows the definition for the type or method symbol your cursor is currently on. It can not show implementation code it doesn't have access to like in an external DLL. In that case it only displays metadata.
|
|
|
|
|
hello Friend i have to know how to split below string in particular part. i have find this type of string in bar-code scanner as a input
I have a input
Hide Copy Code
0.1042.5140.7043.037.000.005.063.613.761.70.062
and i want output
0.104
2.51
40.70
43.0
37.00
0.00
5.0
63.6
13.7
61.7
0.06
please help me to solve this.
|
|
|
|
|
So you're looking at positional indexing. In other words, get the string from position 0 to 4 then 5 to 8 and so on. The string class has many features that could make this life easier for you but, if I were you, I would look at the Substring[^] command.
This space for rent
|
|
|
|
|
What is the basis or pattern for the split? You example appears random.
Peter Leow
http://www.peterleowblog.com/
https://www.amazon.com/author/peterleow
|
|
|
|
|
string s = "0.1042.5140.7043.037.000.005.063.613.761.70.062";
List<int> widths = new List<int>() { 5, 4, 5, 4, 5, 4, 3, 4, 4, 4, 4 };
int index = 0;
widths.ForEach( w => { Console.WriteLine( s.Substring( index, w ) ); index += w; } );
|
|
|
|
|
thanks a lot substring work for me.
|
|
|
|