CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    Candia, NH
    Posts
    374

    Cursor goes to beginning of digits in edit box!

    I have a multiline, numerical only non-rich edit box with right allignment. But when I enter a digit, the first digit appears rightmost (as it should) but the cursor jumps to the beginning of the number thus the result is that the number is entered backwards. So entering 6,4,5 will give the number 546.

    Now I subclass this procedure so there must be something I do in the handling of messages that prevents the system from restoring the cursor to the right. I cannot find a message to send to the edit box which places the cursor to the right (or does anything with the cursor).

    Any ideas or know how on how to control the cursor?

    Brian

  2. #2
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Re: Cursor goes to beginning of digits in edit box!

    Quote Originally Posted by Gyannea
    I have a multiline, numerical only non-rich edit box with right allignment. But when I enter a digit, the first digit appears rightmost (as it should) but the cursor jumps to the beginning of the number thus the result is that the number is entered backwards. So entering 6,4,5 will give the number 546.

    Now I subclass this procedure so there must be something I do in the handling of messages that prevents the system from restoring the cursor to the right. I cannot find a message to send to the edit box which places the cursor to the right (or does anything with the cursor).

    Any ideas or know how on how to control the cursor?

    Brian
    try this may be this one help u

    open the property dialog of edit control in that choose style.
    and select align text left

  3. #3
    Join Date
    Dec 2002
    Location
    Candia, NH
    Posts
    374

    Re: Cursor goes to beginning of digits in edit box!

    Did that already, but it doesn't help. The problem comes from a 'SetWindowText()' API function used in the subprocedure. When a WM_CHAR message is received, the standard handler is used, but after that I GetWindowTExt() to see if the number has exceeded certain limits. If it does, I enter the new corrected number into the edit box. However, the cursor appears to the left of that newly entered number and not the right. From then on, entries will be as they should (number enter to the right but displaced to the left of the number I entered) until I cross limits again then the whole thing starts over again.

    I need to get Windows to recognize my corrected entry as part of the number!

    Brian

  4. #4
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Lightbulb Re: Cursor goes to beginning of digits in edit box!

    Quote Originally Posted by Gyannea
    Did that already, but it doesn't help. The problem comes from a 'SetWindowText()' API function used in the subprocedure. When a WM_CHAR message is received, the standard handler is used, but after that I GetWindowTExt() to see if the number has exceeded certain limits. If it does, I enter the new corrected number into the edit box. However, the cursor appears to the left of that newly entered number and not the right. From then on, entries will be as they should (number enter to the right but displaced to the left of the number I entered) until I cross limits again then the whole thing starts over again.

    I need to get Windows to recognize my corrected entry as part of the number!

    Brian
    Can you post your code.
    so we can c how u r trying to achive this.
    and check once again with SetDlgItemText() method
    Last edited by humptydumpty; July 28th, 2005 at 12:26 AM.

  5. #5
    Join Date
    Dec 2002
    Location
    Candia, NH
    Posts
    374

    Re: Cursor goes to beginning of digits in edit box!

    The problem is in the subclassing (otherwise it doesn't happen). I have found a work around. After I call the 'SetWindowText()' API function I post a WM_KEYDOWN message and fake an arrow key of my choice. That moves the cursor to where it would be without the call.

    Brian

  6. #6
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Cursor goes to beginning of digits in edit box!

    You can use SetSel to move the caret

  7. #7
    Join Date
    Dec 2002
    Location
    Candia, NH
    Posts
    374

    Re: Cursor goes to beginning of digits in edit box!

    Wouldn't have guessed by the name! Thanks, that sounds better thanfaking an arrow key!

    Brian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured