Click to See Complete Forum and Search --> : converting caret postion in text box to pixel grid position


September 27th, 1999, 01:39 AM
Hay People,
I am trying to write an editor that will similarly to the VB editor - will open a list box after a dot was pressed.
I am using the GetCaretPos func from user32 lib to find my caret position.
But, when assigning these caret coordinates to the left and top properties of the list box - the list box will appear not at the caret position but with an offset that will grow the further the caret is.
So, my questions are:
A) What kind or in what grid is the caret position?
B) How can I convert the caret position to the "general" pixel grid position that will allow other controls match the caret position

Hope I am clear enough with my question...
Thanks in advance
Dani.

Ravi Kiran
September 27th, 1999, 02:20 AM
If you look into MSDN, it says GetCaretPos
will return the caret position with respect to Client Coordinates. So its origin will coincide with the (Rich) Edit control that you may be using.
You can use ClientToScreen, ScreentoClient APIs to convert the coordinates to Scrren coordinates and use absolute positioning.

Yet Another thing that will affect the position of your Listbox is its parent control. So, if you want relative positioning you need to add/subtract values that correct for the Parent's (left,top) values.

RK