|
readonly is not recommended for objects of this sort since it implies the objects of the list are unchangeable when in fact they are. It is a constantly source of errors for novices.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
When posting the answer I though for awhile if I should declare the list readonly or not.
When used correctly, readonly eliminates certain problems that can occur if the actual list is changed. I would say that it depends if you want the list to be changed or just to allow to modify it's content. That's why I also defined only getter for the property.
The other thing was that the original question was, how to define a list globally so that others can see and use it. Based on the question my interpretation was (maybe incorrectly) that the list should not be changeable, but it's contents can still be modified.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Whats the difference between
if ((e.Button & MouseButtons.Right) == MouseButtons.Right)
{
}
and
if(e.Button == MouseButtons.Right)
They both work the same
I am unable to understand the use of the logical operator &
and ALSO when I change the & with && it wont work
Can anyone help
|
|
|
|
|
humayunlalzad wrote: Can anyone help
Yes, you can by learning what bits are and how the different bit operations work. Perhaps you should start here[^]
led mike
|
|
|
|
|
They don't actually work the same. If that event was raised with both right and left mouse buttons pressed (eg: e.Button = (MouseButtons.Right | MouseButtons.Left)) then the two snippets would be different. The difference is that the first one checks to see if a particular bit in a value is set and the second checks to see if the value is exactly equal to some other value.
I assume that when you switch & with && you got a compiler error. The single operators & and | are used to perform bitwise operations. The double operators && and || are used to perform operations on boolean values.
|
|
|
|
|
Hi,
humayunlalzad wrote: the logical operator &
No, && would be a logical operator, & is a bitwise operator
The following is similar to your code (just assume MouseButtons.Right=1), but may be easier to understand:
for(int i=int.MinValue; i<int.MaxValue; i++) {
if ((i & 1) == 1) Console.WriteLine(i.ToString()+" is an odd number");
if (i == 1) Console.WriteLine(i.ToString()+" equals 1");
}
i & 1 ANDs the bits of i with the bits of 1 (which is all zeroes except for the rightmost bit);
the result is either 1 or 0, and depends solely on the lowest bit of i.
As a result, the former test checks only a single bit (and hits many times), the latter checks all bits in variable i (and hits just once).
|
|
|
|
|
I do understand the behaviour of bitwise operatores on Integers. But what I still dont understand is
e.Button how is that an Integer, or what bits does it have or how do we know those bits.
I assumed that MouseButton is an enum and the bitwise operator would work on its underlying byte or int value.
And thanx for the help
|
|
|
|
|
Hi,
MouseEventArgs.Button returns a MouseButtons Enumeration, which basically is an int with some
bits set. I suggest you read up on enums, and the Flags attribute if you want to know the
specific details.
|
|
|
|
|
Thanx a lot everything is clear now. You were a great help.
|
|
|
|
|
you're welcome.
|
|
|
|
|
I've scoured the web (well sorta' scoured it anyway) looking for an answer to this question.
I want to rotate a label control so that it's oriented vertically. I've tried a couple of the articles here on CP, but I'm having a couple of issues.
0) The rotated text is incorrectly aligned
1) The rotated text (what I can see of it anyway) is butt-ugly, exhibiting no anti-aliasing at all.
I've tried rendering some text on a bitmap, and then rotating the bitmap, but that ain't working at all (I know it's because I'm not doing it right).
Does anyone know of a decent (free) rotated label control that honors ALL of the alignment and applicable style settings and the system text quality settings?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Thursday, November 20, 2008 12:33 PM
|
|
|
|
|
If you decide to make a custom control check out the Win32 SetWorldTransform call. This will set a transform that even the text drawing API's will how, and still have thinks look reasonable (something that the lfEscapement value completely mucks up). It shouldn't be too hard to do this in .Net. You may also have to drop down and make a DrawTextEx or TextOut call your self - somewhere in the back of my mind I recall one of these calls being the better one to use.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Well, I solved that particular issue by creating the bitmap in a separate class, and then rotating it in the form's OnPaint routine. I have a whole other issue right now.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
BTW, I beat the framework into the submissive bitch that she should be, and forced my will upon her, like she was a $2 hooker.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Glad to hear it, cause the whole bitmap rotation thing was an awfully cheap way to go - kind of My Pretty Pony approach if you ask me.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
John Simmons / outlaw programmer wrote: she was a $2 hooker.
Is that a Texas Special? I don't have firsthand experience mind you, but I'm pretty sure in NYC you're now looking at a $10 hooker, inflation, gas prices, stock market, and so on being what they are.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
is there a way to set a form so it is always on top?
So that any other windows cannot cover the form i designed
|
|
|
|
|
|
The start menu still pops over it... is there a way to get my form always over that as well?
|
|
|
|
|
I'm new to C#, so please excuse my ignorance. I assume there must be a straighforward way to "trash" (not just temporarily ignore) messages sent to a control, such as a button, so that unintentional/random clicks do not queue up and get handled later. I have successfully filtered messages using the IMessageFilter class functions, but the messages are still queued up and get responded to as soon as I invoke RemoveMessageFilter.
Also, any strong recommendations on a C# manual would be appreciated.
I greatly appreciate any help.
Doug
|
|
|
|
|
Try overriding WndProc - declare the WM constants you want to be ignored and test for them, if you want the message to be passed on (not ignored) call the base - something like...
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_???)
{
m.Result = IntPtr.Zero;
return;
}
base.WndProc(ref m);
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanks for the input Dave.
I put the WndProc() override function in a Form class definition, with the intention of catching Left Mouse Button events (WM_LBUTTONUP, WM_LBUTTONDOWN, WM_LBUTTONDBLCLK). The effect of this was that messages from clicking on controls (buttons and text boxes) on the form were not even seen by the WndProc function, but the WndProc function did see mouse clicks from anywhere else on the form. I don't know if the mouse messages are modified somehow from the controls so that there IDs are different?
Any help here would be appreciated.
Thanks,
Doug
|
|
|
|
|
Sorry for the delay in replying, haven't been online for a couple of days.
You'll need to create your own classes and derive from whatever control it is you need to intercept for i.e. Button and override WndProc in there.
If you need to then handle it from the parent form, you could raise an events that use event args derived from CancelEventArgs based on the WM_??? and use the bool Cancel to return whether to call base.WndProc(ref Message m). I've not tried this but it should work.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi.
I have created a component group consisting of a web service, windows service, database, etc. Each of these units(the component group being one unit) will be installed on a server (meaning each server will have a windows service, web service, database, etc). In order to call and use the web service I have consumed it and used it as a normal object.
Ex:
ExampleWebService myWebservice = new ExampleWebService();
myWebservice.Create();
Now my question is here. I have a part of my program which reads the webservices' URLs from a database, and needs to call each webservice in order to check if its still alive or not, a kind of heartbeat monitor if you will. From one webservice, how do I call another, knowing its URL and by consuming it ?
Any help will be greatly appreciated, thanks.
|
|
|
|
|
If you have a web method in each web service that is the same (for example each web service has method Alive() which returns boolean), use WSDL to generate a proxy and include that in your project. You don't need to add web service references to your project.Now you can control better the url and other properties. From there on it's like calling a normal web service.
Addition:
See for example: Invoking a Web Service Without Web Reference[^]
Mika
The need to optimize rises from a bad design.
My articles[ ^]
modified on Thursday, November 20, 2008 3:40 PM
|
|
|
|