1

Topic: Transparent EditControl for text entering over a picture.

The task: to add possibility to enter the text on pictures. I.e. the user sticks with a mouse into any section of a picture (it is drawn in CDialog) and in this place there should be a cursor for text entering. The cursor should be against a picture the text the multiline should be entered. My decision: logically there was a thought to implement by means of EditControl. During the moment a clique, I add in the necessary area of dialogue EditControl and after the user finishes input I cut area with the text and I interpose into an initial picture. A problem 1: the text is entered normally, but thus it for some reason is not deleted. If I select the text selection as is not removed. I.e. as a matter of fact all that in it is drawn is not deleted. How it can be solved? A problem 2: For some reason does not work Multiline a mode which is exposed for IDC_EDIT1. I.e. if I push Enter happens nothing. If I change mine CEditTrans on simple CEdit that all , except a transparency. While it looks so: #include "stdafx.h" #include "EditTrans.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE [] = __ FILE __; #endif ///////////////////////////////////////////////////////////////////////////////CEditTrans CEditTrans:: CEditTrans () {m_TextColor = RGB (255, 255, 255); m_BackColor = TRANS_BACK;} CEditTrans:: ~CEditTrans () {} BEGIN_MESSAGE_MAP (CEditTrans, CEdit)//{{AFX_MSG_MAP (CEditTrans) ON_WM_CTLCOLOR_REFLECT ()//ON_WM_CTLCOLOR ()//ON_CONTROL_REFLECT (EN_UPDATE, OnUpdate) ON_WM_LBUTTONDOWN ()//ON_CONTROL_REFLECT (EN_KILLFOCUS, OnKillfocus)//}} AFX_MSG_MAP END_MESSAGE_MAP () ///////////////////////////////////////////////////////////////////////////////CEditTrans message handlers HBRUSH CEditTrans:: CtlColor (CDC* pDC, UINT nCtlColor) {m_Brush. DeleteObject (); m_Brush. CreateStockObject (HOLLOW_BRUSH);//the background pDC-> SetBkMode (TRANSPARENT) Is done by transparent; pDC-> SetTextColor (m_TextColor); return (HBRUSH) m_Brush;} void CEditTrans:: OnKillfocus () {UpdateCtrl ();} void CEditTrans:: OnUpdate () {UpdateCtrl ();} void CEditTrans:: OnLButtonDown (UINT nFlags, CPoint point) {UpdateCtrl (); CEdit:: OnLButtonDown (nFlags, point);} void CEditTrans:: UpdateCtrl () {CWnd* pParent = GetParent (); CRect rect; GetWindowRect (rect); pParent-> ScreenToClient (rect); rect. DeflateRect (2, 2); pParent-> InvalidateRect (rect, FALSE);} In the dialogue void CMyDlg:: DoDataExchange (CDataExchange* pDX) {CDialog:: DoDataExchange (pDX);//{{AFX_DATA_MAP (CMyDlg) DDX_Control (pDX, IDC_EDIT1, m_textEdit);//}} AFX_DATA_MAP}...

2

Re: Transparent EditControl for text entering over a picture.

Hello, C0x, you wrote: C0x> My decision: logically there was a thought to implement by means of EditControl. During the moment a clique, I add in the necessary area of dialogue EditControl and C0x> after the user finishes input I cut area with the text and I interpose into an initial picture. Here there is a decision, all in pair lines becomes. It [is added] And, you are visible it and used.

3

Re: Transparent EditControl for text entering over a picture.

Hello, Evgeniy Skvortsov, you wrote: ES> Hello, C0x, you wrote: C0x>> My decision: logically there was a thought to implement by means of EditControl. During the moment a clique, I add in the necessary area of dialogue EditControl and C0x>> after the user finishes input I cut area with the text and I interpose into an initial picture. ES> here there is a decision, all in pair lines becomes. ES> [it is added] ES> And, you are visible it and used. Aha and it does not work as it is necessary.

4

Re: Transparent EditControl for text entering over a picture.

Hello, C0x, you wrote: C0x> Aha and it does not work as it is necessary. The problem that at mode setting pDC-> SetBkMode (TRANSPARENT) there is no background overwriting Seems. In this connection it is necessary to process WM_ERASEBKGND, at creation  to capture an image piece which is under EDIT and to recover it.