bitmaps for listview and treeview

I am facing trouble in settting a proper color
for the  bitmaps(icons) of listview and treeview. when i open the
bitmap in paint brush everything is ok. but when i
import the bitmap in the resource editor and compile it, during runtime - the light yellow color appears white.
I tried copy paste from bitmap in paint brush to resource editor,
however it does not work. To top it all when i change the color
of the bitmap in the resource editor, i am unable to save
new colors of bitmaps.
all suggestions are welcomed
LVL 1
MFCAnswerAsked:
Who is Participating?
 
jianliuerConnect With a Mentor Commented:
Can you tell me the type of the imagelist of your ListView and TreeView?(the nFlags parameter you specified in your Create() function of the CImageList object)

Send some pieces of codes to this address<jianliuer@sina.com>,I will try my best to help you.
0
 
MFCAnswerAuthor Commented:
Edited text of question.
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

Go to the properties of the bitmap and change the color to 256 and try it.

VinExpert
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
MFCAnswerAuthor Commented:
Thanks VinExpert, however it still does not work
0
 
jianliuerCommented:
You should not use bitmap with true-color in resource editor because the resource editor can only handle 256 colors bitmap.
Try the function LoadImage() which can read .bmp file.
0
 
MFCAnswerAuthor Commented:
thanks jinliuer.
When i use LoadImage, the icons are appearing light green instead of light
yellow. Do i have to make changes to palette ??
 I am increasing points to 100.
0
 
MFCAnswerAuthor Commented:
Hi  jianliuer :
Thanks for the response. I need help urgently.  I cannot send u the code as it is too big a code. i shall try to create a dummy project and send u the code. Meanwhile, this is what i am doing to display icons in the tree view.


OnInitialUpdate()
{
CBitmap             _bitmap;
CTreeView::OnInitialUpdate();
// Initialze the image list for out tree view
m_pilTreeIcons = new CImageList();
m_pilTreeIcons->Create(20, 20, ILC_MASK, 8, 4);
LPCTSTR lpszResourceName = MAKEINTRESOURCE(AM_IDB_TREEFIRST);
HBITMAP phBitmap = NULL;
HPALETTE *phPalette = NULL;
phBitmap = (HBITMAP)::LoadImage(AfxGetResourceHandle(),lpszResourceName,IMAGE_BITMAP, 0, 0,LR_CREATEDIBSECTION);
  //LR_DEFAULTCOLOR | LR_DEFAULTSIZE  );
if( phBitmap == NULL )
{
AfxMessageBox("unable to load bitmap");
return;
 }
 CBitmap *temp, temp1 ;
  temp = temp1.FromHandle(phBitmap );
_bitmap.LoadBitmap(AM_IDB_TREEFIRST);
m_pilTreeIcons->Add(&_bitmap,  (COLORREF)0xFFFFFF);
_bitmap.DeleteObject();

GetTreeCtrl SetImageList(m_pilTreeIcons, TVSIL_NORMAL);      
PopulateTree(); // to list tree items
}
0
 
MFCAnswerAuthor Commented:
Hi  jianliuer :
Don't bother to answer . I have solved the problem. I am going to give u points for the effort u have put in to answer my question. thanks a lot
0
All Courses

From novice to tech pro — start learning today.