Print Page | Close Window

EraseBkgnd of office 2007 style

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Skin Framework
Forum Description: Topics Related to Codejock Skin Framework
URL: http://forum.codejock.com/forum_posts.asp?TID=6253
Printed Date: 26 June 2024 at 1:10am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: EraseBkgnd of office 2007 style
Posted By: reeves
Subject: EraseBkgnd of office 2007 style
Date 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.



Replies:
Posted By: reeves
Date Posted: 28 January 2007 at 10:02pm
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;


Posted By: Oleg
Date Posted: 29 January 2007 at 1:13am
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


Posted By: reeves
Date Posted: 29 January 2007 at 10:00pm

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.


Posted By: Oleg
Date Posted: 30 January 2007 at 2:39am

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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net