Click here to Skip to main content
16,012,352 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralQuick newbie question Pin
31-Mar-02 9:28
suss31-Mar-02 9:28 
GeneralRe: Quick newbie question Pin
Christian Graus31-Mar-02 12:32
protectorChristian Graus31-Mar-02 12:32 
GeneralRe: Quick newbie question Pin
Paul M Watt31-Mar-02 15:38
mentorPaul M Watt31-Mar-02 15:38 
GeneralRe: Quick newbie question Pin
Mazdak1-Apr-02 0:22
Mazdak1-Apr-02 0:22 
GeneralWinXP symbols - VC does not find them Pin
Lockhart31-Mar-02 9:27
Lockhart31-Mar-02 9:27 
GeneralRe: WinXP symbols - VC does not find them Pin
Tim Smith31-Mar-02 11:55
Tim Smith31-Mar-02 11:55 
GeneralScrolling Pin
31-Mar-02 9:21
suss31-Mar-02 9:21 
GeneralRe: Scrolling Pin
alex.barylski31-Mar-02 22:11
alex.barylski31-Mar-02 22:11 
CRect rcClient;

GetClientRect(&rcClient);

TEXTMETRICS tm;
CDC* pDC = CDC::FromHandle(::GetDC(this->m_hWnd));
pDC->GetTextMetrics(&tm);

int nLineHeight = tm.tmHeight (I think) + tm.tmAscent; (i think)


The above code would work on constant font size, but you would have to figure something else out if you have graphics and such or font's of different sizes.

Basically once you have individual line height and client area figured out, you would need to determine which line the word (found) was located.

int iLine = Search("Test");  //psuedo function


Now that you have the line index:

int nSpace = iLine * nLineHeight;


nSpace is the number of pixels all the lines up to the current indexed line consume.

By having this value and having you current viewing area(client rect) you could subtract client area by line height(s) and determine if the text is out of the viewing area and requires scrolling.

if(nSpace >= rcClient.bottom) //Requires scrolling
{
  //...Calculate required scrolling distance
  //...Set scrollbar(s) to calculated offset
}
else
  AfxMessageBox("Don't scroll...Text is within current area");


I'm missing a few thing i'm sure, but from the above you should get the gist of things and be able to take it one step further.

Cheers! Smile | :)

"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
QuestionTime trial? Pin
Edilson Vasconcelos de Melo Junior31-Mar-02 9:11
Edilson Vasconcelos de Melo Junior31-Mar-02 9:11 
AnswerRe: Time trial? Pin
Christian Graus31-Mar-02 12:35
protectorChristian Graus31-Mar-02 12:35 
AnswerRe: Time trial? Pin
Nish Nishant31-Mar-02 14:13
sitebuilderNish Nishant31-Mar-02 14:13 
GeneralRe: Time trial? Pin
Christian Graus31-Mar-02 14:45
protectorChristian Graus31-Mar-02 14:45 
GeneralRe: Time trial? Pin
Nish Nishant31-Mar-02 15:07
sitebuilderNish Nishant31-Mar-02 15:07 
GeneralRe: Time trial? Pin
Christian Graus31-Mar-02 15:19
protectorChristian Graus31-Mar-02 15:19 
GeneralRe: Time trial? Pin
Edilson Vasconcelos de Melo Junior1-Apr-02 2:52
Edilson Vasconcelos de Melo Junior1-Apr-02 2:52 
GeneralRe: Time trial? Pin
Nish Nishant1-Apr-02 16:11
sitebuilderNish Nishant1-Apr-02 16:11 
GeneralEdit box balloon tips in WinXP Pin
sultan_of_6string31-Mar-02 8:08
sultan_of_6string31-Mar-02 8:08 
GeneralRe: Edit box balloon tips in WinXP Pin
Ravi Bhavnani31-Mar-02 9:11
professionalRavi Bhavnani31-Mar-02 9:11 
GeneralTest Pin
31-Mar-02 3:18
suss31-Mar-02 3:18 
GeneralRe: Test Pin
Jon Newman31-Mar-02 3:52
Jon Newman31-Mar-02 3:52 
GeneralRe: Test Pin
Nish Nishant31-Mar-02 5:13
sitebuilderNish Nishant31-Mar-02 5:13 
GeneralRe: Test Pin
Michael P Butler31-Mar-02 23:12
Michael P Butler31-Mar-02 23:12 
QuestionHow to get the cut point of the line and the rect Pin
Feng Qin31-Mar-02 3:03
Feng Qin31-Mar-02 3:03 
AnswerRe: How to get the cut point of the line and the rect Pin
Nish Nishant31-Mar-02 5:11
sitebuilderNish Nishant31-Mar-02 5:11 
GeneralRe: How to get the cut point of the line and the rect Pin
Feng Qin31-Mar-02 14:50
Feng Qin31-Mar-02 14:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.