Microsoft KB Archive/190982

= How To Add a Button Control to a Command Band =

Article ID: 190982

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Windows CE 2.0 for the Handheld PC
 * Microsoft Windows CE 2.0 for the Handheld PC

-



This article was previously published under Q190982



SUMMARY
When you create a command band, you might want to add a button to the command band (for example, similar to the New button in the Calendar or Contacts applications on the Palm-size PC).



MORE INFORMATION
The following function sends a TB_INSERTBUTTON to the command bar to insert a button control: 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

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.