EraseBkgnd of office 2007 style |
Post Reply |
Author | |
reeves
Newbie Joined: 12 September 2006 Status: Offline Points: 12 |
Post Options
Thanks(0)
Posted: 28 January 2007 at 9:33pm |
hi,
i enabled office 2007 blue style of skin framework on my app.
but i also wanna set background of dialog on it.
but almost of the standard controls can not be set as transparent.
only the static control can use OnCtlColor method to set transparency.
HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{ HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (nCtlColor == CTLCOLOR_STATIC && pWnd->IsWindowEnabled()) { pDC->SetBkMode(TRANSPARENT); return (HBRUSH)GetStockObject(NULL_BRUSH); } return hbr; } So, how can I set other controls to transparent, such as check box, radio, scrool bar and edit box.
refer the following pic
thanks in advance.
|
|
reeves
Newbie Joined: 12 September 2006 Status: Offline Points: 12 |
Post Options
Thanks(0)
|
sorry, that happens on CPropertyPage not CDialog
HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_STATIC && pWnd->IsWindowEnabled()) { pDC->SetBkMode(TRANSPARENT); return (HBRUSH)GetStockObject(NULL_BRUSH); } return hbr; |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
I sure it will not work even without skinframework.
try following. Load this bitmap and create brush from bitmap (m_brush)
from OnCtlColor:
if (hWnd != m_hWnd)
{ CXTPWindowRect rcPaint(hWnd); CXTPWindowRect rcBrush(m_hWnd); ::SetBrushOrgEx(hDC, rcBrush.left - rcPaint.left, rcBrush.top - rcPaint.top, NULL); ::SetBkMode(hDC, TRANSPARENT);
::SetTextColor(hDC, GetColor(COLOR_BTNTEXT)); } return m_brush;
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
reeves
Newbie Joined: 12 September 2006 Status: Offline Points: 12 |
Post Options
Thanks(0)
|
oleg, thanks for your helping but i am not sure what i have done is right, because i still can not set the controls as transparent as your advice.
HBRUSH COptionsPage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{ HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor); HDC hDC = GetDC()->m_hDC; HWND hWnd = pWnd->GetSafeHwnd(); switch(nCtlColor)
{ case CTLCOLOR_BTN: case CTLCOLOR_STATIC: case CTLCOLOR_EDIT: case CTLCOLOR_MSGBOX: CBrush *oldbrush;
pDC->SetBrushOrg(0,0); oldbrush=(CBrush *)pDC->SelectObject(&pbitmap); hbr = (HBRUSH) oldbrush; if (hWnd != m_hWnd) { CXTPWindowRect rcPaint(hWnd); CXTPWindowRect rcBrush(m_hWnd); ::SetBrushOrgEx(hDC, rcPaint.left-rcBrush.left, rcPaint.top-rcBrush.top, NULL); ::SetBkMode(hDC, TRANSPARENT); ::SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT));// GetColor(COLOR_BTNTEXT)); } pbitmap.DeleteObject();
return hbr;
break;
default: hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor); break; } } so, the scroll bar's backgroud is office 2007 skin.
some part of static is white, some part is office 2007 skin.
check box's bk is office 2007 skin, even the edit box has black frame.
so, how to do next?
thanks a lot.
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi, Attach project to debug it.
line
HDC hDC = GetDC()->m_hDC;
looks very wrong. these also:
oldbrush=(CBrush *)pDC->SelectObject(&pbitmap);
pbitmap.DeleteObject();
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |