I've got a Dialog with bitmap background.
How can I make CStatic (and Group Box text) background transparent?
ArtuS
1. A true flicker free and transparent CStatic
2. Transparent Flag for CStatic in resource Editor
Is this flag supposed to work? I am trying to see what this flag does. My text is still covering up the background behind it when I set it to true. Thanks Simon
3. Transparent backgrounds for CStatic
I have derived a CStatic control in order to add transparency and font
control. In a first step I have override OnPaint Method to
make the control transparent :
void CStaticTest::OnPaint()
{
CPaintDC dc(this); // device context for painting
// Where to draw text
CRect client_rect;
GetClientRect(client_rect);
// Get the caption
CString szText;
GetWindowText(szText);
// Get the font
CFont *pFont, *pOldFont;
pFont = GetFont();
pOldFont = dc.SelectObject(pFont);
// Map "Static Styles" to "Text Styles"
#define MAP_STYLE(src, dest) if(dwStyle & (src)) dwText |= (dest)
#define NMAP_STYLE(src, dest) if(!(dwStyle & (src))) dwText |= (dest)
DWORD dwStyle = GetStyle(), dwText = 0;
MAP_STYLE( SS_RIGHT, DT_RIGHT );
MAP_STYLE( SS_CENTER, DT_CENTER );
MAP_STYLE( SS_CENTERIMAGE, DT_VCENTER | DT_SINGLELINE );
MAP_STYLE( SS_NOPREFIX, DT_NOPREFIX );
MAP_STYLE( SS_WORDELLIPSIS, DT_WORD_ELLIPSIS );
MAP_STYLE( SS_ENDELLIPSIS, DT_END_ELLIPSIS );
MAP_STYLE( SS_PATHELLIPSIS, DT_PATH_ELLIPSIS );
NMAP_STYLE( SS_LEFTNOWORDWRAP |
SS_CENTERIMAGE |
SS_WORDELLIPSIS |
SS_ENDELLIPSIS |
SS_PATHELLIPSIS, DT_WORDBREAK );
// Set transparent background
dc.SetBkMode(TRANSPARENT);
// Draw the text
dc.DrawText(szText, client_rect, dwText);
// Select old font
dc.SelectObject(pOldFont);
}
When I try this control it is transparent but as soon as I try to change the
text by calling SetWindowText (except in the OnInitDialog), transparency
disappears.
ANY IDEA ?
5. flickering free and transparent CStatic
6. Transparent CStatic on Dialog with image in background
Hi everyone!
I'm developing a little program for windows mobile (think problem
should be the same for Win32) in MFC and have problems displaying a
dialog with an JPEG-image in the background and placing some
transparent CStatic's above it.
Here is what I dit:
BOOL CMyDialog::OnEraseBkgnd(CDC * pDC)
{
BOOL bRet = CDialog::OnEraseBkgnd(pDC);
// draw background image
CComPtr<IImagingFactory>pFactory;
HRESULT hr = pFactory.CoCreateInstance(CLSID_ImagingFactory);
IImage* pImg;
hr = pFactory->CreateImageFromFile(_T("\\myBackImage.jpg"), &pImg);
RECT a; a.bottom = 320; a.left = 0; a.right = 240; a.top = 0;
pImg->Draw(pDC->m_hDC, &a, NULL);
return bRet;
}
HBRUSH CAlarmDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_STATIC)
{
m_nullBrush.CreateStockObject(NULL_BRUSH);//m_bgBrush;
pDC->SetBkMode(TRANSPARENT);
return m_nullBrush;
}
return hbr;
}
The reason why I have to use the CComPtr things is because
CImage::Load() is not supported by Windows Mobile, but this seems not
to be the problem. The image is drawn to the background, but the areas
of the static controls is not painted at all, meaning the background
of the statics show the previous dialog "behind it" and the areas
surrounding them show the correct image.
What am I missing here?
Thanks for any help!
Greetings
Maik
7. CStatic::SetIcon Transparent.
8. How to build a running backround application ?
Hi, I'm very intrested in building an application that run all the time on the backround (like a windows service appliaction). When the user is typing a specific key (for example : ctrl+F1) - it comes up I don't care which language it is, any links to articles or any slight help, would be very helpfull Thank, Tal