Article ID: 190982
Article Last Modified on 6/29/2004
HWND WINAPI CommandBar_AddRealButton (HWND hWndCB, HINSTANCE hInstance,
LPWSTR lpButtonText, int iWidth,
UINT dwStyle, WORD idButton,
WORD iButton)
{
RECT rect = {0};
TBBUTTON tbbutton = {0};
HWND hWndButton = CreateWindowEx (0, L"BUTTON", lpButtonText,
WS_VISIBLE|WS_CHILD|dwStyle,
0, 0, 0, 0,
GetParent (hWndCB),
(HMENU) idButton,
hInstance, NULL);
if (!hWndButton)
return NULL;
SetParent (hWndButton, hWndCB);
tbbutton.iBitmap = iWidth;
tbbutton.idCommand = 0;
tbbutton.fsState = TBSTATE_ENABLED;
tbbutton.fsStyle = TBSTYLE_SEP;
tbbutton.dwData = (DWORD) hWndButton;
tbbutton.iString = 0;
SendMessage (hWndCB, TB_INSERTBUTTON, iButton, (LPARAM) &tbbutton);
SendMessage (hWndCB, TB_GETITEMRECT, iButton, (LPARAM) &rect);
MoveWindow (hWndButton, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
FALSE);
return hWndButton;
}
Keywords: kbhowto kbcomctrls KB190982