How to determine which form controls the keyboard input on VB.net - vb.net

I'm developing a VB.net windows application and I have some issues with the keyboard input.
My application has different forms and I'm showing and hidding them with the user interaction. One of the inputs comes from the keyboard, and here is where I have a problem.
When I hide a form and show the next one, most of the times the new-shown form does not receive the keyboard input until I click somewhere on it.
I assume that the problem is that the new form I'm showing is not the "selected application" for windows until the user interacts with it by clicking on it, but I don't know how to set this "property" by code.
I tried with focus and select on the whole form (Me.select/focus) and in some form's control (me.lbl_xxx.select/focus), but I did not get any result.
Can anyone explain me how to control which application/form gets the keyboard input on windows?
Thanks
David

You can't really interact with a label so the input focus won't be set properly.
Focussing a specific textbox on your form on the other hand should just work fine.

Related

Opened form won't reactivate after closing modal

Within VB.NET Visual Studio 2013
I have an mdi application with several forms. Only one form is open at a given time, then while the user enters amounts by typing in the control, the form is recalculating itself constantly via code.
I also have buttons above (on the mdiform) to open modal dialogs to enter certain information; the information entered is somewhat long, but at the end what I need from the dialog is the result of certain calculation.
That number (the result) should be shown on the opened form after the user close the modal dialog; but it is not happening unless I press the enter key so the form is again recalculated.
I am looking for a way that the form recalculate when the user close the dialog.
I tried everything at my disposal, "Activate", "a public sub", "raise an event", and many others, but the form is not recalculating, what happens is that the cursor is there on the last control the user works in.
The only way to see those changes is reloading the form, but it is not elegant.
Any help will be highly appreciated.
PS. I have looked everywhere about how to do it, but seems I am looking on a haystack
Please need help badly.
ariel

MFC Custom Keyboard DLL Accessed from Application Dialog Box

The overall goal is to be able to access a pop-up keyboard through an application that I am making in MFC.
I have created a dialog box with an empty text field. I would like to be able to click the empty field and have an onscreen keyboard to enter in the data field.
Is there list of functions or tutorials that anyone can provide me with to be able to perform this function? Ultimate I will be making the keyboard from scratch, so any guidance would be useful.
My first thoughts (I might be wrong someone might correct me if i am wrong.)
1)Create your Keyboard Ui in an MFC DLL and export the KeyBoard Functions like LaunchKB(Int screenx,int screeny) and CloseKB()
functions.
2)I would subClass CEdit and CRichedit such that when the edit control gains or loses focus it would call LaunchKB() function with windows ScreenX coordinates where the keyboard has to be displayed or CloseKB().
3) A callback function registered to dll ,which would get called for every click on the keyboard with characters clicked and these characters are to be displayed in the edit control.
This is just my thought ,there may be better ways to implement as well.

Triggering Visual Basic Keydown events without a specific function

I'm building on top of code that a previous developer has left me, and he left something that intrigued me quite a bit.
Basically on his menus, he has a TextBox to take in user input and a button next to it to submit the value of the TextBox (for example if the user wanted to select option 1, he would input 1 into the TextBox and click the button). However, the user could also press the Enter key while focusing the TextBox, and it would be treated as the submit button was clicked.
Now this is simple enough to do, but when I check the VB code behind the menu, there's no TextBox_Keydown(...) Handles TextBox.Keydown function anywhere, only the button click event. How is he doing this? He has several menus that are similar and I can't figure out how.
A standard dialog box, if not told to act otherwise, enter does default command button and escape does cancel. In VB look at the properties Default for the command button.
I discovered how he was doing it. He basically mapped the AcceptButton and CancelButton properties of the entire Windows Form to various button functions.

Turn off field programmatically in VB.Net

I'm creating an addin button in Arcmap via VB.net that when clicked, runs the identify tool. But I want only selected fields to appear in the identify dialog. I thought of hiding the unnecessary fields and then showing them again after the button is used.
Does anyone know how to programmatically turn off/on field?
you have to iterate the fields in layer and then set visible property into false .
see this link in
gis.stackExchange

How to capture response from Cancel or Ok Button in two different Applications?

With my Application (vb.net) I am trying to scan Excel files some of which have ActiveX Components.
When running my Application, I am getting a pup-up window in Windows Vista Environment with Office-2007 having button OK and Cancel button to proceed.
But my problem is the scanning is not proceeding even after I keep on pressing the OK button. Now I want to continue with my application while pressing the Cancel button; i.e. just to skip the file. Is it possible to capture the response from the cancel button? (As this is a message box from another application, i.e. either from Vista or Office-2007, I'm not sure).
My main motive is to just ignore the message box to proceed....
Can anyone please help me out there....
Thank you....
The DisplayAlerts property of Microsoft.Interop.Excel.Application may help here.
If set to FALSE then Excel automatically chooses the default option on pop-up boxes.
Whether or not this applies to ActiveX controls I don't know but it may be worth trying.