|
I think I found a bug in C#'s Rectangle. At least, it seems like an
inconsistency.
A Rectangle is defined as a combination of a Point (the top-left corner)
and a Size.
Let's say I have a Rectangle at (0,0) with a Size of 100x100.
If I call Rectangle.Top, it returns the Y-coordinate of the top of
the rectangle. Likewise, for Rectangle.Bottom, Rectangle.Left, and
Rectangle.Right. So, for this Rectangle, Top = 0, Left = 0, Bottom = 100,
and Right = 100. At least, according to the Rectangle class. But
if I call Rectangle.Contains(new Point(100,100)), this returns false.
Technically, it seems that Rectangle.Contains() is behaving correctly.
Logically, the rectangle's true bounds are (0,0) to (99,99). So
(100,100) isn't really in that rectangle. But I would argue that
Rectangle.Bottom and Rectangle.Right shouldn't be returning 100, either,
if they are returning the coordinate of the corresponding edge.
Either Rectangle.Contains() needs to be fixed, or Bottom and Right need to be fixed. I think the latter is more appropriate. Until then, I guess we need to deduct 1 from those properties.
|
|
|
|
|
Think Zero based Array (vector)!
<a TITLE="See my user info" href=http:
|
|
|
|
|
What about it? If you're suggesting that I have an off-by-one error in my head, I don't think so -- it would appear that Microsoft does. In fact, someone at Microsoft agrees:
Arun-
Thanks for your feedback!
You are right, the Rectangle version of these descriptions and the
Control version are both a little bit off in different ways.
I have passed your message on to a member of the test team for further
inquiry; he is investigating the behavior and will open a bug (or bugs)
based on what he finds.
Thanks again reporting this, and please continue to send us mail, should
you encounter behavior that seems curious (or other problems).
Seth Grossman
Microsoft Corp.
|
|
|
|
|
Note:
A rectangle under windows does not draw at the right or bottom of the rectangle. Therefore the bottom and right are not with in the rectangle (Bottom and Right are limits).
This is by design on the part of Microsoft and it does not matter if you are programing in C, C++, C#, VB, etc...
Trust in the code Luke. Yea right!
|
|
|
|
|
Okay... But also note that I'm not concerned with how a rectangle is drawn, just whether, in hyptothetical space, a point is in a rectangle or not.
If Bottom and Right are open limits by design, when are they actually used as such? I'd expect there would be a lot more code that does (this.Bottom - 1), but perhaps it's for lazy programmers who want to do (Bottom - Top), rather than (Bottom - Top + 1).
Either way, I'd argue that "Gets the y-coordinate of the bottom edge of this Rectangle structure" is inconsistent, especially since Top is described as "Gets the y-coordinate of the top edge of this Rectangle structure."
|
|
|
|
|
I can see why you might consider it to be inconsistent, but from a GDI point of view it is very consistant. The end point is a limit no matter what you are drawing using GDI, that even includes lines. I know from personal experence that this can be a pain when you want the end point included in the drawing area.
I do agree that the end point should be valid (/drawn). When I designed my own graphics library some years ago the end point was valid [it seemed the natural way to do it].
A bug is some thing that you did not intended to happen.
|
|
|
|
|
Check out "PocketPrep" from handango.com.
It has 90 questions based on the test spec. (070-316 and 070-306)
|
|
|
|
|
I am trying to run an access report in c#. The report runs ok but I cannot seem to stop the dialog box asking for the report parameter.
appAccess.DoCmd.OpenReport( reportName, Access.AcView.acViewPreview, "",
whereCondition, Access.AcWindowMode.acHidden, "");
The filtername and openargs (the "" fields) and the whereCondition parameters of the above method do not seem to set the report parameter.
How can I set a parameter value for this report?
It ain't what you know that matters.
Uncle Monkey
|
|
|
|
|
Hi,
I have a Form in which I want to capture input events (MouseMove , KeyDown ), before they propagate to the Controls of the Form. I tried overriding OnMouseMove , and not calling base.OnMouseMove , but this method seems to be bypassed when my mouse is over one of the controls of the Form. Do i have to set a flag somewhere to not automatically propagate the events to the child controls?
|
|
|
|
|
Is KeyPreview[^] what you're looking for?
John
"We want to be alone when we hear too many words and we feel alone when it has been a while since anyone has spoken to us." Paul David Tripp -- War of Words
|
|
|
|
|
When you assynchronously invoke a delegate using begin invoke, much to my dismay the AsyncCallback it calls when finished is called on the wrong thread.
The AsyncCallback is called on the same thread the assync processessing was done in. This is very annoying
What I need is for the main thread to be notified, so that from the callback method I can then call a method on the main thread.
Anyone figured out how you can do this ???
|
|
|
|
|
Go read this article. Even if you aren't working with a UI on the main thread, the techniques still apply.
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
Hi David,
Thanks for the link, it was very interesting.
However I still cant see how the parent thread can be called when you are not working with windows forms, for example if you are working in a console app.
I myself am specifically working with a class instantiated from the main form but not the main form itself.
I tried inheriting from Control but this didnt work.
What I need is the equivalent of Control.BeginInvoke but which can be used outside a form.
Is it impossible ?
|
|
|
|
|
I am using the TaskbarNotifier class to display incoming TCP/IP messages. I listen for a message on a port and when one is received, I start a thread that creates a new TaskbarNotifier object and shows the message. However, looking at Windows' Task Manager, I've noticed that the GDI Objects continue to grow (by 2 objects each time I am notified), even though the thread appears to end successfully (the thread count in task manager remains a constant 4).
If I call create TaskbarNotifier in the same thread as my TCP/IP listener, the resources don't grow, but the port is blocked until the notifier finishes.
Calling the thread without creading a TaskbarNotifier object also does not create growing resources.
Adding the single line:
TaskbarNotifier taskbarNotifier1 = new TaskbarNotifier();
to the thread class will cause the problem. If i set taskbarNotifier1 = null, it has no effect.
Any ideas welcome.
|
|
|
|
|
Howdy Folks!
Does anybody know of a way I can identify the current x,y location of the cursor in a Rich Text Box?
(Just for clarity - I'm talking about the text insertion cursor, not the mouse pointer...)
Thanks in advance!
Mojo.
|
|
|
|
|
you could do this :
VB:
<font color="blue">Private</font> void richTextBox1_MouseMove(<font color="blue">Object</font> sender,System.Windows.Forms.MouseEventArgs e)
{
<font color="blue">Try</font>
{
<font color="blue">Char</font> c=new <font color="blue">Char</font>();
System.Drawing.Point p=new System.Drawing.Point();
p.X=e.X;<font color="#006400">
p.Y=e.Y;<font color="#006400">
c=richTextBox1.GetCharFromPosition(p);
this.Text=(Convert.ToString(c));<font color="#006400">
}
<font color="blue">Catch</font>
{
System.Exception f=new System.Exception();<font color="#006400">
MessageBox.Show(f.Message.ToString());
}
}
hope that helps a little.
<font color="blue">Private void</font> ExpectingTwins(<font color="blue">string</font> twins)
{
<font color="blue">switch</font>(twins)
{
<font color="blue">Case</font> ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
<font color="blue">break</font>;
}
}
|
|
|
|
|
caret not cursor
<a TITLE="See my user info" href=http:
|
|
|
|
|
Try the GetCaretPos API function.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Thanks everyone for your help!
I eventually managed to do this using:
pt = rtf.PointToScreen(rtf.GetPositionFromCharIndex(rtf.Text.Length))
|
|
|
|
|
Dear all,
How to access a C# DLL function from a MFC app? Is it possible?
VikramS
|
|
|
|
|
Yes, compile your MFC application with /clr and use the #using directive for importing the C# DLL. You'll need to use Managed C++ for calling your C# DLL, but it's not a big deal.
ORACLE One Real A$#h%le Called Lary Ellison
|
|
|
|
|
Hi all!
I have some problems with convert project from VB6 to C#.
I dont know how it be in C# code like this:
----------------------------
Public Event Wiadomosc(ByVal sender As Long, ByVal seq As Long, ByVal time As Long, ByVal class As Long, ByVal message As String)
----------------------------
Public Property Let ListaKontaktow(index As Integer, co As lbpoleKontaktu, value As Long)
If co = 0 Then
kontakty(index).nrgg = value
Else
kontakty(index).typ = value
End If
End Property
----------------------------
Public Property Get ListaKontaktow(index As Integer, co As lbpoleKontaktu) As Long
If co = 0 Then
ListaKontaktow = kontakty(index).nrgg
Else
ListaKontaktow = kontakty(index).typ
End If
End Property
----------------------------
Public Sub sendMsg(numerGG As Long, seq As Long, class As Long, msg As String)
Dim dlugosc As Long
dlugosc = Len(msg) + 12 + 1
sckGG.SendData 11&
sckGG.SendData dlugosc
sckGG.SendData numerGG //where sckGG is Winsock control i know that i must use Socket in C# but i don't know how
sckGG.SendData seq
sckGG.SendData class
sckGG.SendData msg & Chr(0)
End Sub
Greeting
S_W
|
|
|
|
|
|
Hi, friends ! If I want to create a window's control unit for reuse , how could I know when it should inheritance the Forms , Usercontrol , Control , Component ... ? what are they difference between them ? I am very confuse for them ? help me !! thx!
|
|
|
|
|
Hi, friends! How can I do a toolbar like VS.Net ? (it's called coolbar or rebar in C++), I have some library about that , but it's very complex for me , I want to know the keypoint , what is keypoint for coolbar in C# ? thx!
|
|
|
|