Solved

HScroll in list box

Posted on 2000-05-02
4
198 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
  • 3
4 Comments
 
LVL 1

Accepted Solution

by:
Sadhu earned 200 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now