Board index » Visual Studio » Sizing Columns in CListView's / CListCtrl's

Sizing Columns in CListView's / CListCtrl's

Visual Studio266
Greetings:



I'm writing an application that must run on a variety of machines with

different screen resolution settings. I have many dialogs containing list

views and I would like to be able to initialize the column widths so that

they completely fill the full width of the list view without any column

being clipped. However, What works for one screen resolution does not work

for another.



For example, I have a list control with three columns. The column sizes are

specified in the LVCOLUMN structure and three consecutive calls to

InsertColumn using 90, 80 and 100 units, respectively. On a screen with high

resolution, this leaves tons of room to spare along the right-hand side of

the list control. On lower resolution screens, the right-most column gets

clipped and you have to use the horizontal scroll bar to see it. I know my

users will hate that.



I am surprised that there is not a simple member function for CListView or

CListCtrl that returns the length and width of the entire list control

rectangle so that I can size each column of the control as a fraction of the

full width of the list control. Is there some reason why that is not

available?



In the absence of such a simple and useful function, how, exactly, can I

obtain, at runtime, the width of the control and then size each column

accordingly?



Thank you in advance,

Mark Roberts,

Toronto


-
 

Re:Sizing Columns in CListView's / CListCtrl's

I get the width of the ListCtrl using GetClientRect(), then divide

accordingly.



--

-------------------------------------------------------------------------

Free software - Baxter Codeworks www.baxcode.com

-------------------------------------------------------------------------





"Mark Roberts" <mcroberts@sympatico.ca>wrote in message

Quote
Greetings:



I'm writing an application that must run on a variety of machines with

different screen resolution settings. I have many dialogs containing list

views and I would like to be able to initialize the column widths so that

they completely fill the full width of the list view without any column

being clipped. However, What works for one screen resolution does not work

for another.



For example, I have a list control with three columns. The column sizes

are

specified in the LVCOLUMN structure and three consecutive calls to

InsertColumn using 90, 80 and 100 units, respectively. On a screen with

high

resolution, this leaves tons of room to spare along the right-hand side of

the list control. On lower resolution screens, the right-most column gets

clipped and you have to use the horizontal scroll bar to see it. I know my

users will hate that.



I am surprised that there is not a simple member function for CListView or

CListCtrl that returns the length and width of the entire list control

rectangle so that I can size each column of the control as a fraction of

the

full width of the list control. Is there some reason why that is not

available?



In the absence of such a simple and useful function, how, exactly, can I

obtain, at runtime, the width of the control and then size each column

accordingly?



Thank you in advance,

Mark Roberts,

Toronto









-