purple background when transparency = true
-
- Knows some wx things
- Posts: 33
- Joined: Fri Jun 30, 2017 12:34 pm
purple background when transparency = true
I have a Windows application running on WEC7 that uses wxWindows and when I have tranparency set to true on some text and images in the windows they should up with a purple accented output. Any reason for this and how could I remove it? Using wxWidgets 2.8.3
Re: purple background when transparency = true
Hi,
First of, any reason not to use 3.1.1?
Second - can we see some code and a screenshot of what is displayed? Unfortunately there is no one here on this forum whose name is Johnny-mnemonic.
Thank you.
First of, any reason not to use 3.1.1?
Second - can we see some code and a screenshot of what is displayed? Unfortunately there is no one here on this forum whose name is Johnny-mnemonic.
Thank you.
-
- Knows some wx things
- Posts: 33
- Joined: Fri Jun 30, 2017 12:34 pm
Re: purple background when transparency = true
I have to use 2.8.3 because the previous version of product uses 2.8.3 and the customer did not want to update for this hardware update.
I cannot show code it is company private but I can tell you that if I have text in a wxWindow and I set the fgcolor to blue, bgcolor to white and I turn on transparency, the text ends up with purple letters. This code has not changed since the last version of the product the only difference is now we are running on WEC7 versus WEC6/
I cannot show code it is company private but I can tell you that if I have text in a wxWindow and I set the fgcolor to blue, bgcolor to white and I turn on transparency, the text ends up with purple letters. This code has not changed since the last version of the product the only difference is now we are running on WEC7 versus WEC6/
Re: purple background when transparency = true
This sounds like you should be able to build a minimal, compilable sample that shows the problem.I can tell you that if I have text in a wxWindow and I set the fgcolor to blue, bgcolor to white and I turn on transparency, the text ends up with purple letters.
I assume WEC6 is technically XP and WEC7 is WIndows 7?
Use the source, Luke!
Re: purple background when transparency = true
Or even try the drawing sample...
Thank you.
Thank you.
-
- Knows some wx things
- Posts: 33
- Joined: Fri Jun 30, 2017 12:34 pm
Re: purple background when transparency = true
This is running on Windows Embedded Compact 7. In a paint event where paint is a wxDC*, the code does
paint->SetTextBackground((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
paint->SetFont(mFont);
wxBrush brush((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
wxPen pen((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
paint->SetBrush(brush);
paint->SetPen(pen);
paint->DrawRectangle(0, 0, GetSize().GetWidth(), GetSize().GetHeight());
Current mBackColor is dark blue and isTransparent() is returning true if object has
transparency set to true.
paint->SetTextBackground((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
paint->SetFont(mFont);
wxBrush brush((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
wxPen pen((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
paint->SetBrush(brush);
paint->SetPen(pen);
paint->DrawRectangle(0, 0, GetSize().GetWidth(), GetSize().GetHeight());
Current mBackColor is dark blue and isTransparent() is returning true if object has
transparency set to true.
Re: purple background when transparency = true
Hi,
Did you create wxPaintDC? If not - you should.
Thank you.
Did you create wxPaintDC? If not - you should.
Thank you.
Re: purple background when transparency = true
I still think we're missing some context. Please provide compiling sample code.
Are you using native MSW code somewhere that deals with the transparency?
Are you using native MSW code somewhere that deals with the transparency?
Use the source, Luke!
-
- Knows some wx things
- Posts: 33
- Joined: Fri Jun 30, 2017 12:34 pm
Re: purple background when transparency = true
This code is working on a Box with text that is overlaying a Box with a bitmap image. It is trying to show the text but hide the the background of the text box so the image can show through and only the foreground text is displayed. The wxDC* paint is created in other code. The transparency is set in the setTransparent code inheriting from wxWindow (wx/msw/window.h). Is there something special about setting the background color to RGB(255,0,255) in the way the background is shown such as making it clear so the image in the window containing the bitmap can show thru?
void Text::paintEvent(wxDC* paint)
{
paint->SetTextForeground(mForeColor);
paint->SetTextBackground((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
paint->SetFont(mFont);
wxBrush brush((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
wxPen pen((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
paint->SetBrush(brush);
paint->SetPen(pen);
paint->DrawRectangle(0, 0, GetSize().GetWidth(), GetSize().GetHeight());
void Text::paintEvent(wxDC* paint)
{
paint->SetTextForeground(mForeColor);
paint->SetTextBackground((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
paint->SetFont(mFont);
wxBrush brush((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
wxPen pen((isTransparent()) ? wxColor(255, 0, 255) : mBackColor);
paint->SetBrush(brush);
paint->SetPen(pen);
paint->DrawRectangle(0, 0, GetSize().GetWidth(), GetSize().GetHeight());
Re: purple background when transparency = true
setTransparent(wxByte transparency) is only supported for toplevel windows, not for child windows.
There was a wxWindowMSW::SetTransparent(bool) in older wxWidgets versions, but it never did anything.
A method isTransparent() does not exist in wxWidgets.
Also, there is nothing in wxWidgets that lets the color magenta become transparent.
Did you write the whole code for that project yourself? Because it sounds there is some Windows specific code somewhere that you don't know about. (Or that you're not telling about.)
There was a wxWindowMSW::SetTransparent(bool) in older wxWidgets versions, but it never did anything.
A method isTransparent() does not exist in wxWidgets.
Also, there is nothing in wxWidgets that lets the color magenta become transparent.
Did you write the whole code for that project yourself? Because it sounds there is some Windows specific code somewhere that you don't know about. (Or that you're not telling about.)
Use the source, Luke!
-
- Knows some wx things
- Posts: 33
- Joined: Fri Jun 30, 2017 12:34 pm
Re: purple background when transparency = true
The isTransparent function is part of the application objects. It just checks a private transparent flag that is set via application function calls.
Thanks for answering my question about magenta! I am using wxWIdgets 2.8.3 and I agree it looks like SetTransparent() is a no-op.
I guess my question is there a better way to do what this code is trying to do?
Thanks for answering my question about magenta! I am using wxWIdgets 2.8.3 and I agree it looks like SetTransparent() is a no-op.
I guess my question is there a better way to do what this code is trying to do?
Re: purple background when transparency = true
First i'd be quite curious to know how it ever workedI guess my question is there a better way to do what this code is trying to do?
With a screenshot it would be easier to understand what this code actually does. I assume you want to draw something custom on top of a native control? That would be the only situation i can think of, where you would need a hack like this.
Did you try setting the wxTRANSPARENT_WINDOW style flag? Then in the paint event to not draw the background, just draw the text.
Use the source, Luke!
-
- Knows some wx things
- Posts: 33
- Joined: Fri Jun 30, 2017 12:34 pm
Re: purple background when transparency = true
What the code wants to do is have the text foreground to show but the background of the text window to be transparent so the bitmap image in the window under the text window shows through. When the brush and pen are set with a magenta color then the white text shows white with a magenta accent, not really white but sort of a white magenta color.
I will look into your suggestion on the transparent flag with no background.
I will look into your suggestion on the transparent flag with no background.
Re: purple background when transparency = true
If you just need to draw text over a bitmap should should combine these two. Have a paint event handler that draws the bitmap and then the text on top.What the code wants to do is have the text foreground to show but the background of the text window to be transparent so the bitmap image in the window under the text window shows through.
Use the source, Luke!
-
- Knows some wx things
- Posts: 33
- Joined: Fri Jun 30, 2017 12:34 pm
Re: purple background when transparency = true
This code worked fine in Windows Embedded 6 so it has to be either something defined in the OS or the way I built the wxWidgets library using VS2008.
This code is used all over the application (about 40 windows) for all text windows.
This code is used all over the application (about 40 windows) for all text windows.
Last edited by marksatterfield on Wed Oct 24, 2018 5:45 pm, edited 1 time in total.