Here’s how it can be done with ProfUIS_Controls sample. I’m reducing the number of columns to 3 to make the change more obvious.
- Inside CPageGrid::OnInitDialog, look for the struct arrHeader. Right before declaration of this struct, add the lines:
m_wndGrid.SiwScrollTypeHSet( __ESIW_ST_NONE, false );
m_wndGrid.BseModifyStyleEx( __EGBS_BSE_EX_PROPORTIONAL_COLUMN_WIDTHS, 0, false );
- The declaration of the struct is
LPCTSTR sText; INT nWidth; DWORD dwStyle;
, make it
LPCTSTR sText; double nWidth; DWORD dwStyle;
(changing INT to double).
- Comment all items of the struct except for the first 3 (Boolean, CheckBox, RadioButton).
- Change the widths from 85, 85, 85 to 0.5, 0.25, 0.25 .
- Right after this struct there’s a loop to initialize all the headers on the top. Inside the loop there’s a call
pCell->ExtentSet( arrHeader[nColNo].nWidth );
, change this to
pCell->ExtentPercentSet( arrHeader[nColNo].nWidth );
.
- Look for a series of calls _InitColumn.... Comment all except for the first 3.
- Rebuild, run. You will see the 3 columns taking up all the width of the grid. Try resizing the window, columns are resizing accordingly.
Actually the first step is enough to show the effect of style __EGBS_BSE_EX_PROPORTIONAL_COLUMN_WIDTHS, but all the columns would be very narrow.