|
Although you don't tell us exactly what your problem is, this might help you:
Delegates are similar to function pointers in C/C++, callback functions that are called when a certain event arises.
The big advantage of .NET delegates is that they are type-safe.
So for example to catch the CheckedChanged event of a CheckBox you'd write:
checkBox1.CheckedChanged += new EventHandler(checkBox1_CheckedChanged); This attaches a new delegate (EventHandler is a special form of a delegate ) to the CheckedChanged event of your CheckBox checkBox1 . The method to be called is checkBox1_CheckedChanged and must be defined like this:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
So far for a start, I'd suggest you read the description of event handling in the .NET framework documentation.
mav
|
|
|
|
|
hi,
If you are newbee in C# delegate. then i suggest you to go for some e-materials or books or msdn to get a basic idea. and then try to submit your problems which arises on the time of implimentation.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I Want draw a polyline join two points ,It Can generated automatic and steer clear of shapes in the map if input start point and end point. Just like Visio 's polyline does.
Who can tell me the arithmetic about this ?
|
|
|
|
|
Gentlemen,there is a question for you.
Well , I'm trying to replace my system cursor with a real 3D cursor.But I don't konw how,or even it is possible , to display my 3D cursor generated in real time instead of the system cursor.
Anyone can give me some advices?
|
|
|
|
|
It is my understanding the the desktop, cursor, et. al. is only using the 2D graphics API. Using DirectX would require (I do believe, but could be very wrong) running the entire desktop in DirectX 3D mode. You would probably have better options open to you next year using VS 2005 and the WinFX API.
This signature left intentionally blank
|
|
|
|
|
I havent done any programming in a few months now, and as such i kinda forgot alot of this stuff... i used to know the anwser to this question *i wrote a program using it before* but alas, i forgot. Anyways what i need is to have my program running in the background without focus and beable to detect when i press a combo of buttons on my computer, and have it regain focus agian. Its simple i know, but i just pretty much forgot how to do alot of programming, anyways thanks for your help guys. Do i have to catch api calls, if so can you kindly provide any of them or ways of finding them, im looking now for them but i think there has to be a easyier way, a managed .Net way. anyways thanks for your time.
The Code Project Is Your Friend...
|
|
|
|
|
There is currently no "managed .Net way" of doing this, no. You need to implement system hooks by P/Invoking the necessary APIs. In fact, much of the .NET Framework BCL - especially System.Windows.Forms.dll - encapsulates native functionality already. You can see this by examing the BCL assemblies in the IL Disassembler (ildasm.exe that ships with the SDK) or another disassembler/decompiler of your liking. Read Global System Hooks in .NET[^].
Be very careful, however. System hooks need to be fast since all messages from a particular class of messages are passed through the hook. Some people writing managed code often take for granted what's given to you for free without thinking (or knowing) about the code that provides such functionality. And always make sure that your code will not currupt the system message pump unnecessarily.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Ok, loading an assembly is pretty straightforward using assembly.loadFrom()
However, I would like to now unload that assembly (to update the DLL to a new version, etc.)
How do I do this? I have looked and cannot seem to locate an unload method or any other way to get rid of the assembly. The assembly is being loaded from a file, so its not in the GAC (as I understand it, anyway).
Any suggestions????
khariV
|
|
|
|
|
Individual assemblies cannot be unloaded. You must unload the entire AppDomain .
Using Application Domains[^]
Charlie
if(!curlies){ return; }
|
|
|
|
|
I have a serious problem. I only want ONE instance of my application running. So in the Main, I have
Process aProcess = Process.GetCurrentProcess();
string aProcName = aProcess.ProcessName;
if (Process.GetProcessesByName(aProcName).Length > 1)
{
Application.ExitThread();
}
which may not be the most effecient means, but it works. Now the problem is, I have an associated extension (let's say .xyz) that brings up the application whenever someone clicks on a file with this extension. This works fine as well. The PROBLEM is, if an instance of the application is already open, and someone clicks on an .xyz extension, a new instance of the application is attempted and the code above stops it from running. What I WANT to do, is to either
A) Somehow have the new instance pass the args from the .xyz file to any CURRENT running instance of the application and then shut itself down as in above
OR
B) Don't even open up a new instance at all, but rather have it so that somehow something checks first to see if there IS an instance running.
There HAS to be some way to do this? HELP?
|
|
|
|
|
|
|
Yes, unfortunately with the security changes in .NET 1.1 this is no longer allowed since the following error occurs...
Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed
|
|
|
|
|
Sure, but that's easy to come by.
Here's an article by Ingo Rammer[^] about the changes in .NET 1.1.
One more thing, you'll have to override InitializeLifetimeService() to return null on the class being published for remoting or its lifetime lease will run out after approx. 2 minutes, meaning that you'll get an error when you start a second instance of your app after >2 minutes.
I've already contacted Chris Anderson, but he doesn't plan to update his article
Regards,
mav
|
|
|
|
|
Hi,
I want to develop/use expense management tool similar to Microsoft's PocketPC Expense. I would like to create categories on the fly and data to be stored in xml for easy porting? Does any one has source code or ideas to do this?
Can any one point me to a open source for this?
|
|
|
|
|
If you're going to develop such a product, then you shouldn't need source. If you want to find source, I recommend that you do a search. The CodeProject C# forum is here to provide help with questions specific to the C# language and related .NET/CLI questions, not provide specifications and general help on product decisions.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I'm working on a control that I'd like to have enabled in both XP themes and conventional windows style.
One of the things I am baffled by is the gradiant color in the header bars of normal windows. These are done using two seperate colours, now I can only see a way to get the first colour from the system Active/InactiveCaption. How would I go about getting the second color?
Cheers
Cata
|
|
|
|
|
SystemColors.ActiveCaption and SystemColors.InactiveCaption give you your gradient colors, but the gradient in XP's themes are not set by Display/Appearance properties; it is from a theme comprised of bitmap resources that currently does not have a public authoring release. There are cracks to enable your own, but in order to use XP themes (either legit or from a cracked uxtheme.dll) in a custom control, you need to read the Visual Styles Reference[^] and P/Invoke the necessary APIs.
There are articles detailing this here on CodeProject. Try searching.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Sorry mate, i think i was a bit unclear.
I've got the XP styles working perfectly. My problem is with making non XP style conrols look.. well.. like non XP controls.
One of the things i found was at work today, looking through the display settings for NT, was that the header bars of the windows go from one customisable color, to another.
I'm not sure where I could find these two variables, as i'd like my control to conform to the enviroment standards. Does what you said still stand? Or do i need to call some GDI+ or some other system DLL to find out these two values?
I was under the impression that inactive caption was some other color entirely. I'll have a closer look at NT tommorow.
Thanks for the input anyhow.
Cata
|
|
|
|
|
SystemColors.ActiveCaption and SystemColors.InactiveCaption give you the 1st colors for the gradients. To get the other colors, you need to P/Invoke GetSysColor like the other reply mentioned.
To convert the DWORD return value use ColorTranslator.FromWin32 or Color.FromArgb .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
You have to use the API Function:
<br />
[DllImport("User32.dll", EntryPoint="GetSysColor")]<br />
public static extern int GetSysColor(long nIndex);<br />
The Integer you get is in the Form (hexadecimal)
<br />
0x00bbggrr<br />
(if I remeber right).
For the second color of the Title Bar gradient you need the color with the index 27. More info should be in the API description.
Greets
Roland
|
|
|
|
|
Does anyone know if the refresh version has any new featured/bug fixes? On the website it says its the same beta, plus Team Systems. I don't want to download 3.5GB just to get team systems.
|
|
|
|
|
Hi there,
I'm writing a C# application and using a C#Express Beta2 and SQLExpress Beta2:
I've created an object (say 'Human') which I persist to a SQL DB table. Human has a DateOfBirth property of the (.Net) type DateTime. The apropriate field in the table is of SQL type DateTime. Now I create an instance of my Human and set the DateOfBirth to yesterday using the following code:
Human Human1 = new Human();
Human1.DateOfBirth = new DateTime.Now.Substract(new TimeSpan(1, 0, 0, 0));
Then that I persist my you Human to the database. After that I create a new instance of my Human (Human2) and read it's property-values from the database, like:
if(Human1.DateOfBirth == Human2.DateOfBirth) {
}
Comparing Human1's DateOfBirth with Human2's I do not get the expected result as the two DateTime objects return the same Date and Time, but looking at the DateTime.Tick property I see some fractional differences .
How do you handle this? Thanks in advance.
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
The dates are probably not the same because the Time is included in it as well. So if one Human was saved 1 o clock and the other at 3 o clock, the datesTIME's wouldn't match. so match only the Date parts:
if(Human1.DateOfBirth.Date == Human2.DateOfBirth.Date) {
// this code is never reached
}
|
|
|
|
|
Human1.DateOfBirth = DateTime.Now.Date; // init with only the date portion.
Gary
"A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck."
Tom Shales talking about Robin Williams
|
|
|
|