Buttons lose rounded edges - OnPaint background |
Post Reply |
Author | |
doinIT
Newbie Joined: 16 March 2009 Location: Australia Status: Offline Points: 8 |
Post Options
Thanks(0)
Posted: 16 March 2009 at 2:37am |
I created an MFC Dialog app and used the vista skin which is working.
After finding out from another post that the skin builder/framework doesn't included background images for dialogs, I used the OnPaint routine of the main dialog and paint a background gradient image (from a physical .jpeg on disk) using CImage.
Problem is after I paint the background image, the buttons on the Dialog lose the round edges. Looks like they can no longer handle the transparecy of the images.
Anyone know why this would happen?
Thanks,
Jai
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Search in this forum. There was some samples how to draw transparent dialog.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
doinIT
Newbie Joined: 16 March 2009 Location: Australia Status: Offline Points: 8 |
Post Options
Thanks(0)
|
Thanks Oleg.
For others, here is a bit of an explanation and the code that fixed my problem.
I needed to handle the OnCtlColor method and return the brush to be used as the background for the control to be painted.
Inside the OnPaint method I draw a gradient jpeg image that fits the entire background of the Dialog.
I had to use use the same image that was used to paint the background to create a brush inside OnCtlColor (shown below) which fixed the problem of the buttons losing the transparency.
HBRUSH CSkinDlgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{ HBRUSH hbr; if( nCtlColor == CTLCOLOR_STATIC || nCtlColor == CTLCOLOR_BTN ) { if(img){ m_brush = CreatePatternBrush(img); // Previously created CImage if (pWnd->m_hWnd != this->m_hWnd){ CXTPWindowRect rcPaint(pWnd); CXTPWindowRect rcBrush(m_hWnd); HDC hDC = pDC->m_hDC; ::SetBrushOrgEx(hDC, rcBrush.left - rcPaint.left, rcBrush.top - rcPaint.top, NULL); ::SetBkMode(hDC, TRANSPARENT); ::SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT)); } } return m_brush;} else{ hbr = CXTPDialog::OnCtlColor(pDC, pWnd, nCtlColor); } return hbr;}
Cheers, Jai |
|
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 |