|
I'm trying to detect which cursor is currently shown on the screen, whether it is a wait cursor, arrow cursor, etc. Right now, the detection works perfectly EXCEPT that there are 3 cursors that i can't seem to detect sometimes - the hand cursor, horizontal and vertical splitter cursors.
The code i'm using is (with the GetCursorInfo API):
Info.Size = Marshal.SizeOf(Info.GetType());
GetCursorInfo(out Info);
if (Info.Cursor == Cursors.WaitCursor.Handle)
CurrentCursor = "Wait";
else if (Info.Cursor == Cursors.Default.Handle)
CurrentCursor = "Default";
else if (Info.Cursor == Cursors.AppStarting.Handle)
CurrentCursor = "Loading";
else if (Info.Cursor == Cursors.Hand.Handle)
CurrentCursor = "Hand";
....
After i did some tests, i noticed that when i convert the values to string, the two values of Info.Cursor and Cursors.Hand.Handle (along with the HSplit and VSplit values as well) do not tally and they tend to change over and over again almost every time i run my application again.
The tests were done by displaying the values of Info.Cursor and Cursors.Hand.Handle using codes like these:
MessageBox.Show(Info.Cursor.ToString());
MessageBox.Show(Cursors.Hand.Handle.ToString());
I did the tests mostly on Applications that have a weblink and also on web browsers. When using a web browser, the detection seems fine (for the hand cursor at least) but when i run an app that has a weblink somewhere and the hand cursor shows up, the values of Info.Cursor and Cursors.Hand.Handle are totally different.
Is there a way around this?
|
|
|
|
|
try using the .NET way, Cursor.Current
Another Post by NnamdiOnyeyiri l Website
|
|
|
|
|
Cursor.Current only detects the cursor within the form. I need to detect the cursor system-wide (i.e: both inside and outside the form).
|
|
|
|
|
How do I bind two table columns in a combo box with a '-' character separate the column without using concatenation method in my select SQL statement.
|
|
|
|
|
You dont hah ha
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Hi! I have the following code:
Stream stream = new FileStream("Form1.resx", FileMode.Open);
And the default directory for Form1 is in WindowsApplication1\Bin\Debug right?
But I want to use the resx in the WindowsApplication folder. How do I do this?
Please help this newbie.
"To teach is to learn twice"
|
|
|
|
|
Form's .resx file is an embedded resource. This means you can access it as shown below:
Assembly assembly = Assembly.GetEntryAssembly();
Stream stream = assembly.GetManifestResourceStream(
"WindowsApplication1.Form1.resx");
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
What namespace will i add for this?
Thanks in advance!!
"To teach is to learn twice"
|
|
|
|
|
daljv wrote:
What namespace will i add for this?
Whichever you find appropriate. Just don't forget to update the parameter of GetManifestResourceStream() to "Namespace.Of.Form1.resx" .
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
Hi! I used the follwing code:
Assembly assembly = Assembly.GetEntryAssembly();
Stream stream = assembly.GetManifestResourceStream("WindowsApplication7.Form1.resx");
ResourceReader a = new ResourceReader(stream);
IDictionaryEnumerator en = a.GetEnumerator();
en.MoveNext();
MessageBox.Show(en.Key.ToString());
MessageBox.Show(en.Value.ToString());
a.Close();
But I get an exception stating that:
An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
Additional information: Value cannot be null.
Why is this?
"To teach is to learn twice"
|
|
|
|
|
I probably misunderstood your question. You will need: System.Reflection and System.IO .
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
Hi! I used the follwing code:
Assembly assembly = Assembly.GetEntryAssembly();
Stream stream = assembly.GetManifestResourceStream("WindowsApplication7.Form1.resx");
ResourceReader a = new ResourceReader(stream);
IDictionaryEnumerator en = a.GetEnumerator();
en.MoveNext();
MessageBox.Show(en.Key.ToString());
MessageBox.Show(en.Value.ToString());
a.Close();
But I get an exception stating that:
An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
Additional information: Value cannot be null.
Why is this?
"To teach is to learn twice"
|
|
|
|
|
Replace WindowsApplication7.Form1.resx with WindowsApplication7.Form1.resources . This should work.
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
It now works!
Thanks a Trillion!! You have learned twice!!
"To teach is to learn twice"
|
|
|
|
|
daljv wrote:
You have learned twice
Indeed
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
When I go to 'About' in Visual Studio it says I have 1.0.3750...
I have the 1.1 installed on my computer... How do I get visual studio to use it?
/\ |_ E X E GG
|
|
|
|
|
You install VS.NET 2003.
VS.NET is tied to the version of the framework it shipped with, VS.NET 2003 is the same way but it has an added feature to generate a .config file so your application can use version 1.0 at runtime.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
This is horrible... I was afraid someone was gonna say somthing like that...
I can't get the visual styles to work in my application to work for the life of me...
/\ |_ E X E GG
|
|
|
|
|
Just to check a few things:
Do you have a "myapplication.exe.manifest" file in your application's directory? Or have you followed one of the article's here on CodeProject where you embed the manifest, and have you remembered to redo the embedding each time you rebuild your application?
For the controls that support it, do you have the FlatStyle property set to "System"?
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
If your application is called blah.exe, create a manifest file:
blah.exe.manifest
in the directory in which your executable is located. Check MSDN for the manifest file layout. In there, modify the required version to the version of the runtime you want to use.
|
|
|
|
|
I want to get the list of printers installed. Below is the codes I copied from the .NET help file under "InstalledPrinters Property".
private void PopulateInstalledPrintersCombo()
{
string pkInstalledPrinters;
foreach(pkInstalledPrinters in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
printerName.Items.Add(New ListItem(pkInstalledPrinters, pkInstalledPrinters));
}
where printerName is a listbox
The first few times this function was used, it was fine, but later it cannot seem to find the printers ie. System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count returned 0
Any ideas what's wrong?
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|
|
I was typing the code on memory and not pasting it, so i think I got the syntax wrong.
Anyway,it does work for me too, but only the first few times(10+), but after that it stopped working.
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|
|
Remind not to call you for tech support!
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|
|
When I go to 'About' in Visual Studio it says I have 1.0.3750 framwork...
I have the 1.1 installed on my computer... How do I get visual studio to use it?
I wanted to do the enable visual styles thing...
/\ |_ E X E GG
|
|
|
|
|
Visual Studio 2002 only targets NET 1.0 .You can not use the .NET 1.1 from within Visual Studio 2002.
To build a .NET 1.1 App you have two options:
1. Use Visual Studio to write and organize your files and then use the command line compiler on the 1.1 SDK folder to build your app (but remember that NET 1.1 introduces some code-breaking changes to NET 1.0)
2. Upgrade to Visual Studio 2003
As for the visual styles, I wouldn't be too eager to use the NET 1.1 EnableVisualStyles method since there have been multiple reports of instability and inconsistent behavior of this method. Implementing visual styles through yourappname.exe.manifest (a manifest file) is still the safest bet.
|
|
|
|