Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - EraseBkgnd of office 2007 style
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

EraseBkgnd of office 2007 style

 Post Reply Post Reply
Author
Message
reeves View Drop Down
Newbie
Newbie


Joined: 12 September 2006
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote reeves Quote  Post ReplyReply Direct Link To This Post Topic: EraseBkgnd of office 2007 style
    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.
Back to Top
reeves View Drop Down
Newbie
Newbie


Joined: 12 September 2006
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote reeves Quote  Post ReplyReply Direct Link To This Post 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;
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
reeves View Drop Down
Newbie
Newbie


Joined: 12 September 2006
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote reeves Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.