How can I remove keyboard focus from a button on User Control after clicking it, in a vb.net PowerPoint add-in? - vb.net

I have a vsto add-in for PowerPoint (vb.net) which includes a User Control with several buttons.
After clicking any of those buttons, or the User Control itself, I can't immediately use 'Ctrl' keyboard shortcuts, like Ctrl+C. It seems that the button or the User Control gets the focus. If I click on the slide, 'Ctrl' keyboard shortcuts work again.
Is there a way that I can take the focus away from the Button / User Control, in my Button1.Click event handler, in order to be able to use Ctrl+C right away? Or a way in which I can place the focus on the PPT Presentation?
I have searched and tried a ton of different methods, with no success...
PS: One observation I have made is that if instead of a Button, I click a Panel within my User Control, I do not have this problem.
Another observation is that while I can't use 'Ctrl' shortcuts right after clicking the button, 'Alt' shortcuts continue working fine.

Related

Lock ribbon button in VB.NET

I am developing a application in VB.NET. The user interface contains a ribbon tab with a few ribbon buttons. On each ribbon button click event, the application will execute a process.
When a process being executed, I want to lock the click event of other ribbon buttons. It means, the user should not be able to pick the other ribbon buttons.
I do not find the lock property for ribbon buttons. To avoid the button getting grey, I do not want to disable the button. please provide your suggestion.

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.

Click differences between text box and a button

On a form where I display data, if the user clicks the text box I open a virtual keyboard (form) and allow them to click buttons to enter data. When this virtual keyboard is opened, if the path to open was from clicking a text box, the first click in the new form (virtual keyboard) is ignored. If the virtual keyboard form is opened from clicking a button (from the first form), it works fine. I can't find a difference between triggering the virtual keyboard form from either control.
It seems to me that your issue is one of focus. When you trigger the virtual keyboard form to open because of the textbox click, you are somehow immediately returning focus to the caller, and not to the newly opened form. Therefore, you might need something as simple as:
myForm.Focus()
...at the end of the code that is opening the form.
I say this because the first click is "ignored", as you say. I would guess that it's actually consuming that first click as a focus event, and then you get the clicks you want registered as you want after that.

How to add button to word 2007 document, and handle click event with VBA?

How do I:
add button to my ms word 2007 document (i would say this would be trivial task, but can't even figure THIS out)
handle click event of this button in my VBA script
set text of my text control (with tag "text1")
I don't know if it is what you intended, but to add a button in the document, open the Developer tab. Click the Legacy tools folder (in the Controls group) and click the Command Button (Active X Control). This will put a button in the document and make Word go into design mode.
Double-click the new button and you will enter the VBA editor in the event handler for the button.
Enter code to manipulate the text in TextBox1:
TextBox1.Text = "Hi there, VBA master!"
Click the design mode button to exit design mode, and you're good to go; click the new button to set the text.
If you meant to add a button in the ribbon? A little more complicated, but not that hard. Leave a comment, and I'm sure we can work it out as well.

Right Click event not firing in VSTO code for PowerPoint 2010

I'm attempting to add a Context Menu option to PowerPoint 2010 that only appears when text is selected. Unfortunately the WindowBeforeRightClick event does not seem to fire if the mouse is inside of a TextBox.
Is there a different event I need to be listening to or a better way to add that context menu?