farbe von static-feld
-
probiers mal so:
ChildHandle->GetDlgItem(IDC_STATIC); StaticHandle->RedrawWindow(); dc = StaticHandle->GetDC(); StaticHandle->GetClientRect(rect); CBrush* lbrush = new CBrush; lbrush->CreateSolidBrush(RGB(255,255,255)); dc->SelectObject(&lbrush); dc->FillRect(rect, lbrush);
dabei gelten folgende deklarationen:
CWnd* MainHandle, *ChildHandle, *StaticHandle; CDC* dc;
so klappts bei mir zumindest.
-
@Uwe P...
danke, aber: Ja, Ja, Ja
sieht gut aus, aber wo bekomme ich die ganzen handles her? ich hab doch nur den dialog
-
oje, sorry.
@uwe
ist doch keine static kontrolle. ich hab ganz vergessen, dass ich das ding als CTransparentStatic genommen hab (hab ich mir irgendwo ausm internet geholt). ich hab das jetzt wieder rückgängig gemacht und jetzt ist die schrift weiß. nur der hintergrund ist jetzt halt nicht mehr transparent. gibts da eine lösung?
-
Setz mal in der WM_CTLCOLOR folgendes:
pDC->SetBkMode(TRANSPARENT);
Gruß
:: NoName ::P.S. Keine Ahnung obs funktioniert ...
-
geht leider nicht
-
Dann erweitere doch die CTransparentStatic-Klasse so, dass sie den Text auch weiß darstellen kann!
-
Genau, super Idee ! Poste mal den Code der Klasse CTransparentStatic !
Gruß
:: NoName ::
-
oje, da merkt man wieder, das ich totaler anfänger bin. ich hab mal wieder keine ahnung.
Poste mal den Code der Klasse CTransparentStatic !
// TransparentStatic.cpp : implementation file // #include "stdafx.h" //#include "TransparentStaticTest.h" #include "TransparentStatic.h" // CTransparentStatic IMPLEMENT_DYNAMIC(CTransparentStatic, CStatic) CTransparentStatic::CTransparentStatic() { } CTransparentStatic::~CTransparentStatic() { } BEGIN_MESSAGE_MAP(CTransparentStatic, CStatic) ON_WM_PAINT() END_MESSAGE_MAP() // CTransparentStatic message handlers void CTransparentStatic::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); }
-
Also,
soweit ich das überblicken kann, müsstest du eigentlich nur dc.SetTextColor(RGB(255,255,255)); am Ende des Quellcodes setzen :
// Set transparent background dc.SetBkMode(TRANSPARENT); dc.SetTextColor(RGB(255,255,255)); // Draw the text dc.DrawText(szText, client_rect, dwText); // Select old font dc.SelectObject(pOldFont);
Teste mal...
-
hey super. danke