| 803 | } |
| 804 | |
| 805 | int Toolbar_SetButtons ( HWND hwnd, int cmdBase, LPCWSTR lpszButtons, LPCTBBUTTON ptbb, int ctbb ) |
| 806 | { |
| 807 | WCHAR tchButtons[512]; |
| 808 | WCHAR *p; |
| 809 | int i, c; |
| 810 | int iCmd; |
| 811 | ZeroMemory ( tchButtons, COUNTOF ( tchButtons ) *sizeof ( tchButtons[0] ) ); |
| 812 | lstrcpyn ( tchButtons, lpszButtons, COUNTOF ( tchButtons ) - 2 ); |
| 813 | TrimString ( tchButtons ); |
| 814 | while ( p = StrStr ( tchButtons, L" " ) ) { |
| 815 | MoveMemory ( ( WCHAR * ) p, ( WCHAR * ) p + 1, ( lstrlen ( p ) + 1 ) * sizeof ( WCHAR ) ); |
| 816 | } |
| 817 | c = ( int ) SendMessage ( hwnd, TB_BUTTONCOUNT, 0, 0 ); |
| 818 | for ( i = 0; i < c; i++ ) { |
| 819 | SendMessage ( hwnd, TB_DELETEBUTTON, 0, 0 ); |
| 820 | } |
| 821 | for ( i = 0; i < COUNTOF ( tchButtons ); i++ ) |
| 822 | if ( tchButtons[i] == L' ' ) { |
| 823 | tchButtons[i] = 0; |
| 824 | } |
| 825 | p = tchButtons; |
| 826 | while ( *p ) { |
| 827 | if ( swscanf ( p, L"%i", &iCmd ) == 1 ) { |
| 828 | iCmd = ( iCmd == 0 ) ? 0 : iCmd + cmdBase - 1; |
| 829 | for ( i = 0; i < ctbb; i++ ) { |
| 830 | if ( ptbb[i].idCommand == iCmd ) { |
| 831 | SendMessage ( hwnd, TB_ADDBUTTONS, ( WPARAM ) 1, ( LPARAM ) &ptbb[i] ); |
| 832 | break; |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | p = StrEnd ( p ) + 1; |
| 837 | } |
| 838 | return ( ( int ) SendMessage ( hwnd, TB_BUTTONCOUNT, 0, 0 ) ); |
| 839 | } |
| 840 | |
| 841 | |
| 842 | //============================================================================= |
no test coverage detected