|
Hey,
I am writing a program, and one of the functions of this program is to simulate holding down of two keys on the keyboard. I am not sure how to go about this. I don't think the sendkeys function is what I am looking for, because it only sends the keystroke, not holds it down. Is there any sort of way to do this?
|
|
|
|
|
Have you tried searching Google? A quick search found the answer for me. Please do more research next time before posting.
Hogan
|
|
|
|
|
|
no because if you can't answer a question like this, you don't deserve to get a position writing really bad C# code.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
Come on dan - what was the original question? We're intrigued now...
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
He posted a sample code fragment that he'd been presented with in an interview and asked what the problems were with the class. The impression that came across was that he was in the interview at the time and had been given an internet connection. BTW - the mistakes were glaringly obvious; they weren't tricks and I would doubt the coding ability of anyone who didn't spot them. There were only a dozen lines of code after all, and he was told that there were 3 problems.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
For starters:
It should not use a destructor to close a file stream because destruction of the object is non-deterministic. It will hold onto the open file stream until the GC decides to collect it which might not happen before the application closes. It should implement IDispose instead.
|
|
|
|
|
If you can't answer this then you don't deserve a career doing this.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I'm curious as to what the question was
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
I wondered that myself when I cruised through this forum earlier.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Me too! I wished they wouldn't do that...
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
I wished they couldn't do that as soon as there is some reply present.
|
|
|
|
|
Malcolm Smart wrote: Me too! I wished they wouldn't do that...
I guess the poster felt shamed into deleting their message after being told twice that they don't deserve a career as a programmer. Must have been a helluvah post to get that kind of response.
Personally, I wouldn't take on the responsibility of telling someone that regardless of how lamebrained I found their question to be.
|
|
|
|
|
I rather suspect that the OP was in the interview at the time. See my explanation further up the thread as to what the question was that prompted the vitriol.
As to why it was suggested that they weren't suited to a career in programming; they couldn't see obvious deficiencies in a 12 line piece of code. It was a basic test and they just didn't have a clue - would you really want to work with somebody like this. I wouldn't expect to become a plumber with my level of knowledge in plumbing and I don't see why we should put up with people wanting to become programmers when they don't have the basics down.
Now, if the poster goes away and comes back with improved coding skills then I would be delighted.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
They immediately get nominated for a Darwin award.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
This is the normal behaviour:
When you double-click an the Visible property of a UserControl , Visual Studio will emboldens the altered property, and enable the Undo menu item, and even prompt you to save if you attempt to close - all indicating that a change has been made.
But during DesignMode :
When I programmatically (using ControlDesigner ) change the Visible property of a MyUserControl , there is no indication that a change has been made, and Visual Studio does not save the changes. Even though I can see that the property value has changed, it doesn’t go bold or get serialized/saved.
How do you fix it please.
If I'm missing some detail, please let me know.
Any comments are welcomed.
Soog.
|
|
|
|
|
Hello,
A bold entry at design time property, means that the actual value is != the DefaultValue (Which is an Attribute on the property).
It also means, that this property is written in the "InitializeComponents()".
This behaviour is only possible if you change the properties value over the Designer, it will have no effect id you change it programmaticaly.
All the best,
Martin
|
|
|
|
|
Thank you for the prompt reply, Martin.
But, there most be a way to force the property to a Dirty state, and make the IDE serialize/save it. This behaviour is vital to the TabControl that I'm working on, because the Visible property of a currently selected TabPage most be programmatically changed through the TabControlDesigner .
Again, any comments are appreciated.
Thanks in advance,
Soog.
|
|
|
|
|
Hello,
I think in this case:
TabControl, saves the SelectedIndex, not the Visible states of the TabPages
All the best,
Martin
|
|
|
|
|
I see, I guess.
The thing is, I don't know how to go about implement this . I've been trying, but don't quite understand it .
Thanks again,
Soog.
|
|
|
|
|
I think, you have to explain what you want to do a little more detailed.
Maybe show us some codesnipped, what you have done so far!
All the best,
Martin
|
|
|
|
|
Yata!
I did it .
The solution, in one word (or phrase) was DesignerTransaction .
After inspecting the Add and Remove events in my DesignerControl , I devised what you can see in the following snippets, which works perfectly:
[Designer(typeof(MyTabControlDesigner))]
public class MyTabControl : UserControl
{
protected override void OnMouseDown(MouseEventArgs e)
{
if ((tabPageNext = GetHitTest(e.Location)) != null)
{
tabPageLast = TabPageFocused;
if (DesignMode)
{
ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService));
ArrayList a = new ArrayList();
a.Add(tabPageNext);
s.SetSelectedComponents(a);
}
else
OnSelectionChanged();
}
base.OnMouseDown(e);
}
internal void OnSelectionChanged()
{
TabPageFocused = tabPageNext;
}
internal bool SelectionIsFresh()
{
if (TabPageFocused != tabPageLast)
return false;
tabPageLast = new TabPageEx();
return true;
}
internal class MyTabControlDesigner : ControlDesigner
{
void OnSelectionChanged(object sender, System.EventArgs e)
{
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService));
DesignerTransaction dt;
if (!tabControl.SelectionIsFresh())
return;
dt = dh.CreateTransaction("Select MyTabPage");
cs.OnComponentChanging(tabControl, null);
tabControl.OnSelectionChanged();
cs.OnComponentChanged(tabControl, null, null, null);
dt.Commit();
}
I hope this helps anyone else in a similar situation.
Thank you for your assistance, Martin , the only person who cared during my plight .
Soog.
|
|
|
|
|
Well Done!
Happy it works for you now!
Got my '5' for sharing it with the community.
All the best,
Martin
|
|
|
|
|
Hello,
I currently have the problem that I want to update the contents (a string) of an item of a listbox with a textbox. Best would be on-the-fly so I tried listBox1.Items[listBox1.SelectedIndex] = textBox1.Text in TextChanged.
However I also want to be able to select which item to update by selecting the item in that very listbox. So I do something like textBox1.Text = listBox1.Items[listBox1.SelectedIndex] in SelectedIndexChanged of the listbox. (I say "something like" because the information includes other numbers that are also stored in a list along with the text.)
The problem with that is that selecting an item changes the text in the textbox and that again updates the item which implicitly calls an SelectedIndexChanged again (or so it seems). And during that updating of the listbox it happens that the selectedindex changes to -1. Which is a problem if you try to read that item...
I was wondering if there is an easier/better/cleaner way to accomplish what I try?
Stephan
|
|
|
|