Create keyboard short-cuts for Toolbar Control in VB6 - vb6

In my VB6 project, I'm using only Toolbar Control in main MDI From (Not menubar), The Toolbar has big pictures denoting actions like New, Save, View, Help etc. I wanted to know if there is any way to create keyboard short-cut for these actions. As far as I know, properties of Toolbar control of MS Windows Common Controls 6.0 isn't showing any relative option to do this. As MDI form doesn't have any key events, I can't create short-cuts by associating keys as well. I don't want menu bar in my form as it has very few items so only Toolbar makes the job. Please suggest any idea to have short-cuts for toolbar buttons...... :-| Thanks in advance.............

One way is to use a local WH_KEYBOARD hook, this article explains how (and provides a library).

Add a key event to your form. You could then process the short cuts by having them call the same function that would have been called on the mouse down event for the menubar.
For example you might have something like
public sub SaveItem_Clicked()
DoSave()
end sub
Then in your keypress check for Alt+S etc, and have it call DoSave()

Related

How to disable the navigation keys on Inno Setup installer GUI?

Is there a way to completely disable the navigation hotkeys on the installers created by Inno Setup?
Currently pressing B is like like clicking on the BACK button, and pressing N will get you to the NEXT page. I would like to disable this behaviour, so the installer is not reacting to these keys, and maybe other navigation keys which are there.
I'm adding a component search ability on the components page. These hotkeys were breaking it. As if someone is searching for a name that is containing either N or B, it was switching the page, totally ruining the functionality I added there.
First this is a bad idea. The keyboard accelerators are useful and they are absolutely needed for example by blind users.
If the accelerators break your search functionality, then you have implemented it incorrectly. Have you noticed that if you type the hotkeys on input boxes, the keys correctly type into the box and don't trigger the buttons? You seem to have an XY problem.
Anyway...
The keyboard accelerators are controlled by adding the & symbol in control caption before the letter, that should work as the accelerator. In the GUI the letter is then underlined (after you click the Alt key).
For example, this is how the buttons are defined in the Default.isl:
ButtonBack=< &Back
ButtonNext=&Next >
ButtonInstall=&Install
Just remove the &, if you do not want them. Either modify the Default.isl or override the caption in the [Messages] section in your .iss.
Related questions:
How to add access key to button in Inno Setup
Why do we use '&' character in Inno Setup?

events for right click detection in Outlook and Power point

In office applications i want to get the word on which the user right clicks.
i was able to get for Excel and Word. in outlook and PowerPoint i am not able detect the right click event.
In outlook i want to detect right click on a word in mail body.
In power point i want to detect right click in a slide content.
In outlook i have tried the events:
ItemContextMenuDisplay,
AttachmentContextMenuDisplay,
FolderContextMenuDisplay,
ContextMenuClose,
StoreContextMenuDisplay,
ViewContextMenuDisplay,
In power point i have tried:
WindowBeforeRightClick,
can somebody help me with the events to be used?
I will try to answer the Outlook part.
The Outlook object model doesn't provide any events for that. The only possible solution is to add your control to the context menu and handle the getVisible or getEnabled callbacks. Thus, you will be aware when the context menu is going to be displayed. But it seems MS doesn't provide the required IDs for that menu, see Extending the User Interface in Outlook 2010 for more information.
See Office 2013 Help Files: Office Fluent User Interface Control Identifiers
In the case of PowerPoint, WindowBeforeRightClick is the correct event.
You would find that setting Cancel = True in the handler for that event only works if the right-click is on the slide itself. On a shape or within a text range this fails to work as expected.
Workaround is the lock the screen and switch to a different view and back and then update the screen to prevent the contextual menu from appearing for the shape/text range.

How do I add a window from the resources as a child window?

I am creating a windows using win32:
HWND mainWnd = CreateWindow(...);
Now I can add gui elements as children of mainWnd. However this soon becomes a bit tedious and I want to use the designer built into Visual Studio to help me.
I noticed that under Add Resource there is a Dialog entry. Among the dialogs IDD_FORMVIEW seems the most general so I added one of these. Next I added gui elements to it using the designer.
Now I want to use this as a child of my mainWnd. How do I do this?
I found some examples using DialogBox, but I do not want a separate dialog, I want this window as a child of my mainWnd.
The designer in Visual Studio is appropriate for creating dialog boxes, not arbitrary windows.
That being said, there are a couple of approaches (in increasing order of difficulty):
Make your main window a dialog. Petzold's book has an example of using a dialog as the main window of the program. (If I recall correctly, it's the calculator example.)
Create the dialog and, before you show it, change its style to WS_CHILD, change its extended style to WS_EX_CONTROLPARENT, and parent it to your main window. For all the navigation stuff to work, you'll have to add IsDialogMessage calls in your message pump. This is do-able, but it's likely hard to get everything working well.
A mixture of 1 and 2 where you create one dialog for your main window, then create a second dialog for the content (with DS_CONTROL), and put the second dialog in the first. I've never tried this approach myself, but it seems like it should work.
Write your own code to parse the dialog resource and create the child windows, which is basically re-doing a lot of the work that CreateDialog does for you.
Given your desire to use the GUI to design the UI, I suspect only the first solution is simple enough that you would be interested.
Use the CreateDialog API to create the window from the resource. If you do not want it to look like a dialog then remove the titlebar style from the resource properties.
To use a dialog created from a dialog resource template you have to specify the DS_CONTROL window style in the template.
Read more about dialog boxes here.
Dialog resources are explained here

How to associate Click to Form Control as was previously done to ActiveX Control?

In Excel 2010 for Windows, I associated a Click event to an ActiveX Control. In Excel 2011 for Mac, I understand I must use Form Controls rather than ActiveX Controls. How do I associate a Click with a Form Control command button? I don't seem to be able to get at the Properties of a Form Control as I previously did with an ActiveX Control.
This assumes that Mac Form Controls act like Windows ones. When you first create the button, you'll see the Assign Macro dialog. If you've already created the macro, you can select it then:
If you want to assign the macro later, you need to get the Assign Macro dialog. In Windows, you'd right-click like this:
I'm realizing this is not my most helpful answer ever, but hopefully it's good enough.

Using old toolbars in Excel 2010 and Windows 7

I have a toolbar with some actions linked to macros in Personal.xls. I want to use the toolbar in Excel 2010 under Win7, but it insists C:\Documents and Settings\user\App...\PERSONAL.XLS doesn't exist. Quite right, they've changed the %AppData% location to C:\Users\user... And I can't put a copy of PERSONAL.XLS in the old place because C:\Documents and Settings\ is special-cased in Windows 7, and it's a forbidden place to everyone.
My question: How can I reset the macro linked to the toolbar buttons?
You used to be able to access
the Commandbars collection to get a command bar
The Controls collection of the command bar to get a control (button in this case)
The OnAction property of the control to identify the linked macro.
But OnAction doesn't seem to be a supported property for Excel 2010.
Any suggestions?
I'd much rather relink the toolbar than create a new custom ribbon tab. The toolbar buttons don't waste the APALLING amount of space custom ribbon items take up, and the custom icons on my toolbarare meaningful. Subsiduary question: Are there simple ways to create custom designs for custom ribbon items?
Looks like I didn't investigate closely enough. "OnAction" might not appear in the Object Browser, but it is available, and can be used to reset the associated toolbars. It didn't seem to work using the Immediate window, but does work within code in a module.
Cheers folks...

Resources