I want to make Multiline Edit Control, with a transparent background.
( Only Text And scrollbar should be visible ), how can i do this? :confused:
Printable View
I want to make Multiline Edit Control, with a transparent background.
( Only Text And scrollbar should be visible ), how can i do this? :confused:
If i could change the background of my edit control, i could sucssed.
So that is a good solution too. How todo that?
I mean to change the background to a HBITMAP.
I remember this tutorial on windows skinning address topics in transperancy.. although I am not sure if the same methods would apply to a multiline edit box...
tried googling for an owner-draw edit box.. no love
>>make Multiline Edit Control<<
Create the control with the ES_MULTILINE style.
>>change the background to a HBITMAP<<
Use CreatePatternBrush (very limited capability on win95, okay for later versions of windows) to convert the bitmap into a brush and return its handle from WM_CTLCOLOREDIT handler of the parent window (or WM_CTLCOLORSTATIC if the edit control is read only).
Edit controls.
Thanks. It seems that i have to do the same thing for RichEdit. Sorry.
And my RichEdit has a VSROLLbar.
Since RichEdit doesn't have a WM_CTLCOLORXXX, i don't know what to do...
There is a function to set a color of a Rich Edit Box (COLORREF), but there is nothing which includes HBRUSH...
with richedits you can send the EM_SETBKGNDCOLOR message, with
set the wparam to 0 and set the lparam to a 0x00bbggrr value, or also works setting it to a (COLORRREF)RGB(r,g,b) return.Code:wParam = (WPARAM) (BOOL) fUseSysColor;
lParam = (LPARAM) (COLORREF) clr;
Niara
You have no idea what your talking about.Quote:
Originally Posted by Niara
I want to talk to Ken Fitlike.
There isn't even OWNERDRAWN style. There must be solution to this. I tryed to use Edit Control,
( its Read Only )
but when i scroll down a little bit. The background image freaks out...
One possibility might be to subclass the richedit control, and BitBlt your bitmap during handling of WM_ERASEBKGND for that control. Another, possibility is to superclass the richedit control and change the HBRUSH of the WNDCLASSEX to that returned by CreatePatternBrush.
Not sure if either of these will work, though.
For more information about window sublassing, search this board and read this.
For superclassing, see the bottom of this msdn page (also contains more information on subclassing).
>>You have no idea what your talking about.<<
(s)he's factually correct and, while it's not exactly what you're looking for, you'll get more and varied help if you exhibit more grace and less impatience towards those generous enough to offer free advice.
I know, i know. Just that (s)he started to explain what i allready wrote.Quote:
Originally Posted by Ken Fitlike
no problem
void rename (open char* ">>(s)he's factually<<", concrete char* ">>he's...<<") :)
Niara
I'm close to solution with subclassing. Iv'e tryed both paths, and subclassing seems to work.
I did what you told me, and background is drawn. But the problem is that when i assign new
WndProc, the old one isn't used. And the old one contained just about everything about
the RichEdit.
So the result is a RichEdit with only things i did in new WndProc. So things that where in
previus WndProc ( like TEXT, SCROLLBAR, ...) aren't there, obviusly.
Can i somehow copy stuff from old WndProc to my New one?
You use the CallWindowProc function to call the old window procedure. This function should usually be called instead of DefWindowProc. The first argument, lpPrevWndFunc, should be the value returned by SetWindowLongPtr. Your window procedure should look something like this:
Code:LRESULT CALLBACK WndProc( ... )
{
switch (uMsg)
{
case WM_ERASEBKGND:
{
// do your stuff here...
}
default:
{
return CallWindowProc(oldWindowProc, hwnd, uMsg, lParam, wParam);
}
}
return 0;
}
Ok, now i got another problem.
The thing you told anonytmouse works.
But now i must use WM_PAINT message. If i do things there, then other WM_PAINT isn't executed.
Where can i find the source of handling WM_PAINT for a RichEdit. I'm just gonna copy the source,
and modify it a little bit... ( So that i Select my HBRUSH )
, WM_ERASEBKGND works only when i select text in RichEdit. And still The BkMode is set to OPAQUE,
that's why i'm going to play with WM_PAINT.
I don't wanna search all the windows headers. Does someone knows where the WM_PAINT message
for RichEdit is defined?
I have somekind of thing that points to WndProc, but i don't know how could that be helpfull...
Code:oldWindowProc
Windows is not open-source. The code for WM_PAINT for a rich-edit is not available. You can try calling the old window procedure before or after your extra processing but I'm not optimistic this will work. Even if you get it working on your platform, you should consider that the rich-edit implementation may be different on other platforms.
I did a search and apparently rich-edit versions 2 and greater (make sure you are loading the correct DLL) support the WS_EX_TRANSPARENT extended style. You would use this style and display your background image in a control behind the rich-edit control.
http://groups.google.com/group/borla...48987d4eae24bf
http://home.att.net/~robertdunn/FAQs/Faqs.html#Bmk010
http://www.codeproject.com/richedit/SemiRichEdit.asp
There is also windowless rich-edit controls, although this would be far more complex to use.
Heres how my code looks like right now:
- First i tryed to put WS_EX_TRANSPARENT, with other styles (WS_BORDER | WS_VSCROLL), but then i gotCode:CreateWindowEx(WS_EX_TRANSPARENT, RICHEDIT_CLASS, NULL,
WS_CHILD | ES_MULTILINE | WS_BORDER | WS_VSCROLL,
10, 10, 500, 400,
hWindow, (HMENU)(400), hinstance, NULL);
RichEdit, which displays my text with "*", like a password field.
- Then i moved the style above, like you can see in the code. Now it looked like it worked. But heres
what happened.
I put my drawing in WM_ERASEBKGND ( a single BitBlt ) In my window there is nothing but RichEdit.
Problems that occured:
- only current line of text is visible when i type text
- the background isn't updated when i type so i got |||||| on the buffer ( | - typing cursor )
- the background is updated only when i select text. and only current line. - wierd
- The arrows of my scrollbar aren't displayed.
- when i select text the text goes behind my bitmap, this works if i select multiple rows.
It seems that i will never finish this...
also i did this
Code:LoadLibrary(TEXT("Riched20.dll"));
You will need to subclass the WM_CHAR message of the rich-edit and invalidate the parent window so that the background is repainted each time a character is received. There is an example here:
Making a RichEdit see through
I quit this. It isn't worth all the trouble. I could easyer create my own RichEdit...
Thanks for help everyone, especialy anonytmouse & Ken Fitlike.