I am currently a developer working on a very task specific application; the user(s) are often multitasking so they can often make errors inputting data. The nature of the task makes notifying them of those imputation mistakes important. We currently use a combination of panels and labels and/or a small label at the bottom of the application in order to notify them of something happening. In the near future we will be tasked to update interface for the application.
Recently while looking up an unrelated question I came across the following question:
click here for link the answer caught my eye and setting the owner’s handle to zero (null) did indeed do what the author asked.
Since I have only recently started working with importing and working with unmanaged code in C# I was wondering if there were any “side effects” of using this method. I of course realize that the user could cause the application to open a ton of message box(s). I have in the past attempted to use a thread-safe message box and found the requirement of our application always being on top was an issue (the location of the message box was hidden by the application).
I was able to take to test the code against the requirement, and it appears to have similar issues as the method I found but appears we could work around those issues. I did think of something that could be done, I realy need to figure out how to determine where on the screen the message box will be displayed.
In order to address Jim's concerns one has to understand that the application that is running is processing data continously. So currently anything that locks the main thread, can cause problems processing this data, which is task critical. We get around this problem using labels, but with our future task I am looking for a more streamline approach to present these error messages. The main problem is the solution also must not additional overhead to the application. Some additional tid-bits of information is that the system is used on a closed network.
I suppose the short question would have to be, are there any negatives of using this particular method, to show a non-blocking messagebox in C#?
There's no particular technical problem with displaying modal message boxes by setting the window handle to null. I question its use as a UI error message indication, because it doesn't prevent the user from continuing in the face of error.
Modal message boxes that make the user hit OK and then correct the error make for a terribly clunky user interface. But a popup that might be hidden and lets the user keep going is just as bad. There are much better solutions, some of which are shown in the validation examples for Windows Forms (and, presumably WPF).
Related
This is related to my other question.
I used the OnStructureChanged event to detect that the 'Help' window popped up in the 3rd party application that my application is writing data to. I need my application to pause while the end user resolves the data issue in the 3rd party application, then I need my application to resume once the end user closes the 'Help' window. (Either I need to detect that the 'Help' window was closed or I need to display a message box and use the DialogResult to trigger my application to resume).
I've never encountered something like this before. I don't know if it's possible to do what I want to do. If it is possible, I don't know where to start.
Advice?
UPDATES:
I have only used Threading once before and I think it was a fairly "easy peasy" usage, I pulled it off without much effort, considering I'd never used Threading before. I'm playing around with Threading for this issue right now. There's a good chance I've implemented it incorrectly, but my app isn't functioning correctly anymore...I don't know if I'm even playing with the correct tool.
I had to just keep moving with the project - deadlines, you know...
I ended up using UI Automation to detect the "Help" window, then I showed a message box giving instructions to the end user. I check the MessageBox's DialogResult and continue processing based on that. It might not be the "best" way to skin the cat, but I'm a noob and I have a deadline, so I did what I needed to do to keep moving.
I am writing an application in c# to lock or freeze all programs untill user enters a value in the app's textbox and clicks ok.
The purpose of the app would be to get people to enter their time.
As far as I know you can set it to top most but they can end the app with task manager so am stuck here..
formName.TopMost = true;
Any help would be appreciated
Yes, that's correct. The Windows operating system allows multiple programs to run at one time. What you're experiencing is entirely by design.
If I remember correctly, the TopMost property applies only to windows in your process, and as you mention, it's all quite irrelevant: the user can still kill your application using the Task Manager.
There's no legitimate way of getting around that. It's not a "limitation", it's a feature. Any app that prevents itself from being closed by the Task Manager is treading dangerously closely on the category of software that we call malware. Nothing good can come out of pursuits like this.
Relevant reading: The arms race between programs and users
Perhaps a good compromise solution is to make your window/form actually top-most and disable the Close button so that the user knows they shouldn't try and close it. This is almost always enough to stop a user that is not determined to end your application by any means necessary, and that's about all you should ever be concerned with.
See the sample code here for how to make your window/form always appear on top of other running applications by setting the WS_EX_TOPMOST flag or toggling HWND_TOPMOST.
I've also already written a detailed answer here about disabling the Close button the correct way by setting the CS_NOCLOSE class style.
Recently, I have been trying to get the built-in Windows 7 narrator/screen reader to be compatible with my WPF app. There is very little info about this, but what I have read is that I can set an attached property (AutomationProperties.HelpText, AutomationProperties.AutomationID).
The problem I am having is that the UI contains a progress bar and the current progress value is periodically read out by the screen reader as it changes. In this case, reading out the progress is not desirable but I cannot find a way to turn this off. I thought maybe I could set this by accessing the AutomationPeer associated with the element, but this doesn't seem to be the case (I can force an event to be raised, but I cannot have it ignore an event).
Does anyone know of a way to do this?
This is something that's typically controlled by the screenreader itself, via user settings/options, not something you can do at the application level. Narrator, which comes with Windows, is a fairly basic screenreader; think of it more like a notepad or wordpad level compared to a screenreader like Jaws or NVDA, which are more like Word. Narrator has minimal options, while the other two likely have all sorts of options that the user can use to customize when the screenreader speaks out specific events.
So, long story short; there's nothing you can do here. Ensure that the events are sent, that way a screenreader can chose to read them or not read them, as the user directs.
Also, keep in mind that Narrator is a basic screenreader, most users will actually be using something like Jaws (which costs $800 or so) or NVDA (free!), so consider testing with those to get a closer feel for what a real-world screenreader user would experience.
I've been teaching myself how to use messages with Window's APIs, and have actually been doing very well learning them. Problem is, I can't figure out how to receive a message from another application to start code within mine.
Essentially, what I want to do is allow others using a commercial application to click the save button (on the commercial application), and have my application stop the save message, prompt the user, and from that either cancel the save to allow them to continue, or allow the save (which I know how to do now through messages).
I just need to know how to catch a message, and stop it. If anyone can point me to an API call, or function, or just documentation that may help, please do.
Check out Detours by Microsoft Research. It's possible, but not simple. Also, look into how client-side game cheats are performed. I will not link any of them here, but they are out there. That's essentially what you want to do.
I think you'll need to attach your own application to the running process the same way a debugger would... Unless the commercial application has a custom method of plugging into their architecture to do this.
The next question is... do you want to proceed down this path.
I have a simple contact us / comment from in my website and this form will send email containing the comments, etc after it is submitted. I have used NoBot control from ajaxcontrol toolkit for several times but it seems that this control did not prevent the spam/bot attack 100%.
The client insist that this form should not have any capcha code or something that users have to insert in the form. So what is the best way to handle the spam/bot attack for my current case.
Thanks.
Without a captcha there is no 100% way of stopping all spam. (or even with a captcha)
one method would be to put an input type=text on the page and hide it using css, then if it's filled in when the form is submitted it's spam, any normal user would never even know about the field.
Outside of a captcha, the key to stopping bots on small sites is to do something custom. Bot-writers know their work, and they'll have canned scripts capable of defeating the common and even most of the uncommon systems out there. You need to do something unique. It doesn't even have to be that complicated. The person who created this very site was able to get by running a popular blog for years by simply asking his users to type in the word orange.
I want to also point out that this doesn't mean you should start from scratch. As with all security-related code, if you try to do it yourself you'll likely get it wrong. What you want to do is find a system that gives you source code and customize it for your site, so that existing scripts that know how to defeat that system will no longer work.