CompuServe Thread

#CListBox sizing in VCiew

2 messages in this thread
#30504From: Steven WaldronJul 11, 1994 9:53 AM
In order to have a view which supports a selectable list of database entries in my document, I have created a list box within my CView class. I would prefer to create a clistbox view but can't find any sample code for that. Anyway here is the problem: In the oncreate of CMyView I do the following: , I call CView::Create then MoveWindow to size my window. Then I create CMyListBox with the CRect used to size my parent window. CMyListBox style is WS_HSCROLL | WS_VSCROLL so the listbox can scroll itself. Then I size CMyListBox with a MoveWindow. The problem is that the listbox scrollbar is in the middle of my mainwindow. I can't get it to move. It is always about 70 characters wide. No matter how I try to size it. Can anywone help?
#30581From: Mike RyanJul 11, 1994 7:51 PM
I just faced this issue – what I did was use a CFormView parent, creating a dialog containing a listbox in AppStudio. To get the sizing to work, add a WM_SIZE message handler to the view, and in it call SetWindowPos on the listbox (using the cx and cy arguments). This not only makes it come up the right size when initialized, but makes sure the listbox resizes to fill the view if the user resizes it. Mike