|
Thanks, setting the KeyPreview to true worked perfectly for me.
|
|
|
|
|
Hola!
Here's a short description of my what I wanna do:
I'll create a program which is running all the time
I've got the computer on and it will listen to my typing,
and if I type a certain word, let's say "calculator" the
program will start the calculator up.
My problem is that I have no idea of how to get started with
the keylistening.. Ofcourse it needs to work while out of focus
too.. I need a push in the right direction - anyone?
/Joplinazz
|
|
|
|
|
search here and google for keyboard hooks
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
|
Hi
i define this interface :
public interface Interface1
{
void myMethod();
}
then create class which inherited from our interface :
public class Class1 : Interface1
{
#region Interface1 Members
private void myMethod()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
as you can see in second code, i set modifier of myMethod to private, but the following error message has shown me :
'WindowsApplication10.Class1' does not implement interface member 'WindowsApplication10.Interface1.myMethod()'. 'WindowsApplication10.Class1.myMethod()' is either static, not public, or has the wrong return type.
i want to set it's modifier to private to prevent access to this method outside of my class, but how to do ?
thanks
|
|
|
|
|
This doesn't quite make sense. Interfaces are used to quarantee existence of methods, properties, indexers or events that are public. For this reason implementation must be public.
If you don't want the method to be callable outside of your class, don't put it in an interface.
Mika
|
|
|
|
|
Mika is correct, it doesn't make sense to declare interface method implementations as private , that's not what they're for.
You can however use an abstract class like this:
public abstract class Vehicle
{
abstract protected void SomeMethod();
}
public class Car : Vehicle
{
protected override void SomeMethod()
{
throw new NotImplementedException();
}
}
However, the lowest access level is protected in this case.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
If you implement it Explicitly
void Interface1.MyMethod()
{
throw new NotImplementedException();
} then it will remain invisible unless a Class1 instance is explicitly cast to Interface1 like
Class1 class1 = new Class1();
Interface1 interface1 = (Interface1)class1;
interface1.MyMethod();
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
That's true, however then this sort of defeats the purpose of an interface, because often you just do something like
IInterface obj = Factory.GetSomeImplementation();
Usually you don't access (and don't care about) the direct implementation for an instance.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I totally agree - just trying to give the OP an alternative that may work in his situation.
A better way may be to have a base interface without the method that he could use and a second interface that inherits from the first for when he needs the method
public interface Interface1
{
}
public interface Interface2 : Interface1
{
void myMethod();
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
If you don't want your method to be public or accessible via the interface (explicit impl) then the solution is very simple:
remove the interface from your class since you are not using the class through that interface..
|
|
|
|
|
I am setting the image in a treeview by:
oNode = treeview1.Nodes.Add(sCaption);
oNode.Tag = sTagValue;
oNode.ImageKey = sImageKey;
oNode.Expand();
The images are being set fine. But when I click on a node, the icon changes to the icon set on the root node. When I click a different node, the prior node's image changes back to its correct icon.
Anyone know what I'm doing wrong?
Everything Makes Sense In Someones Mind
|
|
|
|
|
Check SelecteImageKey for the node. ImageKey is used only when node is not selected.
Mika
|
|
|
|
|
Hello everyone..
Im writing a c# app that needs to be able to receive notifications that have been sent by a web app using asp.net.
the notification can be sent to the inbox or directly to the desktop app if thats possible.
if its sent to the email, the app needs to somehow flag that an email has been received in the inbox. if they are sent directly to the desktop app it also needs to flag and the email be opened in the app.
please help...!!!
|
|
|
|
|
Do you even have the slightest idea about what kind of security issues what you are asking for can bring? You do not want a web application controlling the desktop or client machine.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi there.
I saw somewhere that obj1.Equals(obj2) is faster than obj1==obj2
Is it true ?
|
|
|
|
|
Mohammad Dayyan wrote: I saw somewhere that obj1.Equals(obj2) is faster than obj1==obj2
Leave alone the fast execution part but do you know that these two statements may not give the same result always.
Well, my personal suggestion is before posting the questions in the forum, atleast try to have a look at msdn. There are many chances that you will get the answer there itself.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Manas Bhardwaj wrote: Leave alone the fast execution part
Why?
Manas Bhardwaj wrote: do you know that these two statements may not give the same result always
Do you have any examples ?
|
|
|
|
|
Mohammad Dayyan wrote: Do you have any examples ?
Have a look at it[^]
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
|
Hey Manas, he's asking about speed and you send him off to MSDN, for shame. I use that only when all other avenues are exhausted.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mohammad Dayyan wrote: I saw somewhere that obj1.Equals(obj2) is faster than obj1==obj2
First of all, that depends on the type of the objects. That will decide which operator or method will be used.
If there is a difference in performance, it's because they don't do the same thing. You should find out which one that does what you want, because it's totally irrelevant if the method is fast if it doesn't do what you need it to do. That's like saying that "you should use addition instead of division, because it's faster".
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you Guffa.
For example when we wanna use two string Object which one of them is faster ?
|
|
|
|
|
The == operator first checks if the references are the same, so if you are comparing a string instance to itself (or comparing two null references) that would be faster. Otherwise they call the exact same private method to do the value comparison, so the difference can only be marginal.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
It depends on how it's implemented in the object being compared. Have a look at operator overloading for == and overriding the Equals(object obj) method for the other. The results could be the same or very different, as can the execution times.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|