15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Transparent CEdit Problem

Willem Fourie -- willem@teklogic.co.za
Monday, January 29, 1996

Hi, I'm using a CEdit derived control as a child window of a CView derived
view.   This window is made a child of the view window using the Create()
function.  I move the CEdit control around dynamically to give the user the
impression that he is entering textual data as a 'graphic' object (along
with polylines and other line graphics).  I use the OnCtlColor() function in
the view to set text color and background.  Everything works great but I
need to make the CEdit window completely transparent!    I did an override
of the CEdit control's PreCreateWindow() function to set the extended style
flag WS_EX_TRANSPARENT, and when this did not work, via ::SetWindowLong() -
no joy!  I used the view's OnCtlColor() to return an HBRUSH with a BS_NULL
style, which only removed the control's backspace functionality visually.  I
did an override of the control's OnEraseBkGnd() function (to return the
value TRUE, and do nothing else). guess what?  It did not work.  I even
created the window using ::CreateWindow() and SubClassWindow() ala
"Subclassing Windows with the Microsoft Foundation Class Library" by Dale E.
Rogerson on the MSDN - again no joy!  What am I missing?

I'm using VC++ 2.1 with MFC 3.1 on Win NT 3.51.  Any help will be appreciated.





David W. Gillett -- DGILLETT@expertedge.com
Monday, January 29, 1996

[Mini-digest: 2 responses]

>  What am I missing?

  The system-supplied Edit control doesn't support transparent
backgrounds.

  In our app, we let the edit control force a solid background while 
editing the text, and redraw the text with the transparent background 
(this also means forcing the window underneath to redraw) when the 
edit control loses focus.  That might be acceptible for you.

  There are two other possibilities.  For one thing, you might check 
out the RichEdit control and see if it offers a transparent 
background as an option -- it could happen.
  The other possibility is to use ExtTextOut to implement your own 
edit-like window class.  Personally, I'd expect this mainly to make 
it clear why the edit control doesn't support them, but if you're 
wedded to the idea that you need transparent backgrounds while your 
user is editting the text then you may not have much choice.

Dave

-----From: mikeblas@interserv.com

On Mon, 29 Jan 1996, Willem Fourie  wrote:
>Hi, I'm using a CEdit derived control as a child window of a CView derived
>view.   This window is made a child of the view window using the Create()
>function.  I move the CEdit control around dynamically to give the user the
>impression that he is entering textual data as a 'graphic' object (along
>with polylines and other line graphics).  I use the OnCtlColor() function in
>the view to set text color and background.  Everything works great but I
>need to make the CEdit window completely transparent!
[snip]
>What am I missing?

In your OnCtlColor(), you should call SetBkMode() against the DC Windows 
gives you.  You should set the background mode to TRANSPARENT.

.B ekiM
--
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");





| Вернуться в корень Архива |