Wierd Text Disappearing Bug
Wierd Text Disappearing Bug
I've come across a wierd bug which seems to be caused by some sort of built-in Windows functionality.
I have a login screen which takes in a username and password via two wxTextCtrls (password of course using wxTE_PASSWORD style). It also contains a few wxPanels that hold text drawn via the OnPaint event (the reason I'm not using wxStaticText control being that I want the transparency behind the text for drawing on top of a graphical background).
Basically what happens is this. If the Capslock key is on while I type in the password box, I get a message bubble warning saying something to the effect of "Capslock is on, this could cause your password to be incorrect". Which is fine. Except as soon as this message bubble disappears, ALL of my text on the frame also disappears!
I'm including the wx/msw/wx.rc resource for Windows XP style, which I'm pretty sure is why this warning bubble is coming up (I checked some older versions before I added it and the bubble never appeared). The bubble itself I don't mind but I definately don't want my text disappearing.
So does anyone have any idea why this would be happening? Or better yet, how to fix it? I don't care if I have to somehow disable that warning bubble, I just don't know how to do that. But it seems wierd that the bubble would wipe all the text I've drawn in other panels.
When I get home I'll upload some pictures to show what I mean.
Edit: I discovered if the window is redrawn (i.e. another window is placed over it and then you go back to it) the text comes back. It's just after that message bubble is dismissed that the text disappears.
I have a login screen which takes in a username and password via two wxTextCtrls (password of course using wxTE_PASSWORD style). It also contains a few wxPanels that hold text drawn via the OnPaint event (the reason I'm not using wxStaticText control being that I want the transparency behind the text for drawing on top of a graphical background).
Basically what happens is this. If the Capslock key is on while I type in the password box, I get a message bubble warning saying something to the effect of "Capslock is on, this could cause your password to be incorrect". Which is fine. Except as soon as this message bubble disappears, ALL of my text on the frame also disappears!
I'm including the wx/msw/wx.rc resource for Windows XP style, which I'm pretty sure is why this warning bubble is coming up (I checked some older versions before I added it and the bubble never appeared). The bubble itself I don't mind but I definately don't want my text disappearing.
So does anyone have any idea why this would be happening? Or better yet, how to fix it? I don't care if I have to somehow disable that warning bubble, I just don't know how to do that. But it seems wierd that the bubble would wipe all the text I've drawn in other panels.
When I get home I'll upload some pictures to show what I mean.
Edit: I discovered if the window is redrawn (i.e. another window is placed over it and then you go back to it) the text comes back. It's just after that message bubble is dismissed that the text disappears.
Hi Ksmith22,
just some quick thoughts:
- You are creating a wxPaintDC in you paint handler, aren't you?
- Those baloon tips can only be turned off by a registry key AFAIK.
- If the text is still visible when the baloon tips pops up but gets inivisble as soon as you start typing (is that the way it happens?), you could try to catch wxEVT_COMMAND_TEXT_UPDATED events via EVT_TEXT(id, func) and refresh the whole window as a workaround. Ugly, but could work.
Chris
just some quick thoughts:
- You are creating a wxPaintDC in you paint handler, aren't you?
- Those baloon tips can only be turned off by a registry key AFAIK.
- If the text is still visible when the baloon tips pops up but gets inivisble as soon as you start typing (is that the way it happens?), you could try to catch wxEVT_COMMAND_TEXT_UPDATED events via EVT_TEXT(id, func) and refresh the whole window as a workaround. Ugly, but could work.
Chris
this->signature=NULL;
Yupchris wrote:Hi Ksmith22,
just some quick thoughts:
- You are creating a wxPaintDC in you paint handler, aren't you?
Yeah, that's the way it happens. I might just put the text directly onto my background image instead. Not what I wanted to do but I don't know how else to fix it.- Those baloon tips can only be turned off by a registry key AFAIK.
- If the text is still visible when the baloon tips pops up but gets inivisble as soon as you start typing (is that the way it happens?), you could try to catch wxEVT_COMMAND_TEXT_UPDATED events via EVT_TEXT(id, func) and refresh the whole window as a workaround. Ugly, but could work.
Chris
-
- Super wx Problem Solver
- Posts: 424
- Joined: Tue Jul 12, 2005 8:44 pm
- Location: Alabama, USA
toxicBunny wrote:Could you post some code for this dialog showing the constructor, the OnPaint event handler, and how you handle the background image? Maybe it would help to see things in a little more detail...
-Scott
Code: Select all
CustomPanel::CustomPanel(wxWindow* p, const wxPoint& pos, const wxSize& size,char* n,
wxString t,wxFont f, wxColour c)
: wxPanel(p,wxID_ANY,pos,size,0|wxTRANSPARENT_WINDOW|wxTAB_TRAVERSAL,n)
{
// Define private variables
parent = p;
text = t;
width = size.GetWidth();
height = size.GetHeight();
font = f;
color = c;
padding = 0;
m_draggingWindow = false;
hasBackground = false;
isCentered = true;
hasShadow = false;
SetBackgroundStyle(wxBG_STYLE_CUSTOM); // Keep background transparent on redraw
}
Code: Select all
void CustomPanel::OnPaint(wxPaintEvent& WXUNUSED(evt))
{
wxCoord text_width,text_height;
wxPaintDC dc(this);
dc.SetFont(font);
dc.SetBackgroundMode(wxTRANSPARENT); // Text background is transparent
if(hasBackground) // If panel has a background image, draw it
dc.DrawBitmap(bgimg, 0, 0, true);
// If text has a shadow, draw label first in black but offset by 2 pixels
if(hasShadow)
{
dc.SetTextForeground(*wxBLACK);
if(isCentered)
{
// Get size of text string for centering
dc.GetTextExtent(text, &text_width, &text_height);
// Draw text centered on panel
dc.DrawText(text,wxPoint(((width-text_width)/2)+2+padding,
((height-text_height)/2)+2));
}
else
dc.DrawText(text,wxPoint(2+padding,2));
}
dc.SetTextForeground(color);
// If centered, draw centered on panel. Otherwise, draw left aligned.
if(isCentered)
{
// Get size of text string for centering
dc.GetTextExtent(text, &text_width, &text_height);
// Draw text centered on panel
dc.DrawText(text,wxPoint(((width-text_width)/2)+padding,
(height-text_height)/2));
}
else
dc.DrawText(text,wxPoint(0+padding,0));
}