If I ask you what time it is, and you say "It's 10 am", you're saying "10 hours have past since midnight".
Assuming you're right, and the TimeSpan class represents it as "10 AM to Midnight", then the TimeSpan class is implemented stupidly. Why then is the "Day 4 = 20 Hours", correct? According to what you said, that should be 4 hours.
Time is not "Until midnight". It's "Time elapsed".
Okay, stop thinking that your computer and the rest of us are out to mess with your mind. Let's take this from a none computer perspective and that should make things simpler - imagine you're 7 years old and it's 10 O'Clock on Christmas Eve. How many hours are there until Christmas Day starts? Now, suppose you're told that you can't open your presents until 4PM on Christmas Day. How many hours do you have to wait from the 10 O'Clock time until you can open your presents?
I don't think the implementation is wrong at all. On the contrary, it seems that your comprehension of the mathematics is what is wrong. If you are interested in computing an elapsed period of time, then that is exactly what is happening.
Take this for example. If you started the clock at 10AM yesterday and stopped it at 10AM today then a total of 24 hours has passed. Yes? The 24 hours is easily broken down in to 10 hours TODAY and 14 hours YESTERDAY. So a time which has elapsed takes the last fraction of the day your started and the first fraction of the day you finished.
I see you got it now. This was the reply I was writing to your deleted post.
How many hours are there between Mon 11:00pm and Tue 2:00am? 3, right?
Even though I said 11:00pm (which is the 23rd hour of the day), there's only one hour left in that day. THAT's the start of the time interval. So you end up with 1 hr left on Mon and 2 hours elapsed on Tue, giving us a total of 3 hours.
Yes. But wouldn't you do the same when computing a time interval? For the first day, you'd count the hours left (not elapsed) and for all successive days you'd count the hours elapsed, right? Hence, Mon 10pm to Tue 1am would be a time interval of 3 hours, right?
The TimeSpan isn't counting forward or backward from any specific time.
It is representing (in this case) the elapsed time from one DateTime to another.
It has no concept of forward from "10 am".
If you used an hourglass to count time from 10 am Aug 11 until 8pm Aug 14, you would just be turning the glass over for the 82nd time at the 8pm Aug 14. The TimeSpan is just representing the amount of sand that flowed through neck of the hourglass (with much more precision than counting each grain of sand!!)
It is a signed difference.
If you did the subtraction in the other order it would return -82 hours.
It is just a counter.
var TimelineStart = new DateTime(2015, 08, 11, 10, 00, 00);
var TimelineEnd = new DateTime(2015, 08, 14, 20, 00, 00);
TimeSpan delta = TimelineEnd - TimelineStart;
I have a form and want to display formatted text. I use a RichTextBox control. But I want windows message such as mouse clicks on the text to be handled by the parent form. So I disable the control. But that changes the background colour to grey, which is unacceptable as I want to set the background colour. Okay, so I override the WndProc method of the RichTextBox and use SendMessage to send messages such as mouse double click to the parent. That works, the form WndProc DOES receive the double click. But, the form's handler for a mouse double click is not invoked. Why is this? Does the system invoke Form event handlers instead of WndProc?
Note that the mouse bouble click message includs the client position in the lParam arg. I changed that from the location in the RichTextBox to the location in the parent form.
The problem is how to make a RichTextBox transparent to mouse events, so that it does no more than draw text on screen. Disabling the richtextbox sets a fixed background colour, which is not what I want.
The solution is to handle mouse events from the richeditbox in the form. Then in each event handler call Form.OnXXXXXX method e.g. Form.OnDoubleClick().
This code is just a prototype and describes the basic concept of notify message handling, it's no matter you implement it in C++ or C#. The notify message handling works similar in either C#.NET or C++ MFC. The main post of this post is the concept.
Sadly I don't think it does do what I need. Basically I want the RichTextBox to display text, with the correct font, bold, background colour, etc, but to be transparent to mouse events such as double click.
I am able to intercept mouse double clicks in a class derived from RichTextBox, and SendMessage them to the parent form. They are passed in to the parent form WndProc. But for some reason they do not invoke the MouseDoubleClick event handler. I tried overriding the Form.WndProc, but could not invoke MouseDoubleClick, for reasons I understand.
Surely, because in Win32API, to be able to handle control's messages in parent window you have to send and process notification messages. For example, if you need to process MouseDblClick message outside the RichEditCtrl, first you have to handle this message in RichEditCtrl window class by posting WM_NOTIFY message and then process the WM_NOTIFY in the parent window as just I have shown in my reply.
I made a function of having a Form Designer software.
In this software, I use this namespace:System.Drawing.Design.
I use the following code in my program is designed .to Program run A pop-up It is designed to form.
Now I have a problem: How can The program Run time Right click It is designed to form A pop-up with a menu.
DesignSurface surface = new DesignSurface();
Control view = (Control)surface.View;
view.Dock = DockStyle.Fill;
toolBoxService = new DemoToolboxService();
toolBoxService.ToolBox = new ListBox();
toolBoxService.ToolBox.Dock = DockStyle.Fill;
IServiceContainer container = surface.GetService(typeof(IServiceContainer)) as IServiceContainer;
if (container != null)