Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Transparency and Tab Controls
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Transparency and Tab Controls

 Post Reply Post Reply
Author
Message
JohnCrenshaw View Drop Down
Groupie
Groupie
Avatar

Joined: 08 September 2006
Status: Offline
Points: 65
Post Options Post Options   Thanks (0) Thanks(0)   Quote JohnCrenshaw Quote  Post ReplyReply Direct Link To This Post Topic: Transparency and Tab Controls
    Posted: 05 January 2007 at 4:43pm
Aaahhh!!! HELP!!! I pulled my hair out for a few days to be able to use the tab controls (CXTTabCtrl) nicely in 10.3.1. Now I have downloaded and installed 10.4 and my old fix doesn't work!!!
 
Some background on my solution. I needed to encapsulate each page of the control in it's own class (CXTResizePropertyPage derived currently.) Using the following code I added these pages:
 

m_page1->Create(&m_cWhenTabs);

m_page2->Create(&m_cWhenTabs);

m_page3->Create(&m_cWhenTabs);

m_page4->Create(&m_cWhenTabs);

m_cWhenTabs.AddControl(_T("1"), m_page1);

m_cWhenTabs.AddControl(_T("2"), m_page2);

m_cWhenTabs.AddControl(_T("3"), m_page3);

m_cWhenTabs.AddControl(_T("4"), m_page4);

m_cWhenTabs.SendInitialUpdate(TRUE);

m_cWhenTabs.SetAutoCondense(true);

 
The trouble with this is that the tab control, as encapsulated by CXTTabCtrl, has a nice pretty gradient background, while the property pages have a nice ugly solid background. Place the one on top of the other and it is REALLY ugly. I needed to fix this so I divined the following solution:
 

BOOL CTransparentForm::OnEraseBkgnd(CDC* pDC)

{

if (((CXTTabCtrl*)GetParent())->IsWindowVisible())

{

CXTPClientRect rcClient(((CXTTabCtrl*)GetParent()));

((CXTTabCtrl*)GetParent())->ClientToScreen(rcClient);

ScreenToClient(rcClient);

CXTPBufferDC memDC(*pDC, rcClient);

CRect r;

GetWindowRect(r);

((CXTTabCtrl*)GetParent())->ScreenToClient(r);

((CXTTabCtrl*)GetParent())->GetPaintManager()->DrawTabCtrl(&memDC, (CXTTabCtrl*)GetParent());

CRect rAll = rcClient;

rAll.MoveToXY(0,0);

// for some unknown reason, the ScrollDC function is leaving some stuff

// at the bottom as an artifact, however, the result is barely noticeable

// (only if you are looking for it) as long as we do the vertical and

// horizontal scrolls separately. If we do them together we get a nice

// vertical bar on the tab in the bottom left corner.

memDC.ScrollDC(0, -r.top, NULL, NULL, NULL, NULL);

memDC.ScrollDC(-r.left, 0, NULL, NULL, NULL, NULL);

}

return true;

}

 
Basically, the code assumes that we are on top of a CXTTabCtrl, which is the parent. We grab the parent, ask it to paint itself on our device context (as our method of erasing the background) position everything properly, and return true (to indicate that the background was erased.)
 
In version 10.3.1 this solution worked, in the current version the net effect seems to be nothing.
 
I would of course be satisfied with just being able to see the tab control background again, however, ultimately, this solution is ugly. Is there any chance of getting a more solid solution in the future, perhaps a CXTTabControlPage that removes the burden from code on the user side?
 
I have a hard time imagining that I am the first person to have a problem with this. Using tab controls is an immense amount of work because of the gradient background. I had to override and paint Checkboxes, radio buttons, group boxes, static text, and there are some things I didn't get to because I didn't need to use them. Perhaps it wouldn't be a bad idea to have a set of classes to draw these "transparent" items in a truly transparent fashion. Without this, the tab controls are hard enough to use, it isn't even worth it anymore for the average program, however, I digress.
 
I have everything in place to be able to use the tab controls, but I can't because the stupid property page can't pretend to be transparent anymore. Can anybody suggest a solution?
 
John.
 
Back to Top
jansim View Drop Down
Groupie
Groupie


Joined: 03 November 2005
Location: Canada
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote jansim Quote  Post ReplyReply Direct Link To This Post Posted: 28 March 2007 at 2:42pm
Hi, we have the same problem here. We worked hard to find a solution that worked with MFC and Win32. We want to do the same thing with the resize dialogs that Code Jock offers, but now the background of the dialog doesn't match the one of the tab control.
 
This is a regretable glitch. We cannot accept to release a software with ugly property pages.
 
So I ask the question again :
Can anybody suggest a solution?
 
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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 March 2007 at 1:22am
Hi,
Can you upload some screenshots to show what you mean.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jansim View Drop Down
Groupie
Groupie


Joined: 03 November 2005
Location: Canada
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote jansim Quote  Post ReplyReply Direct Link To This Post Posted: 29 March 2007 at 8:52am
I think we figured out how to do it !
 
When creating the tab child dialog, we must call the following:
 
XTPSkinManager()->EnableThemeDialogTexture( childDlg.GetSafeHwnd(), ETDT_ENABLE_TAB );
 
Then for every group box in the dialog, we must use a CXTResizeGroupBox.
 
It works fine this way.
 
Is is really simple to use, thank you for supporting this nice feature. We just had a hard time finding how to do it.
It would be a good idea to add a sample with a dialog as a tab control page that is not a CPropertyPage.
 
Best regards
Jansim
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.047 seconds.