microdrainage
asked on
Transparent static text label
Hi
I'm trying to write a small dialog application. I have a static label control on the dialog and I want to make its background transparent, but I'm not having any success.
Here's the code I'm trying at the moment
CStatic* pStaticText = (CStatic*)GetDescendantWin dow(IDC_ST ATIC_COMPA NY);
if (pStaticText != NULL)
{
DWORD style = pStaticText->GetStyle();
if (SetWindowLong(pStaticText ->m_hWnd, GWL_STYLE, style | SS_NOTIFY) == 0)
MessageBox("Unable to set window style");
CDC* pStaticDC = pStaticText->GetDC();
if (pStaticDC != NULL)
{
COLORREF bob = 0xFFFFFF;
pStaticDC->SetBkMode(OPAQU E);
if (pStaticDC->SetBkColor(bob ) == 0x80000000)
MessageBox("Unable to set back colour");
pStaticDC->SetBkColor(bob) ;
CString fontName = "Times New Roman";
CFont staticFont;
if (staticFont.CreateFont(100 0,0,0,0,FW _BOLD,0,0, 0,DEFAULT_ CHARSET,OU T_DEFAULT_ PRECIS,CLI P_DEFAULT_ PRECIS,DEF AULT_QUALI TY,DEFAULT _PITCH | FF_DONTCARE,fontName) != TRUE)
MessageBox("Unable to create font");
pStaticText->SetFont(&stat icFont,TRU E);
}else
{
MessageBox("Unable to get DC");
}
}
else
{
MessageBox("Unable to get window");
}
I've been trying to change the font size as well! In this code I'm simply trying to change the background colour just to see if anything happens. I haven't done any VC++ programming for a very long time) (It easy in VB!!!)
Thanks in advance
~Ian
I'm trying to write a small dialog application. I have a static label control on the dialog and I want to make its background transparent, but I'm not having any success.
Here's the code I'm trying at the moment
CStatic* pStaticText = (CStatic*)GetDescendantWin
if (pStaticText != NULL)
{
DWORD style = pStaticText->GetStyle();
if (SetWindowLong(pStaticText
MessageBox("Unable to set window style");
CDC* pStaticDC = pStaticText->GetDC();
if (pStaticDC != NULL)
{
COLORREF bob = 0xFFFFFF;
pStaticDC->SetBkMode(OPAQU
if (pStaticDC->SetBkColor(bob
MessageBox("Unable to set back colour");
pStaticDC->SetBkColor(bob)
CString fontName = "Times New Roman";
CFont staticFont;
if (staticFont.CreateFont(100
MessageBox("Unable to create font");
pStaticText->SetFont(&stat
}else
{
MessageBox("Unable to get DC");
}
}
else
{
MessageBox("Unable to get window");
}
I've been trying to change the font size as well! In this code I'm simply trying to change the background colour just to see if anything happens. I haven't done any VC++ programming for a very long time) (It easy in VB!!!)
Thanks in advance
~Ian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.