 |
|
 |
cool thanks got it working after a few tries..
im using the Treepropsheet class pulled out from emule
and all i had to do to get this to work is add the #include .hpp line
and add the function call to my ALREADY over-ridden oninitdialog function in TreePropSheet.cpp
almost forgot.. im using icons not bitmaps too
like this, TreePropSheet::CTreePropSheet::SetPageIcon( &wndName, IDI_ICON1 );
NOT like this, TreePropSheet::CTreePropSheet::SetPageIcon(&wndName, Images, 0);
hope this might help others to get this fix working.
|
|
|
|
 |
|
|
 |
|
 |
Simply made with great effect. Thanks a lot! It prevents me from a waste of time for creating my own solution.
|
|
|
|
 |
|
 |
Although this is a fairly old article, I'd just like to say thanks; this has helped me loads with an app I'm making - CTreePropSheet is great but it just didn't look right.
|
|
|
|
 |
|
 |
Hi all,
I don't know if I'm missing something, but the instructions were perfectly clear. I included the HighColorTab.hpp file in my project, added a #include at the top of the file containing the OnInitDialog() function and added the line: HighColorTab::UpdateImageList( *this ); in the code.
I am using the original demo project for TreePropSheet, but I get an assertion in line 109 of file HighColorTab.hpp. Moving the HighColorTab line to other parts of the function makes no difference. I get no assertion in the demo project supplied with HighColorTab, or with TreePropSheetEx demo.
I haven't changed anything else in the original demo project. Does anyone have any idea why I am getting this assertion?
Thank you all very much for any replies.
--
/stokos
|
|
|
|
 |
|
 |
I suggest that you step through the code to see why bSuccess gets set to false. The variable is used to gather all errors so it is hard to tell why you get the assertion.
Regards,
Yves Tkaczyk
|
|
|
|
 |
|
 |
Hi Yves,
Thank you for the prompt reply.
Having stepped through the code, bSuccess is set to false because
apILNew->Add(pPage->m_psp.hIcon) returns -1 inside the first 'if' statement. The code then doesn't go inside the second if statement. hIcon is not NULL nor is apILNew (the image list).
I don't know what else is wrong. I'm using VC++ .NET 2003 on WinXP Pro SP2, if that's any help.
Thanks again.
--
/stokos
|
|
|
|
 |
|
 |
Hi again,
I don't know if this helps but, still relating to the original TreePropSheet demo, if I replace the CTreePropSheet with a normal MFC CPropertySheet and comment out the specific TreePropSheet function calls from 'TreePropSheetDemo.cpp'("SetEmptyPageText", "SetTreeViewMode", "SetTreeDefaultImages", "DestroyPageIcon"), the assertion no longer occurs!
I hope this helps a little, because I still haven't found the reason behind the assertion. Note I am using the original TreePropSheet demo program with no modifications or customisations from the original code.
|
|
|
|
 |
|
 |
Stokos,
I had the exact same problem (not getting the full-colour images with the original TreePropSheet class). Were you loading images from a bitmap, instead of from a file stored as an icon? That's what I was doing, and I think that's why it wasn't working.
If anyone is interested in what I did to work around the issue was:
1) Add a (public) member to CTreePropSheet:
CImageList* m_pExternalImageList;
2) swap out the imagelist for the tab. Modify the function:
BOOL CTreePropSheet::OnInitDialog()
...
if (m_bTreeImages)
{
if(NULL!=m_pExternalImageList){
CTabCtrl* pTabCtrl = GetTabControl();
if(NULL!=pTabCtrl){
pTabCtrl->SetImageList(m_pExternalImageList);
}else { ASSERT(false); }
}
m_pwndPageTree->SetImageList(&m_Images, TVSIL_NORMAL);
m_pwndPageTree->SetImageList(&m_Images, TVSIL_STATE);
}
...
3) In your code (after you create the sheet, but before the DoModal() call)
a) add a helper function:
void CYourClass::AddPage(
TreePropSheet::CTreePropSheet& propSheetToAddTo,
CImageList& imageList,
CImageList& externalImageList,
CPropertyPage* pPageToAdd,
int imageIndex)
{
// imageIndex parameter is an index into the bitmap
TreePropSheet::CTreePropSheet::SetPageIcon(pPageToAdd, imageList, 0);
externalImageList.Add(imageList.ExtractIcon(imageIndex));
propSheetToAddTo.AddPage(pPageToAdd);
}
b) use the following to load up the imagelist
**** NOTE *** do NOT use the CImageList::Create that takes a IDB_BITMAP because
this will not be full-colour
CImageList externalImageList;
externalImageList.Create(16,16, ILC_COLOR32|ILC_MASK, 0, 9);
CImageList Images;
Images.Create(16,16, ILC_COLOR32|ILC_MASK, 0, 9);
CBitmap bm;
bm.LoadBitmap(IDB_OPTIONS_TREE); // YOUR BITMAP HERE
Images.Add(&bm, RGB(0, 0, 0));
TreePropSheet::CTreePropSheet sht( _T("Options") );
CPropertyPage page_0;
CPropertyPage page_1;
CPropertyPage page_2;
// last parameter is an index into the bitmap
AddPage(sht, Images, externalImageList, &page_0, 8);
AddPage(sht, Images, externalImageList, &page_1, 0);
AddPage(sht, Images, externalImageList, &page_2, 7);
// set the external image list pointer
sht.m_pExternalImageList = &externalImageList;
Hopefully this is of use to someone...
Warren
|
|
|
|
 |
|
 |
What you need to do is replace the original method with the following:
BOOL CTreePropSheet::SetPageIcon(CPropertyPage *pPage, UINT unIconId)
{
HICON hIcon = AfxGetApp()->LoadIcon( unIconId );
if (!hIcon)
return FALSE;
return SetPageIcon(pPage, hIcon);
}
Hope it helps.....
|
|
|
|
 |
|
 |
I got the same problem:
stokos wrote: I am using the original demo project for TreePropSheet, but I get an assertion in line 109 of file HighColorTab.hpp.
The assertion occurs if no icon is setted for any of the propertypages.
|
|
|
|
 |
|
 |
I notice with great interest the two images of a CPropertySheet, one with what I might call Windows 98 coloring, the other with more modern color style.
How to get the nice white/pale grey and orange? I have several programs using CPropertySheet. Most use the drab brown colours, but one I wrote two weeks ago happened to use the new off-white. Today, my latest coding shows it in brown again. Why this one should be a nice colour and the rest all horrible, I really don't know.
Any clues?
Shraddhan
|
|
|
|
 |
|
 |
Shraddhan,
The coloring is the Windows XP theme. It is only available in Windows XP and theming must be enabled. To enable theming, you must include a manifest file. This can be done either in your resource file or as an extra file. There is a tool on code project (MakeXP[^] by Ernesto D.) that let you easily upgrade an application with the manifest file.
Hope this helps. Regards,
Yves Tkaczyk
|
|
|
|
 |
|
 |
I run the demo program under Windows XP and it worked great. However, when I tried it on several W2K machines, it displayed only 16 colors. I have set display effects to "Show icons using all possible colors" in display properties. I have also set the registry "HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\Shell Icon BPP" to 24 instead of 16. But none of them helps. If anyone knows how to solve the problem please let me know.
Thanks!
|
|
|
|
 |
|
|
 |
|
 |
Yves,
Thanks for your quick response. I actually have not written any code yet. I have downloaded your projects (both HighColorTab and TreePropSheetEx_Demo from The Code Project web site) and got the precompiled exe programs from the Release directories. I tried them on my develop computer which is Dell 420MT workstation with NVIDIA Quadro FX 500/600 PCI adapter. Also tried on IBM with Intel 82545G/GL video card. They both set to 32bit color and 1280 X 1024 resolution. It must be my computers that some switches may not set right. There is no problem when run program under Windows XP. However, under Windows 2000, I can only see 16 color and unpleasant images.
jz
|
|
|
|
 |
|
 |
Nice Code. Works great for me. Just a little kink for Unicode though. The following line doesn't compile:
bSuccess &= ( -1 != apILNew->Add( AfxGetApp()->LoadIcon( pPage->m_psp.pszIcon) ) );
ofcourse this is nothing that a little A2T can't fix.
|
|
|
|
 |
|
 |
Yves,
Thanks for your article. It wasn't quite what I wanted but after reading your code I realized my mistake was in just one line of code.
I wanted to add true color bitmaps to my tab control (CTabCtrl) - not a property sheet. I realize now that the ICL_MASK flag when creating the image list is VERY important.
So, for anyone else who is just using a plain old CTabCtrl, you can add your images like this:
CImageList m_tabImageList;
CTabCtrl m_tabCtrl;
m_tabImageList.Create(16, 16, ILC_COLOR32|ILC_MASK, 3, 3);
m_tabImageList.Add( ::LoadIcon(::AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON1)) );
m_tabCtrl.SetImageList(&m_tabImageList);
m_tabCtrl.InsertItem(0, _T("tab 1"), 0);
I'm using icons to store each image, but you can just as easily use a bitmap.
Well, hope that helps some folks out.
Sam.
|
|
|
|
 |
|
 |
Thanks alot, it certianly helped me.;)
|
|
|
|
 |
|
 |
It did .... thanks
|
|
|
|
 |