Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Excel add in development in C++ Aplications in finance - Dalton S.

Dalton S. Excel add in development in C++ Aplications in finance - Wiley publishing , 2005. - 425 p.
ISBN 0-470-02469-0
Download (direct link): exceladdindevelopmentincand2005.pdf
Previous << 1 .. 104 105 106 107 108 109 < 110 > 111 112 113 114 115 116 .. 168 >> Next

Note: Excel does not permit the deletion of short-cut menus, however, these can be disabled and re-enabled with the xlfEnableCommand function.
If the function cannot find or delete the menu, it returns #VALUE!, otherwise it returns ‘true’.
266
Excel Add-in Development in C/C++
Warning: The action of SubMenuItem is intended, according to the XLM reference manuals, to delete the specified sub-menu on the given menu. Instead it deletes the menu itself. Use xlfDeleteCommand to delete a sub-menu.
Note: Remember to store the information needed to restore menus and undo changes, especially when deleting built-in menus. Simply restoring Excel defaults may delete other custom menu items.
Example 1
The following code fragment deletes the Data menu.
cpp_xloper BarNum(10); // the worksheet menu bar cpp_xloper Menu("Data");
Excel4(xlfDeleteMenu, &RetVal, 2, &BarNum, &Menu);
8.11.13 Deleting a custom menu bar: xlfDeleteBar
Overview: Deletes a custom menu bar.
Enumeration value: 200 (xc8)
Callable from: Commands only.
Return type: Boolean or error.
Arguments: 1: MenuID: The menu bar ID number returned by the call to
xlfAddBar.
If called with an invalid ID the function returns the #VALUE! error.
8.12 WORKING WITH TOOLBARS
Toolbars (also known as command bars) provide the user with a number of graphical controls, typically buttons, that give short-cuts to commands. They can also contain list and text boxes that enable setting of certain object properties quickly.
This section only deals very briefly with the toolbar customising functions of the C API: it is recommended that you use other means to modify command bars if you intend to rely heavily on them. The functions and their argument types are listed and a little detail given, but no code samples. Excel’s internal toolbar and tool IDs are not listed.7 If you want to know them, you can fairly easily extract information about all Excel’s toolbars using the xlfGetToolbar and xlfGetTool functions (described briefly below) using the following steps:
1. Get an array of all toolbar IDs as text (both visible and hidden) using the xlfGetToolbar function, passing only the first argument set to 8.
7 For a full listing of tools and toolbar IDs, you should try to get a copy of a Visual Basic User’s Guide for Excel, which lists them all.
Accessing Excel Functionality Using the C API
267
2. For each ID in the returned horizontal array, call xlfGetToolbar again with the first argument set to 1 and the second set to the ID, to obtain an array of all the tool IDs on that toolbar.
The above section on customising menu bars provides a relatively easy way to provide access to commands contained within the DLL if you need to.
8.12.1 Getting information about a toolbar: xlfGetToolbar
Overview: Gets information about a toolbar.
Enumeration value: 258 (x102)
Callable from: Command and macro sheet functions.
Return type: Various. See Table 8.26 below.
Arguments: 1: InfoType: A number from 1 to 10 indicating the type of
information to obtain. (See table below.)
2: BarlD: The name as text or the ID number of a toolbar.
Table 8.26 Information available using xlfGetToolbar
InfoType What the function returns
1 Horizontal array of all tool IDs on the toolbar. (Gaps = zero.)
2 Horizontal position in the docked or floating region.
3 Vertical position in the docked or floating region.
4 Toolbar width in points.
5 Toolbar height in points.
6 Docked at the top (1). left (2). right (3). bottom (4) or floating (5).
7 True if the toolbar is visible.
8 Horizontal array of toolbar IDs. names or numbers, all toolbars.
9 Horizontal array of toolbar IDs. names or numbers, all visible toolbars.
10 True if the toolbar is visible in full-screen mode.
Values of InfoType 8 and 9 do not require a BarlD argument.
8.12.2 Getting information about a tool button on a toolbar: xlfGetTool
Overview: Gets information about a tool button on a toolbar.
Enumeration value: 259 (x103)
Callable from: Command and macro sheet functions.
268
Excel Add-in Development in C/C++
Return type: Various. See Table 8.27 below.
Arguments: 1: InfoType: A number from 1 to 9 indicating the type of
information to obtain. (See table below.)
2: BarlD: The name as text or the ID number of a toolbar.
3: Position: The position of the button (or gap) on the toolbar counting from 1 at the left if horizontal, or the top if vertical.
Table 8.27 Information available using xlfGetTool
InfoType What the function returns
1 The button’s ID number or zero if a gap at this position.
2 The reference of the macro assigned to the button or #N/A if none assigned.
3 True if the button is down.
4 True if the button is enabled.
5 True if the face on the button is a bitmap, false if a default button face.
6 The help reference of a custom button, or #N/A if built-in.
7 The balloon text reference of a custom button, or #N/A if built-in.
8 The help context string of a custom button.
9 The tip text of a custom button.
Previous << 1 .. 104 105 106 107 108 109 < 110 > 111 112 113 114 115 116 .. 168 >> Next