Using C#, I made a form maximized without showing the toolbar, but I need to disable all keyboard shortcuts (Alt+F4, Ctrl+Shift+Esc, etc) including Ctrl+Alt+Del. Can I do this?
You might want to use OnPreviewKeyDown (in WPF) event. Where you can identify what user entered and control based on key combinations.
Related
We are using the windows form application on a tough pad (touchscreen device).
want to show the on screen key board when user click the text box or any input control , rather then handling this event is there any way to handle this on the application level to show and hide the windows on screen keyboard
DevExpress editors, as well as regular .NET editors, do not affect OnScreenKeyboard's behavior. I suggest that you use one of the approaches described here to display it - Automatically pop up tablet touch keyboard on WinForms input focus.
Every windows hook is set to a particular window, or is global. And if I'm not wrong, even the textbox is a window. So, is it possible to set a low level keyboard hook to a specific textbox?
My goal is to capture keydown event on my textbox, but I figured out that using basic method I'm not able to capture the PrintScreen key, so I'm trying to do it another way.
Thanks
PrintScreen is a key that triggers a system function, e.g. Copy screen to clipboard. The key needs to work no matter what UI control has the keyboard focus and is getting the rest of the keystrokes, e.g. your text box. The way to capture this key is with a keyboard hook. See this answer. I believe the code works in both Winforms and WPF.
I am new to C# and Windows Programming in general. I am trying to right a application where I need to perform certain actions based on which key was pressed. Say, I want to generate a message whenever 'Shift' key was pressed. I was thinking I could simply detect the keypress and print the message.
While googling different ideas, I came across the term hotkey and the process of registering a hotkey. I am not sure why would someone want to register a 'hotkey' when they can simply detect whether a key or a combination of keys was pressed using simple key APIs. I read that hotkeys are useful when the form is out of focus, but I do not know what that means.
What exactly does a 'form' mean. For example, if I have Microsoft word open, and I have the edit menu open, and I press Ctrl-C, is that considered a hotkey. What if the edit menu is not open? I am treating the edit menu as a form.
Thanks
First of all a Form in Visual Studio is a Window. So if the form is out of focus it means the window is not selected.
As a beginner you can use the Events tab (in the properties of the window).
You can use the KeyUp, KeyPress, KeyDown events and use "case" to set different roles to different key presses.
I hope this was helpful.
Registering hotkey allows you to attach any method to run whenever in application you are placed now. Detecting key press is provided only when you are waiting for it literally.
Out of focus means that you are leaving some window and switch to another (in general Focus works on all UI controls - it is like, what the click/key press will be associated with - with button, form, label, etc).
Since Microsoft doesn't allow to replace the system's virtual keyboard, I've developed a custom virtual keyboard as a UserControl to be used inside my Windows Store App. My current problem is that the default virtual keyboard always pops up whenever a user taps a TextBox.
I've been searching for a solution to this problem since yesterday, but I couldn't solve it. My almost successful attempt was developing a TextBox with a transparent Canvas over it. When the user taps the Canvas, the focus is programatically transferred to the TextBox and my custom virtual keyboard is instantiated. However, if no physical keyboard is connected to the tablet, the system keyboard also pops up with this approach (over my custom keyboard).
The main reason why I want to use a TextBox is because that way I can preserve and use the already implemented caret function, but it is not mandatory.
Any input will be helpful, thanks.
There are a couple of things you could do:
There are events for when the keyboard shows up, check those and see if you can prevent it.
You could implement a custom TextBox that suppresses OnPointerPressed event so that the TextBox is never focused. There are a couple of other things you'll need to do (such as prevent tabbing into it giving focus by setting IsTabStop=false.
You could implement a custom TextBox from the ground up (that looks and acts like a TextBox).
I think the second option is the easiest and most interesting option to try.
Edit: You could also give your TextBox a DependencyProperty that you set the current Page to via bindings. In the TextBox's OnGotFocus event, set the visual state to "CustomFocus" (or whatever you call it), then call Page.Focus();
I'm trying to determine whether or not a user left the WPF TextBox using the keyboard or the mouse.
If I decide to monitor the TextBox for certain keys being pressed, what are the keys for which I should watch? Put another way (hence the question title):
Question: With what keys can a user possibly leave a WPF TextBox?
Is it only Tab , or are there other keys to consider?
Don't forget about
Shift-tab
Arrow keys (depending on focus)
Alt menu option key combinations
Alt-tab
Windows key
tab by default. However, In windows forms (including WPF) you have full control over everything so the keystrokes/keystroke combinations that could cause a control to lose focus is virtually limitless. It would probably be fairly easy to see if anything specific could cause a specific control to lose focus, but covering all possibilities is impractical in the general case.
Also, have you considered how to handle voice recognition software that lets a user navigate a screen?