Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4620348
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:32:54+00:00 2026-05-22T02:32:54+00:00

I have a logical order problem. Lets say I have three points of significance.

  • 0

I have a logical order problem.

Lets say I have three points of significance. Left side of edit field, right side of edit field, caret position in edit field.

I want to show the control that has focus, and show it’s caret.

To show a field that has focus, I generally try to ensure the following in this order.
1. Ensure right side visible.
2. Ensure left side visible.
3. Ensure caret (plus max width character) visible.

Problem is if the field is too wide for the parent. The control will always attempt to show the right, then left, then caret. If the caret is near the end (and the current scroll ensures the right side is visible), and the user types, the parent will scroll to right after the caret even if it was already visible.
This actually scrolls the parent to the left if the caret < right side.
I don’t want to do that.

Pseudo code:

if (cFocusRect.right > cClientRect.right) 
{ 
   cFinalPoint.x += cClientRect.right - cFocusRect.right;
   cFocusRect.OffsetRect(cClientRect.right - cFocusRect.right, 0);
   fBoundRight = TRUE;
}
if (cFocusRect.left < 0)
{
   cFinalPoint.x -= cFocusRect.left;
   cFocusRect.OffsetRect(cFocusRect.left, 0);
}

nCaretRight = min(cFocusRect.right, pChild->GetCaretPos().x + nMaxCharWidth);

if (nCaretRight > cClientRect.right)
{
   cFinalPoint.x += cClientRect.right - nCaretRight;
   cFocusRect.OffsetRect(cClientRect.right - nCaretRight, 0);
   fBoundRight = TRUE;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:32:55+00:00Added an answer on May 22, 2026 at 2:32 am

    Here’s the solution. Don’t scroll the Field’s rect into view if you need to scroll the caret into view. To decide, check if the field is bigger than the scrollable area.

    if (cFocusRect.Width() < cClientRect.Width())
    {
        if (cFocusRect.right > cClientRect.right)
        {
            cFinalPoint.x += cClientRect.right - cFocusRect.right;
            cFocusRect.OffsetRect(cClientRect.right - cFocusRect.right, 0);
            cCaretPoint.Offset(cClientRect.right - cFocusRect.right, 0);
            fBoundRight = TRUE;
        }
        if (cFocusRect.left < 0)
        {
            cFinalPoint.x -= cFocusRect.left;
            cFocusRect.OffsetRect(cFocusRect.left, 0);
            cCaretPoint.Offset(cFocusRect.left, 0);
        }
    }
    else
    {
        nCaretRight = min(cFocusRect.right, cCaretPoint.x + (cFocusRect.Height() * 3));
    
        if (nCaretRight > cClientRect.right)
        {
            cFinalPoint.x += cClientRect.right - nCaretRight;
            cFocusRect.OffsetRect(cClientRect.right - nCaretRight, 0);
            cCaretPoint.Offset(cClientRect.right - nCaretRight, 0);
            fBoundRight = TRUE;
        }
    
        nCaretLeft = max(cFocusRect.left, cCaretPoint.x);
    
        if (nCaretLeft < 0)
        {
            cFinalPoint.x -= nCaretLeft;
            cFocusRect.OffsetRect(cClientRect.left - nCaretLeft, 0);
            cCaretPoint.Offset(cClientRect.left - nCaretLeft, 0);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem in MATLAB. I have a NxM logical array called L
I'm sure the answer is somehow logical but here goes. I have three big
We are developing an enterprise-size accounting system and we have logical design problem which
I'm creating a database table and I don't have a logical primary key assigned
Cut and dry... while I never have enough logical operations for it to be
I have something of a logical puzzle I can not figure out. I have
I have a web application distributed over different logical and physical layers. The application
i have a many to many table relationship that involves 2 logical tables. Record
I have a situation where I have several VB.NET Modules in the same Logical-Module
I am writing ESME using logica smpp lib , but have a serious problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.