|
Its not as bad as you think, after a while you'll get out of the mindset of wanting to use globals. It promotes good OO design. Hell, academics have been saying globals are the work of the devil since the early days of structured programming.
In cases where globals would be appropriate you can just make a class with static members. However I rarely find myself doing that.
|
|
|
|
|
True, but like most other things, the difference between academia and the real world is like night and day. So static members are a "workaround" to the global problem (is there a pun in that?)
What about messaging? While the whole GUI event architecture in Window Forms is now changed to use delegates instead of messaging, there doesn't seem to be any support for messaging (well, there's the System.Messaging stuff, but that's way overkill for simple intra-application messaging). I've seen a lot of C++ apps that use custom messages for notifications, etc. Is this whole concept easily converted to delegates?
Thanks for your reply. I'm trying to dig into some of the differences in C# vs. C++ design.
Marc
|
|
|
|
|
Right, System.Messaging is intended for Multi-server messaging. Its the .NET wrapper for MSMQ. As far as delegates go I believe they can be used as a replacement for many custom message scenarios. Of course they can't replace it entirely, most of the Events from System.Windows.Forms are generated in direct response from Windows Messages.
In addition, .NET does provide for generating and processing messages directly. All objects that are associated with an HWND have an overridable WndProc which is a slightly abstracted WindowProc. You can also use all the native API functions for registering custom messages and Posting messages to other windows.
Now keep in mind I'm not trying to argue that .NET (C# in this case) is ssooo much better than Win32 C++ design. I'm just pointing out (what I think at least ) what the .NET developers have done as alternative solutions to these common tasks that seem to be missing from the framework and C# language.
|
|
|
|
|
Hi
I'd like to invoke member function e.g. from System.Windows.Forms.Button. I found some article in MSDN for System.Int32 that works well but for class Button no :/
Type myType1 = Type.GetType("System.Int32"); // OK
Console.WriteLine("The 'Fullname' is {0} ",myType1.FullName);
Type myType2 = Type.GetType("System.Windows.Forms.Button",true); // ERROR ? WHY ?
Console.WriteLine("The 'Fullname' is {0} ", myType2.FullName);
myType2.InvokeMember(....);
Is possible in this case ?
Wizard_01
|
|
|
|
|
From MSDN docu:
"If typeName includes only the name of the Type, this method searches in the calling object's assembly, then in the mscorlib.dll assembly. If typeName is fully qualified with the partial or complete assembly name, this method searches in the specified assembly."
Since you're only specifing the type name, it looks in your assembly, can't find it then looks in mscorlib. System.Int32 is defined there but System.Windows.Forms.Button isn't. Thus the error.
This however, will work:
Type myType2 = Type.GetType("System.Windows.Forms.Button,"+Assembly.LoadWithPartialName("System.Windows.Forms").FullName,true);
or the much simpler
Type myType2 = typeof(System.Windows.Forms.Button);
|
|
|
|
|
Thank you
Could you tell me who can I now create new Object from 'myType2' ?
Wizard_01
|
|
|
|
|
Activator.CreateInstance(myType2);
|
|
|
|
|
Has anyone got sample code of using Oracle and .NET?
I'm specifically looking for the syntax of calling a stored proc and receiving a result set.
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
oracle has recently released a beta version of their managed data provider. It comes with fairly extensive help files.
You may want to look into using that instead of the OleDb data provider.
|
|
|
|
|
I'm looking at the site now.
Any idea if there's truth to the rumor that Oracle can't return a recordset from a stored proc. to ADO?
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
Hi All,
I'm having a small problem with my C# application.
I have a DLL written a while ago, using pure Windows API. Now, it would be really nice if I could call functions of that DLL from my C# application.
Any ideas how I might go about it?
Any help would be appreciated.
Regards,
Venet.
--------
Black holes are where God divided by zero.(Steven Wright)
|
|
|
|
|
i'm not an expert in dll-including, but i once took a function out of an ordinary dll like this:
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
and just used it.
that was all
:wq
|
|
|
|
|
Your best bet...
Put up the function call and we'll translate it for you.
It's incredibly easy with C# now. I've done about 20 of them so far and I'm really impressed with the robustness of them.
|
|
|
|
|
Thanks for your replies.
Basically the function contained within the dll is:
bool state;
bool InstallMHook(state);
And I have exported this function from mhook.dll.
So is this what I need to do:
[DllImport("mhook.dll")]
private static extern bool InstallMHook(bool someState);
as suggested by Rüpel ?
Regards,
Venet.
--------
Black holes are where God divided by zero.(Steven Wright)
|
|
|
|
|
|
I shall try this.
Regards,
Venet.
--------
Black holes are where God divided by zero.(Steven Wright)
|
|
|
|
|
Does anybody know how and if it is possible to access VS.Net Webforms designer using add-in and change some html code generated by each webcontrol.
For example i want to replace some html codes before it is displayed inside VS.Net.
Alper
|
|
|
|
|
In office about dialog, we can display a systeminformation dialog by click the button, how to do in C#?
I'm amumu, and you?
|
|
|
|
|
System.Diagnostics.Process.Start("winmsd");
|
|
|
|
|
Got it, thank you
I'm amumu, and you?
|
|
|
|
|
I am trying to create a custom web control in C#. As i know, i can provide own property for user to set their prefer properties. Example:
public string Text
{
get{ return text;}
set{ text = value;}
}
But, the case is, i want to allow user to set multiple values for a property where user click on the the property window, it will be popping up a window and add the properties by using my own window setting. Is this possible to do and where can i find some example on this?
Thank you in advance
|
|
|
|
|
|
I am having problems finding out how to convert a time from a client's local time zone to GMT/UTC.
It seems the classes I should use would be in the .NET SDK for either System.TimeZone or System.Datetime. However, the .NET Framework SDK's System.TimeZone object does not have a public constructor (and is abstract) and the System.DateTime only creates its CurrentLocalTime according to the server the code is running on.
So, how do I create and specify another timezone? Most of the examples I have found either use JavaScript to display the value in the client's system time or use the standard offset for the client's timezone (which usually does not take into account Daylight Standard Time and the varying dates that the timezone switches to Daylight Time).
Any help is greatly appreciated. Thanks!
Chris
|
|
|
|
|
|
Hi...
so what is it this time
This time I really would like someone, to explain how I store (and retrieve) bitmaps in a resource file....
Also: If I have a funktion to wich I want to send parameters, then how can I make a list appear, with the few diferant parameters I expect...
F.x.
call SomeMethod(Jump)// So when I want to send the paramet a list shows up with 5 differant options
private void SomeMethod(xxx usrAktion)
switch (usrAktion)
case Jump: etc;
case Walk: etc;
Please help, I will be greatful (honest)....
|
|
|
|