Click to See Complete Forum and Search --> : Cursor goes to beginning of digits in edit box!
Gyannea
July 27th, 2005, 10:40 AM
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
humptydumpty
July 27th, 2005, 10:46 AM
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
Gyannea
July 27th, 2005, 11:24 AM
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
humptydumpty
July 27th, 2005, 11:51 PM
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
Gyannea
July 28th, 2005, 05:27 AM
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
kirants
July 28th, 2005, 12:08 PM
You can use SetSel to move the caret
Gyannea
July 28th, 2005, 02:50 PM
Wouldn't have guessed by the name! Thanks, that sounds better thanfaking an arrow key!
Brian
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.