?
Solved

HScroll in list box

Posted on 2000-05-02
4
Medium Priority
?
207 Views
Last Modified: 2013-11-20
hey guys,
i have CListBox on a dialog, i want it to has HScroll bar so i can see the rest of the string in the box...

what should i do ???

Shay
0
Comment
Question by:Shay050799
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 1

Accepted Solution

by:
Sadhu earned 600 total points
ID: 2770801
use SetHorizontalExtent( int cxExtent )

to set extent



0
 
LVL 1

Expert Comment

by:Sadhu
ID: 2770817
you could write function similar to following to calcualte extent for string.
LONG YourClass::GetExtentForString(LPCTSTR lpszItem)
{
    CDC* cdc=this->GetDC();
    CFont* font = this->GetFont();
    CFont* pOldFont;

    if (font)
     {
        pOldFont = cdc->SelectObject(font);

          TEXTMETRIC tm;
          cdc->GetTextMetrics(&tm);

          CSize size = cdc->GetTextExtent(lpszItem, lstrlen(lpszItem) );
          size.cx += tm.tmAveCharWidth;

          cdc->SelectObject(pOldFont);
          this->ReleaseDC(cdc);

          return (LONG) size.cx;
     }

     this->ReleaseDC(cdc);

     return 0L;
}

0
 
LVL 1

Expert Comment

by:Sadhu
ID: 2770849
Also do not forget to check box for auto horizontal scroll bar in your list box properties.

0
 
LVL 3

Author Comment

by:Shay050799
ID: 2771116
Sadhu  answer was excelent,thanks a lot
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question