mfc >> CEdit position

by ArtuS » Sun, 23 Nov 2003 09:55:04 GMT

I have some CEdit in my dialog. I need to know what is a x&y point and
width&height one of these CEdits (for example CEdit one;). I want to draw a
point (few pixels) in a middle of that CEdit so I must know where is a
center of this component.

Can you help me?

ArtuS




mfc >> CEdit position

by Jeff Partch [MVP] » Sun, 23 Nov 2003 10:16:34 GMT





a

Possibly GetClientRect followed by CRect::CenterPoint.
--
Jeff Partch [VC++ MVP]





mfc >> CEdit position

by ArtuS » Sun, 23 Nov 2003 10:54:23 GMT

> Possibly GetClientRect followed by CRect::CenterPoint.
CRect rect;
GetDlgItem(IDC_OONE)->GetWindowRect(&rect);
CPoint pt = rect.CenterPoint();
ScreenToClient(&pt);

THX4help

ArtuS




CEdit position

by Joseph M. Newcomer » Sun, 23 Nov 2003 17:09:37 GMT

And what makes you think that doing your own drawing is going to work? Edit controls paint
themselves whenever they feel like it, and doing your own drawing risks the fact that
mechanisms entirely outside your control are free to overwrite whatever you do.

I'd be inclined to paint on a transparent window which is on top of the edit control, or
something similar. Since I don't ever have a desire to draw on edit controls, I've never
experimented with this, but I believe you are in for some serious frustrations.
joe




Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


Similar Threads

1. CEdit and retreiving column number from cursor position

How would I retreive the current column number (e.g., the number of
characters from the start of a specific line) in a CEdit control?


2. CEdit display text with Gdiplus:Font, Graphics - wrong caret position

3. CEdit, set cursor position

4. Problem with caret position after changer font of CEdit

5. Cursor position in a single line CEdit control

I have a situation where I need to examine and possibly modify,
programmatically, the text of a CEdit control.  If a change is made,
usually removing a character that has just been typed as being
erroneous, the edit cursor jumps to the beginning of the display.  I
need to know how to get the position of the character cursor at the
time of the entry and how to set it when I've changed the text.  There
appear to be functions for this with a multi-line CEdit control but
nothing is said about a single line control.

-- 
Thanks,
Lilith

6. maintaing cursor position in CEdit refresh

7. CEdit caret position

The user has input some text in a CEdit control.
The cursor/caret is positioned somewhere in the text.
If the user press a button I want to insert some text at this position.

Is there are an easy way to determine the current text position?
Thanks Thomas 


8. CEdit display text with Gdiplus:Font, Graphics - wrong caret position