|
Coming from a pure object oriented background (smalltalk and eiffel) I am very sympathetic to your view. Like you I mostly avoid using structures. When I do create structures I generally employ 'new', and I mostly use them for interop with Windows API's.
Obviously value types were retained for speed optimizations and because the second you drop below the rather spartan GDI+ abstraction you will be making extensive use of structures.
Unfortunately C# is still a hybrid language - for instance, it is not truly polymorphic. And it does not use messaging as its primary medium for communicating between objects. However, the inclusion of the Interface 'pattern' has gone some way towards alleviating the lack of full polymorphism. And it does encourage a rather nice 'published' approach to defining component interfaces. I wish that metadata manipulation were a shade better developed. On the odd occasion I cannot be bothered to write an Interface I end up using the 'is' keyword and casting objects to specific class types. Which is a bit of a bore really.
Studio .NET is really just a two trick pony. C# is the primary language and C++ is retained for those occasions you really must drop down to API level (I use C++ to wrap DirectX API code for instance).
VB.NET is just C# with VB-like syntax. Likewise J#. Except that J# is essentially useless to serious Java programmers because it has no support for VM/Swing. I also mourn losing FoxPro database. But hey, that's life.
Only change is constant
|
|
|
|
|
C# is a hybrid, but they should have left the non-OO stuff just for use with InterOp. They should not have used it in the .NET framework. The other annoying thing is when coding, and I come across a new 'object' that is returned to me from the .NET Framework I do not know if it is a struct, or a object 'object' until I try to do something illegal to one or the other.
When I have to use a struct from the framework I do not use the new keyword any more, so that I know it is a struct. I know that all the books say not to do this that it will be confusing or not look right. Well I say it is less confusing since it show that it is a struct and is a ValueType object, with it's pro's and con's, and should be treated as such.
Why treat one ValueType object different than the others? Should you then use new to create all your int's and float's etc?
I just wish there was a way to tell you are working with a struct when an object hands you one without having to implement any stupid hungarian notation.
It's nice to know that someone else has similar issues, since most of the people responding are more negitive of my comments.
Thanks,
Aalst
|
|
|
|
|
Is there any control like CPropertySheet (in MFC) in C# ?
I want make a wizard like dialog, is there any control can does ?
Thx.
|
|
|
|
|
The closest approximation to a PropertySheet would be a UserControl.
Genghis[^] has a framework for creating Wizards; but I haven't even looked at it so I don't know what it offers.
I do have a wizard framework that I'll make available, but I'm too busy at the moment to find one bug that just makes me cringe in that I have no idea why it is happening.
If anyone feels like bug hunting, I've uploaded the source and a demo of the wizard framework; TSWizard.zip (39.4 Kb). The bug is that the BaseStep.Wizard_OnNextClicked delegate isn't removed from the Wizard's NextClicked event when the back or next buttons are clicked. Oddly I don't have that problem with the BackClicked event and the code is exactly the same (except a few name changes).
[Edit: Oops forgot to add this bit]
I'm posting it now only because I'm going to be very busy writing my first chapter [insert excited emoticon here] and probably won't have a chance to look at it for another week. On top of that I've promised the code for two weeks now
[/Edit]
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Thx.
And there is a bug. In BaseWizard.cs
internal event EventHandler NextClicked
{
add
{
Events.AddHandler(BaseWizard.nextClicked, value);
}
remove
{
Events.AddHandler(BaseWizard.nextClicked, value);
}
}
the remove must be Events.RemoveHandler(BaseWizard.nextClicked, value);
And it is very good wizard,I like it.;)
|
|
|
|
|
I can't believe I missed that!
That bug had plagued me for 2 weeks and I went over it at least a hundred times.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
|
|
I don't think everybody can do it.James is one of editors in CP.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Mazy is right, its a feature for Editors, Platinum members, and Supporters.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
My application needs to restrict the cursor to a rectangular region. How do I do this?
I've tried using the mousemove event (of the form). When the mouse moves out of the rectange I use SetCursorPos. But this ends up being a mess because the mouse cursor "blinks" (mouse cursor apears in two locations), because it does pass the region and has to be put back in.
Another approach I tried. I used a lowlevel mouse hook. If the mouse went out of the rectangle I would mark the message as handled, keeping the message from going any further. The cursor would be positions on the edge of the rectangle (closest to where the real position would be). But even this approach was flawed because the mouse still "blinked". Appearently the cursor is drawn on the screen before the message gets to my hook.
Is there a way to do this?
|
|
|
|
|
Check out the Cursor.Clip property. I believe this can restrict the cursor to a specific rectangle and it doesn't require any special coding.
The syntax is like this:
Cursor.Clip = new Rectangle(...your retangle dimensions here...)
Does this help?
Alastair
Only change is constant
|
|
|
|
|
|
Luis Alonso Ramos wrote:
The problem is that if a change the server and client to use UDP (and datagrams) an exception is thrown in the server at the Listen call.
UPD datagrams support up to 64 KB messages without fragmentation.
If you want to send a bigger portion simply turn on it
socket.SetSocketOption( SocketOptionLevel.Udp, SocketOptionName.DontFragment, false);
Another case in which an exception could be thrown is that the default buffer is too small to receive such a big datagram. For example, in UdpClient it's set to 8KB.
socket.SetSocketOption( SocketOptionLevel.Udp, SocketOptionName.SendLowWater, 1024 * 128 );
socket.SetSocketOption( SocketOptionLevel.Udp, SocketOptionName.SendBuffer, 1024 * 128 );
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
I tried adding those lines after the creation of the socket, and they throw exceptions (of invalid argument type.)
Anyway, I don't try to send more than 64 KB at a time, it's just a simple 19 byte message.
Any idea why the server will not start listening??
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Could you give the exception's description and its type. It could help.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Yes, this is the exception:
System.Net.Sockets.SocketException: The attempted operation is not supported for
the type of object referenced
at System.Net.Sockets.Socket.Listen(Int32 backlog)
at AsynchronousSocketListener.StartListening() in d:\projects\asyncsock\server\server.cs:line 49 The socket is created like this:
Socket listener = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp); Thanks,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
From what I remember, UDP is a connectionless protocol. Unlike TCP, UDP has no notion of an explicit 'connection' being made to a server socket, which is most likely why this exception is being thrown.
TCP is designed to guaruntee data delivery or to notify the sender and receiver of a delivery failure. In order to do this it keeps alot of state behind the scenes, thus necessitating the 'connection' metaphor.
UDP, however, is much more like IP in that it is a "best effort" delivery protocol. If you send data over UDP, it will most likely get their in good shape. However, it's up to the person reading from the UDP stream to figure out whether or not the data they got has been corrupted.
Long story short - there is no such thing as a 'Connection' or a 'Listen socket' in UDP. If you want to send a data packet via UDP, you specify the data you want to send along with the IP address and port # you want to send it to. You do this for every send() call. Same type of thing with receive() on UDP. You don't connect to a server socket like you would with TCP, you just recv() on a specific port # and wait for someone to send a UDP packet to that port.
My only experience with writing UDP code is in straight C on Unix, so I'm not sure how this would be implemented in the .NET FCL...
--
Russell Morris
"Have you gone mad Frink? Put down that science pole!"
|
|
|
|
|
Russell Morris wrote:
You don't connect to a server socket like you would with TCP, you just recv() on a specific port # and wait for someone to send a UDP packet to that port.
So, that is why there is no UdpListener class?? For an UDP server I just start an UdpClient class and call receive on certain port, and it will block until some one calls send on that port?
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
My application needs to support multiple displays. How do I programmaticly move a window/form to a certain displays (monitor)?
If I need to do this with win32 api, what would be the function?
|
|
|
|
|
As long as child forms can move outside the main window, it should have multiple monitor support.
I did note somewhere (cant remember where though) than the position you use is as if the no.1 monitor is the centre monitor in an imaginart monitor grid.
So in my case, 2nd monitor being on the left, the bottom left corner would be (-1024, 768) top right (0,0). Not so sure though
Hope you understand
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
You should be able to get all the info you need about screen points from the System.Windows.Forms.Screen class
|
|
|
|
|
|
AK wrote:
If I need to do this with win32 api, what would be the function?
I presume you meant to ask this in the C++ forum ? If you're asking about C#, you don't need the API at all. Check out James' and my Code Project screensaver, it supports multimonitor in C#.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
What I basicly needed was to get the a form to show up on all the displays center on the screen. This is what I did:
1. Create a form for every screen.
2. Set the location of the form to the screen points (w/ offset to make it centered)
3. Assign all the events to the same event handler. (So all the forms are uniform)
4. Show all the forms.
5. When I get input from the form - all forms are closed.
Thanks for helping me out.
|
|
|
|