To provide toolbar-style command buttons on the Properties palette, implement the IAcPiCommandButton and IAcPiPropCommandButtons interfaces. You provide a class that implements IAcPiCommandButton for each button you define. The IAcPiCommandButton interface provides a button's bitmap, state, and style to the Property Inspector. To define your button's behavior, you implement the IAcPiCommandButton::Execute() method. The Property Inspector calls this method when a user clicks your button.
The Property Inspector accesses your button definitions by calling your IAcPiPropCommandButtons::GetCommandButtons() method implementation. You simply return a SAFEARRAY of IUnknown pointers that reference your button definitions. Command buttons generated through this method display on the Property Inspector between the category list and the status bar.
An easier way to implement command buttons is to derive from the IAcPiPropCommandButtonsImpl template class and declare a command button map. The template class implements the IAcPiPropCommandButtons::GetCommandButtons() method. This implementation generates buttons at runtime that use the configurations you specify in the command button map.
Each map entry provides the following information for a single button:
A button can specify two bitmaps: one that displays when the button is enabled, and another that displays when it is disabled. Bitmap types are defined in the Windows PICTYPE enumeration. Bitmap resolution is expressed in a string format. A command button's size is 16 pixels wide by 15 pixels tall. If your bitmap's resolution is larger than the button, only the upper-left 16° 15-pixel matrix displays.
A button's style indicates whether it is a typical Windows click button or a dual-state toggle button. To define a toggle button, you specify a value of type long that sets the Windows-defined BS_CHECKBOX bit (0x00000002). Otherwise, you should specify NULL.
The following example declares a toggle button with a 16° 15 enabled bitmap of type bitmap, no disabled bitmap, and an execution routine named MyButtonProc :
BEGIN_CMDBTN_MAP() CMDBTN_MAP_ENTRY(IDS_CMDBTN1, “IDB_CMDBTN1ENABLED”, PICTYPE_BITMAP, NULL, PICTYPE_UNINITIALIZED, 0x00000002, MyButtonProc) END_CMDBTN_MAP()