- // remove old columns
- for (int j=0, max=Header_GetItemCount((HWND)m_hWnd); j < max; j++)
- Header_DeleteItem((HWND)m_hWnd, 0);
-
- m_imageList->RemoveAll();
-
- // add the updated array of columns to the header control
- unsigned int cols = GetOwner()->GetColumnCount();
- unsigned int added = 0;
- for (unsigned int i = 0; i < cols; i++)
- {
- wxDataViewColumn *col = GetColumn( i );
- if (col->IsHidden())
- continue; // don't add it!
-
- HDITEM hdi;
- hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_WIDTH;
- if (col->GetBitmap().IsOk())
- {
- m_imageList->Add( col->GetBitmap() );
- hdi.mask |= HDI_IMAGE;
- hdi.iImage = m_imageList->GetImageCount()-1;
- }
- hdi.pszText = (wxChar *) col->GetTitle().wx_str();
- hdi.cxy = col->GetWidth();
- hdi.cchTextMax = sizeof(hdi.pszText)/sizeof(hdi.pszText[0]);
- hdi.fmt = HDF_LEFT | HDF_STRING;
- if (col->GetBitmap().IsOk())
- hdi.fmt |= HDF_IMAGE;
-
- //hdi.fmt &= ~(HDF_SORTDOWN|HDF_SORTUP);
-
- if (col->IsSortable() && GetOwner()->GetSortingColumn() == col)
- {
- //The Microsoft Comctrl32.dll 6.0 support SORTUP/SORTDOWN, but they are not default
- //see http://msdn2.microsoft.com/en-us/library/ms649534.aspx for more detail
- // VZ: works with 5.81
- hdi.fmt |= col->IsSortOrderAscending() ? HDF_SORTUP : HDF_SORTDOWN;
- }
-
- // lParam is reserved for application's use:
- // we store there the column index to use it later in MSWOnNotify
- // (since columns may have been hidden)
- hdi.lParam = (LPARAM)i;
-
- // the native wxMSW implementation of the header window
- // draws the column separator COLUMN_WIDTH_OFFSET pixels
- // on the right: to correct this effect we make the column
- // exactly COLUMN_WIDTH_OFFSET wider (for the first column):
- if (i == 0)
- hdi.cxy += COLUMN_WIDTH_OFFSET;
-
- switch (col->GetAlignment())
- {
- case wxALIGN_LEFT:
- hdi.fmt |= HDF_LEFT;
- break;
- case wxALIGN_CENTER:
- case wxALIGN_CENTER_HORIZONTAL:
- hdi.fmt |= HDF_CENTER;
- break;
- case wxALIGN_RIGHT:
- hdi.fmt |= HDF_RIGHT;
- break;
-
- default:
- // such alignment is not allowed for the column header!
- break; // wxFAIL;
- }
-
- SendMessage((HWND)m_hWnd, HDM_INSERTITEM,
- (WPARAM)added, (LPARAM)&hdi);
- added++;
- }