|
There is no TabIndex or TabStop as the form is receiving input from an IR controller as a keydown event.
|
|
|
|
|
I don't know if I fully understand your question. But in windows applications, only the active control with the keyboard focus can receive keyboard events. You need to set focus to the textbox (or whatever your control is) before you can send keystrokes to the control.
|
|
|
|
|
Update:
I have done some more experimenting and find the following. When the program is executed outside the compiler the child Form2 is created but the focus remains on Form1. When compiled with CTRL F5 the focus goes to the compiler.
Here is where Form2 is created: Form2=playMKV
Application.RemoveMessageFilter(this);
if (temp.EndsWith(".mkv")) // its a Matroska file
{
playMKV dlg = new playMKV(fname);
//if (dlg.ShowDialog() == DialogResult.OK) // not necessary as there will always be a result 1 or 0;
dlg.ShowDialog();
if (dlg.Number == 1)
{
string temp2 = "\x22" + fname + "\x22";
System.Diagnostics.Process proc =
System.Diagnostics.Process.Start("mplayerc.exe", temp2 + " /fullscreen /play /close ");
proc.WaitForExit();
}
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
Application.AddMessageFilter(this);
return;
}
I have tried delaying the this.Focus in Form2 as Luc suggested and it seems to make no difference.
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
this.Focus();
this.Activate();
this.BringToFront();
}
This Form2 closes on any keydown event there being two options:
1.the "Enter" key is hit or "Enter" is pressed on the IRcontroller in which case the key event is == 13 returning 1 to Form1
or
2.on any other key the Form2 is closed returning 0;
Form2 keydownevent
if (keyEvent.KeyValue == 13)
{
num = 1;
}
else
{
num = 0;
}
this.Close();
The program works without problem as long as I click on Form2 with the mouse.
|
|
|
|
|
Shameel
TNX for your input as it allowed me to solve the problem. I added an event handler to the listBox on Form2 and the focus was gained by the form.
TNX again.
|
|
|
|
|
Is there a reason you use Application.RemoveMessageFilter(this) ?
|
|
|
|
|
Yes. The message filter seems to stop the Form2 from receiving the IR commands. Although I have not test without it since implementing the newest changes.
|
|
|
|
|
I checked and the keydown event goes to the parent form and not the child unless the Message Filter is removed.
|
|
|
|
|
Hi
Do you know, if there exist a code (application), that capture all the text from the keyboard? Application should not be seen, so it should run in tray, like a hiden application, but it still capture all the text.
If you don't konw if that kind of application exists, maybe you have some suggestions how to made it.
Thnx
|
|
|
|
|
Write a global keyboard hook - here's[^] one example.
/ravi
|
|
|
|
|
such apps are evil.
|
|
|
|
|
Yeah, it's called a keylogger and NO we're not going to tell you how to write one.
|
|
|
|
|
Hi
I have a gridview that get it's data from a dataset;
I add a checkbox to this gridview as culumn;
now my user can choose each row;
How can i recognize that checkboxes that have checked by user and other value of that checked rows?
|
|
|
|
|
|
I almost lost some money today on a bet with a colleague arguing that the following Java code was just plain invalid.
if( this_thing == DING & that_thing == DONG ) {
thenGoDoTheOtherThing();
} Fortunately, he did not take me up on the bet! Turns out, for both Java and C#, when the & operator is used in this context the compiler stops treating it as the bitwise AND operator. Instead it treats it like the logical AND operator (&& ) except that it applies a slightly modified evaluation rule - where && stops evaluation as soon as it encounters the first expression that evaluates to false , & goes ahead and evaluates all the expressions regardless of what each component expression evaluates to. The logical AND still works as one might expect, just that all the component expressions are always evaluated. Here's an example:
class Program
{
static void Main(string[] args)
{
if (Eval1() & Eval2())
Console.WriteLine("Eval1() and Eval2() returned true.");
else
Console.WriteLine("Eval1() and/or Eval2() returned false.");
}
static bool Eval1()
{
Console.WriteLine("Eval1");
return false;
}
static bool Eval2()
{
Console.WriteLine("Eval2");
return true;
}
} And here's the output you get.
Eval1
Eval2
Eval1() and/or Eval2() returned false. Guess you learn something new everyday! I am not sure that using this feature is such a great idea though. Thoughts?
modified on Friday, December 4, 2009 3:31 PM
|
|
|
|
|
IMO, that it doesn't do the short circuit evaluation means that it actually is a bitwise AND, between two bools, but that doesn't make it any less "bitwise" or "AND", a bool is just 0 or 1 with nicer names after all..
|
|
|
|
|
Yep, it does indeed still do a bitwise AND of the boolean operands. See my reply[^] to OriginalGriff[^]'s post below.
|
|
|
|
|
Fortunately it should only work if (as in your example) both the parameters are bool - as it then performs a bitwise AND of the two results. Hence why it evaluates both rather than stopping when one fails.
It's still quite nasty though - I wonder if you can turn it off...
if ((dataTable.Rows != null) & (dataTable.Rows.Count > 0))
{
...
} would throw exactly the exception you are testing to avoid!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Yes. It does still perform a bitwise AND of the 2 boolean operands. Here's the IL for the sample code:
L_0000: call bool ConsoleApplication1.Program::Eval1()
L_0005: call bool ConsoleApplication1.Program::Eval2()
L_000a: and
L_000b: brfalse.s L_0018
L_000d: ldstr "Eval1() and Eval2() returned true."
L_0012: call void [mscorlib]System.Console::WriteLine(string)
L_0017: ret
L_0018: ldstr "Eval1() and/or Eval2() returned false."
L_001d: call void [mscorlib]System.Console::WriteLine(string)
L_0022: ret And I agree, it does seem to be a fairly dangerous operator. I'd be surprised if somebody deliberately used it with this explicit intent - chances are, in a majority of the cases its occurrence is a typo - and something the compiler won't even alert you about.
|
|
|
|
|
That is what the documentation says:
"Binary & operators are predefined for the integral types and bool. For integral types, & computes the logical bitwise AND of its operands. For bool operands, & computes the logical AND of its operands; that is, the result is true if and only if both its operands are true.
The & operator evaluates both operators regardless of the first one's value."
And now you can go and test/read up on the | operator...
|
|
|
|
|
Luc Pattyn wrote: And now you can go and test/read up on the | operator...
What about ^ ? One of the most underestimated operators ever.. except in cryptography of course.
On the other hand, I've never had to xor two bools together, I've only done it once and just for laughs
|
|
|
|
|
XORing bools isn't very useful for two bools, as you could as well compare them for (in)equality; XORing multiple bools makes more sense, not too many application domains will ever need it though.
However XOR is fundamentally different from AND and OR, as there is no ^^ operator, and no short-circuiting.
|
|
|
|
|
Luc Pattyn wrote: However XOR is fundamentally different from AND and OR, as there is no ^^ operator, and no short-circuiting.
Well of course not, that would be impossible, the result always depends on both inputs
|
|
|
|
|
Exactly, it isn't "destructive", it preserves the true (or false) probability, something AND and OR don't.
|
|
|
|
|
Just in the same way, we could use | or || for normal or "short circuit" OR.
|
|
|
|
|
Dear Sirs,
I would like to learn how to create Visual Studio (2008) addins. I thought I would start by making one that changes the color of the current line. This has proved to be very difficult. First, there are very few examples, so I go to the SDK. Second, it seems that the MSDN isn't consistent here. I don't know what I'm missing, but I see
DTE.get_Properties(String category, String page); in code, but DTE properties[^] lists it differently, as
DTE.Properties {get;} Whatever, I got past that, and now I use get_Properties(string, string) . So, I found out how to get general color properties:
Properties ps = DTE.get_Properties("FontsAndColors", "TextEditor");
Property fC = ps.Item("FontsAndColorsItems");
FontsAndColorsItems fcs = fC.Object as FontsAndColorsItems;
foreach (ColorableItems a in fcs)
Debug.WriteLine(a.Name); (the above listing gives all the different properties in Tools > Options > Environment > Fonts and Colors > Display items: )
****GETTING TO THE POINT****
But, what I need is to be able to access LOCAL color properties. A start might be to be able to set the font color or background color, or whatever, of the current selection:
Document doc = DTE.ActiveDocument;
TextSelection sel = doc.Selection as TextSelection;
Or something like that. Any suggestions?
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|