Barsdi.exe Customizes the Toolbar ControlID: Q125683
|
The sample BARSDI demonstrates how to provide Customization features for the Toolbar Common Control. The Toolbar Common Control under Windows 95 provides Customization features that are useful when the user needs to change the toolbar control's buttons dynamically (add, delete, interchange, and so on, buttons).
The following file is available for download from the Microsoft
Software Library:
Barsdi.exeRelease Date: Apr-21-1999
Q119591 How to Obtain Microsoft Support Files from Online ServicesThere are two ways the user can customize the toolbar:
// The initial set of toolbar buttons.
TBBUTTON tbButton[] =
{
{0, IDM_FILENEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{1, IDM_FILEOPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{2, IDM_FILESAVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{3, IDM_EDITCUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0},
{4, IDM_EDITCOPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{5, IDM_EDITPASTE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{6, IDM_FILEPRINT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0},
{7, IDM_ABOUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
};
// Buttons that can be added at a later stage.
TBBUTTON tbButtonNew[] =
{
{ 8, IDM_ERASE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{ 9, IDM_PEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{10, IDM_SELECT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{11, IDM_BRUSH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{12, IDM_AIRBRUSH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{13, IDM_FILL, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{14, IDM_LINE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{15, IDM_EYEDROP, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{16, IDM_ZOOM, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{17, IDM_RECT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{18, IDM_FRAME, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{19, IDM_OVAL, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
};
// The bitmap that is used to create the toolbar should have all
// tbButtonNew + tbButton buttons = 20 in this case.
// Use tbButtons array to create the initial toolbar control.
// Once the user starts to customize the toolbar, process the WM_NOTIFY
// message and the following notifications.
// The toolbar control sends a WM_NOTIFY message to the parent window
// during each process of the customization.
LRESULT OnMsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam,
LPARAM lparam)
{
LPNMHDR lpnmhdr;
lpnmhdr = (LPNMHDR)lparam;
// Process the QUERYINSERT And QUERYDELETE notifications
// to allow the drag/drop operation to succeed.
if (lpnmhdr->code == TBN_QUERYINSERT)
return TRUE;
else if (lpnmhdr->code == TBN_QUERYDELETE)
return TRUE;
else if (lpnmhdr->code == TBN_GETBUTTONINFO)
// The user has brought up the Customize dialog box,
// so provide the control button information to
// fill the list box on the left side.
{
LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam;
char szBuffer [20];
if (lpTbNotify->iItem < 12) // 20 == the total number of buttons
{ // tbButton and tbButtonNew
// Since initially we displayed
// 8 buttons.
// Send back information about the rest of
// 12 buttons that can be added the toolbar.
lpTbNotify->tbButton = tbButtonNew[lpTbNotify->iItem];
LoadString(hInst,
NEWBUTTONIDS + lpTbNotify->iItem, // string
//ID =command ID
szBuffer,
sizeof(szBuffer));
lstrcpy (lpTbNotify->pszText, szBuffer);
lpTbNotify->cchText = sizeof (szBuffer);
return TRUE;
}
else
return 0;
}
}
Additional query words:
Keywords : kbfile kbsample kbCtrl kbSDKWin32 kbToolbar kbGrpUser kbWinOS95
Version : WINDOWS:
Platform : WINDOWS
Issue type :
Last Reviewed: April 23, 1999