|
Thanks a lot, Bill.
As you said, I have no choice but to add click event handler to every control on that user control.
Best regards,
Zaw Min Tun
|
|
|
|
|
Does anyone know if there is a simple tray application that will provide a pop-up window that indicates that the caps lock in on?
I want to see the window at the bottom of my screen when the CAPSLOCK on and have it dissappear when the CAPSLOCK is off.
Otherwise; can anyone tell me how to write such an application using Visual Studio 2010 and C#?
Thanks in advance.
Joe
joe
|
|
|
|
|
There must be applets around that do that, I don't have any information on them though.
Creating something yourself would be very easy; polling the keyboard state at 1 or 2 Hz using Control.IsKeyLocked[^] seems the easiest way to do it.
|
|
|
|
|
I cannot find a simple CAPSLOCK pop-up program.
Thanks for the tip on Control.IsKeyLocked[^], but I am not sure how to write a tray app to monitor the keyboard. I need more specific direction on this.
joe
|
|
|
|
|
I am writing a small 2D game on C#2010 Express.
I am learning as I go.
I am using two computers.
The first is a Desktop with vista.
The second is a Laptop with xp.
My project runs good on the Desktop.
But after one click on the Laptop version, during debug,
the mouse quits responding.
I put breaks in various places in program but cannot seem
find where focus has gone.
It does not crash.
|
|
|
|
|
Here's something you can do:
When the app stops responding, click the "break" button in the IDE to break the program.
Then, open the "Threads" window from the "Debug" menu. Double-click on the main thread and then look at the "Call stack" window to determine in what function the thread is currently executing.
Whatever function the main thread is currently in is probably where it is hanging up.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
ok, i am going to try that, What I did find is I ran both computers side by side. put a break on refresh() and the paint call. In the one working you stopped at refresh then went immediately to paint call on resume. On the laptop it either took a =very long time to get to paint or you never get there and hang somewhere. Will try your suggestion now
|
|
|
|
|
when you say break do you mean "stop debugginh" I see no break on tool panel
|
|
|
|
|
sorry, I changed tools to expert and the break button showed up but I am having trouble finding the
the thread , however program breaks at 'application.run(new Form1()); and i don't think i should be there?
|
|
|
|
|
Joseph A Delinski Jr wrote: I am having trouble finding the
the thread
Did you mean you're having trouble finding the Threads window, or the main thread?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Threads window and main thread, both
|
|
|
|
|
I can infer, from one of your answers, that you are using WinForms, but in questions like this may I suggest you include in the original post a clear statement as to which of WinForms, WPF, DirectX, XNA, you are using.
best, Bill
"... Sturgeon's revelation. It came to him that Science Fiction is indeed ninety-percent crud, but that also—Eureka!—ninety-percent of everything is crud. All things—cars, books, cheeses, hairstyles, people and pins are, to the expert and discerning eye, crud, except for the acceptable tithe which we each happen to like." early 1950's quote from Venture Sci-Fi Magazine on the origin of Sturgeon's Law, by author Theodore Sturgeon: source Oxford English Dictionary on-line "Word-of-the-Day."
|
|
|
|
|
Yes I see your point, it is a Windows Form application. I believe the problem is that my
Laptop is to old to run program written on my desktop. The desktop framework has been upgraded with
the XNA as a possible feature. When I tried to do that (add XNA) to my laptop c# 2010 Express, I received an error that a sp# was needed and I couldn't get "that" upgrade to take. So I kinda give up and will see how my program runs on some friends newer machines. thanks for taking time to reply.
Joe
|
|
|
|
|
Hi,
I have 10 bool variables in a class. Instead of creating 10 bools, how to create a single bool and bit flags for remaining 9 bool variables inorder to efficiently use memory.
Can I have a code snippet in C# for this..
Thanks in Advance.
|
|
|
|
|
Why on earth would you need to do this? That's optimising beyond where you really need to go. A bool holds a negligible amount of memory, and the code you need to translate backwards and forwards from the bit flag would actually take up more memory than you would save in a single instance. Added to this that converting the bit flags takes clock cycles and you could end up with a less efficient program than just having nine bools.
|
|
|
|
|
I can think of plenty of reasons for this - none of which have directly to do with optimization (not for speed anyway).
For example,
- the flags are a field in a structure used in interop. (happens all the time)
- the flags are delivered as packed flags and later have to be passed on as flags. Saves a lot of setting up and tearing down to just leave them packed.
- when a switch over the packed flags (or a subset of them) is shorter and clearer than a massive tree of if's. (uncommon)
- when operations done on the flags can be done by short expressions of arithmetic and bitwise operations, and doing it manually with bools would create a huge mess. (ok this one is pretty rare, unless you write emulators)
|
|
|
|
|
But read the question asked. The wording there does not indicate that any of these are the reasons - hence why I asked why he was trying to do it.
|
|
|
|
|
Yes, his question doesn't really indicate anything, but your question sounds somewhat like it's never a good idea.
|
|
|
|
|
If a whole bunch of instances of the class are made then there could be a space saving. And if the instances are serialized and sent somewhere.
Regardless of concerns of "performance", grouping a bunch of related flags into an enumeration is a good design choice.
|
|
|
|
|
You may note that I carefully used the phrase "single instance". The point was to get the OP to think about whether or not they really needed to perform this optimisation.
|
|
|
|
|
Pete O'Hanlon wrote: to get the OP to think
You've been here long enough to know this is not possible
No comment
|
|
|
|
|
PIEBALDconsult wrote: Regardless of concerns of "performance", grouping a bunch of related flags into an enumeration is a good design choice.
The question implies unrelated booleans, as a compression technique.
Bastard Programmer from Hell
|
|
|
|
|
|
OP wrote: I have 10 bool variables in a class. Instead of creating 10 bools, how to create a single bool and bit flags for remaining 9 bool variables inorder to efficiently use memory.
It does.
Bastard Programmer from Hell
|
|
|
|