horizontal scroll bar in CListBox
Leonhard Laumeyer -- leonhard.laumeyer@munich.ixos.de
Thursday, January 23, 1997
Environment: VC++ 4.1, Win 95
Hello,
I've created a dialog with a CListBox in it and set the Vertical and Horizontal
scroll options in the list box properties styles.
Before the dialog is displayed i add some strings. If there are more strings
than lines in the visible area, a vertical scroll bar is shown. O.k.
But, if one or more strings are wider than the visible area no horizontal scroll
bar is displayed. What will i have to do to see now a horizontal scroll bar.
Thanks,
Leo
Charlie Jursch -- cjursch@pacbell.net
Friday, January 24, 1997
[Mini-digest: 9 responses]
Leo,
Do the following in your init function:
CListBox* p = (CListBox*) GetDlgItem (IDC_LISTBOX);
p->SetHorizontalExtent(some number);
[some number] is how wide an area you want the list box to scroll.
At 11:42 AM 1/23/97 +0100, you wrote:
>Environment: VC++ 4.1, Win 95
>
>Hello,
>
>I've created a dialog with a CListBox in it and set the Vertical and
Horizontal
>scroll options in the list box properties styles.
>
>Before the dialog is displayed i add some strings. If there are more strings
>than lines in the visible area, a vertical scroll bar is shown. O.k.
>
>But, if one or more strings are wider than the visible area no horizontal
scroll
>bar is displayed. What will i have to do to see now a horizontal scroll bar.
>
>Thanks,
> Leo
>
>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Charlie Jursch "Be kind to your web-footed
Patotech Software, Inc. friends for a duck may be
1-800-PATOTECH somebody's mother."
mailto:cjursch@pacbell.net
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-----From: "Lindholm, Jeff"
You will need to call the function; after you determine the width of the
control and the width of the longest string.
SetHorizontalExtent( int cxExtent );
I usually just overload the add/insert functions and do a
GetTextExtent() call and a SetHorizontalExtent() if needed.
>----------
>From: Leonhard Laumeyer[SMTP:leonhard.laumeyer@munich.ixos.de]
>Sent: Thursday, January 23, 1997 5:42 AM
>To: 'mfc-l@netcom.com'
>Cc: 'leo@ixos.de'
>Subject: horizontal scroll bar in CListBox
>
>Environment: VC++ 4.1, Win 95
>
>Hello,
>
>I've created a dialog with a CListBox in it and set the Vertical and
>Horizontal
>scroll options in the list box properties styles.
>
>Before the dialog is displayed i add some strings. If there are more strings
>than lines in the visible area, a vertical scroll bar is shown. O.k.
>
>But, if one or more strings are wider than the visible area no horizontal
>scroll
>bar is displayed. What will i have to do to see now a horizontal scroll bar.
>
>Thanks,
> Leo
>
-----From: Brian Jones
Leo,
In order for you to use the horizontal scroll bar in a CListBox you must
set the horizontal extent using the CListBox::SetHorizontalExtent member
function. This function accepts an int argument for extent in pixels.
Once the call is made, the listbox's horizontal size will reflect the
extent, and the scrollbar will display itself if necessary. In order
for this to work effectively, you must find the longest string you are
going to display and get its device context text extent.
Brian Jones
Applied Technical Systems
Bremerton, WA
>----------
>From: Leonhard Laumeyer[SMTP:leonhard.laumeyer@munich.ixos.de]
>Sent: Thursday, January 23, 1997 2:42 AM
>To: 'mfc-l@netcom.com'
>Cc: 'leo@ixos.de'
>Subject: horizontal scroll bar in CListBox
>
>Environment: VC++ 4.1, Win 95
>
>Hello,
>
>I've created a dialog with a CListBox in it and set the Vertical and
>Horizontal
>scroll options in the list box properties styles.
>
>Before the dialog is displayed i add some strings. If there are more strings
>than lines in the visible area, a vertical scroll bar is shown. O.k.
>
>But, if one or more strings are wider than the visible area no horizontal
>scroll
>bar is displayed. What will i have to do to see now a horizontal scroll bar.
>
>Thanks,
> Leo
>
-----From: hou@tfn.com (Bing Hou)
Use SetHorizontalExtent() function to set the horizontal extent in pixel
greater than the list box's width.
Bing Hou
hou@tfn.com
======================
Jambalaya Baby!!!
======================
______________________________ Reply Separator _________________________________
Subject: horizontal scroll bar in CListBox
Author: Leonhard Laumeyer at Internet
Date: 1/23/97 11:42 AM
Environment: VC++ 4.1, Win 95
Hello,
I've created a dialog with a CListBox in it and set the Vertical and Horizontal
scroll options in the list box properties styles.
Before the dialog is displayed i add some strings. If there are more strings
than lines in the visible area, a vertical scroll bar is shown. O.k.
But, if one or more strings are wider than the visible area no horizontal scroll
bar is displayed. What will i have to do to see now a horizontal scroll bar.
Thanks,
Leo
-----From: Sandeep
Hi Leo,
to scroll horizontally, you need to set the horizontal Scroll Range in
createwindow function of the CListBox. The default range is 0 to 100.
You may set the maximum limit that suits you need.
hope it helps.
sandeep
Leonhard Laumeyer wrote:
>
> Environment: VC++ 4.1, Win 95
>
> Hello,
>
> I've created a dialog with a CListBox in it and set the Vertical and Horizontal
> scroll options in the list box properties styles.
>
> Before the dialog is displayed i add some strings. If there are more strings
> than lines in the visible area, a vertical scroll bar is shown. O.k.
>
> But, if one or more strings are wider than the visible area no horizontal scroll
> bar is displayed. What will i have to do to see now a horizontal scroll bar.
>
> Thanks,
> Leo
-----From: "Amit Ramon"
----------
> From: Leonhard Laumeyer
> To: 'mfc-l@netcom.com'
> Cc: 'leo@ixos.de'
> Subject: horizontal scroll bar in CListBox
> Date: Thursday, January 23, 1997 4:42 AM
>
> Environment: VC++ 4.1, Win 95
>
> Hello,
>
> I've created a dialog with a CListBox in it and set the Vertical and
Horizontal
> scroll options in the list box properties styles.
>
> Before the dialog is displayed i add some strings. If there are more
strings
> than lines in the visible area, a vertical scroll bar is shown. O.k.
>
> But, if one or more strings are wider than the visible area no horizontal
scroll
> bar is displayed. What will i have to do to see now a horizontal scroll
bar.
>
> Thanks,
> Leo
First, create the list with horizontal scroll style (style tab in
properties window in app studio).
Then you have to measure each one of the strings that you add to the list,
and set the text extent of the list box
to the extent of the longets string. The code looks like this:
CListBox list; // creat this as member variable in class wizard (or
subclass the list box)
char *szBuf[100]; // assume this array contains your strings
.
.
.
CClientDC dc(&list); // get the list device context
int nLongestLine = 0;
for (int i = 0; i < 100; i ++)
{
list.AddString(szBuf[i]); // add a string to the list
CSize size = dc.GetTextExtent(szBuf[i], strlen(szBuf[i]); // measure the
string length
if (size.cx > nLongestLine) // save the longest length
nLongestLine = size.cx;
}
// now set the list extent to the extent of the longets string
m_listConditions.SetHorizontalExtent(nLongestLine);
Hope this help,
Amit
-----From: Yeung Chi Kong
Environment: VC++ 4.1, Win 95
Hello,
I've created a dialog with a CListBox in it and set the Vertical and Horizontal
scroll options in the list box properties styles.
Before the dialog is displayed i add some strings. If there are more strings
than lines in the visible area, a vertical scroll bar is shown. O.k.
But, if one or more strings are wider than the visible area no horizontal
scroll
bar is displayed. What will i have to do to see now a horizontal scroll bar.
Thanks,
Leo
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| ||
|| My Home Page address ||
|| ===> http://www.speednet.net/~cytusso/yeung/22.htm ||
|| ||
|| E-mail address ||
|| =====> Yeung Chi Kong ||
|| ||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-----From: Dong Chen
At 11:42 AM 1/23/97 +0100, you wrote:
>Environment: VC++ 4.1, Win 95
>
>Hello,
>
>I've created a dialog with a CListBox in it and set the Vertical and Horizontal
>scroll options in the list box properties styles.
>
>Before the dialog is displayed i add some strings. If there are more strings
>than lines in the visible area, a vertical scroll bar is shown. O.k.
>
>But, if one or more strings are wider than the visible area no horizontal
scroll
>bar is displayed. What will i have to do to see now a horizontal scroll bar.
>
>Thanks,
> Leo
>
>
Try the SetHorizontalExtent() function.
--
Dong
d_chen@ix.netcom.com
-----From: Mike Blaszczak
At 11:42 1/23/97 +0100, Leonhard Laumeyer wrote:
>Environment: VC++ 4.1, Win 95
>I've created a dialog with a CListBox in it and set the Vertical and
Horizontal
>scroll options in the list box properties styles.
>Before the dialog is displayed i add some strings. If there are more strings
>than lines in the visible area, a vertical scroll bar is shown. O.k.
>But, if one or more strings are wider than the visible area no horizontal
scroll
>bar is displayed. What will i have to do to see now a horizontal scroll bar.
Did you call CListBox::SetHorizontalExtent()?
.B ekiM
http://www.nwlink.com/~mikeblas/
Why does the "new" Corvette look like a 1993 RX-7?
These words are my own. I do not speak on behalf of Microsoft.
Roma -- roma@neonet.lv
Sunday, January 26, 1997
Hello,
Leonhard Laumeyer wrote:
>
> Environment: VC++ 4.1, Win 95
>
[snip]
>
> But, if one or more strings are wider than the visible area no horizontal scroll
> bar is displayed. What will i have to do to see now a horizontal scroll bar.
Check help for: void CListBox::SetHorizontalExtent( int cxExtent );
In general you have to call this function to give lisbox info about
width of
your lines in the list box. While adding lines you have to calculate
maximum width
and than call SetHorizontalExtent(nMaxWidth);
-Roma
| Вернуться в корень Архива
|