imagelist.add ILC_COLOR4 images show w cyan bkground. MFC bug?

Hi All,

Having a minor problem with loading icons from bitmaps when they are 4 bit
color in VS6. Here's a simple example:

Make a simple mfc dialog-based app named "fourbit" with default choices.
Make a new empty bitmap image in paint and set the width and height to 16
pixels.
Save it as "4biticon.bmp" with the 16 color bitmap option in the root folder
of you app.

in the header of the dlg "fourbitdlg.h" add an imagelist member:
  CImageList m_imagelist;

in the resource editor add a listcontrol default IDC_LIST1 and set it to
style small icon,top,none with single selection and no column header, all
else default.

With class wizard add a member variable for the list of type CListCtrl andf
named m_list

in the dialog class OnInitDialog() method after the
  CDialog::OnInitDialog();
 line add the following code :

  m_imagelist.Create( 16, 16, ILC_COLOR4, 0, 1);
  CBitmap bm;
  HBITMAP * hB;
  hB = (HBITMAP*)::LoadImage(0, "4biticon.bmp", IMAGE_BITMAP, 0, 0,
                                       LR_LOADFROMFILE |
LR_CREATEDIBSECTION);
  if (hB)
  {
    bm.Attach(hB);
    m_imagelist.Add(&bm,RGB(0,0,0));
    m_list.SetImageList(&m_imagelist,LVSIL_SMALL);
    m_list.InsertColumn(0,"",LVCFMT_LEFT,100);
    m_list.InsertItem(0,"item1",0);
  }


then run the app.

Item 1 shows in the list box with a cyan icon to its left when it should be
a white icon.

doing
   m_imagelist.GetBkColor()
shows that R G and B are all 0xFF

If  when adding the image to the imagelist you use
    m_imagelist.Add(&bm,RGB(255,0,0));

then it displays correctly?? say what? Yep then it works. Tried it on
several computers and 2 different OS (W2K and XP)

So what am I doing wrong?  What's with the cyan background as default....

BTW: loading 24 bit color icons using ILC_COLOR24 in the create works just
fine.

Thanks for your help,
Johnny
"Got me scratching my head, almost worn a bald spot"


0
11/18/2004 5:05:55 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
802 Views

Similar Articles

[PageSpeed] 21

"Johnny" <removeThis.gbl_user99@hotmail.com> wrote in message
news:F4Wmd.106049$bk1.59028@fed1read05...
> Having a minor problem with loading icons from bitmaps when they are 4 bit
> color in VS6. Here's a simple example:
>
> Make a simple mfc dialog-based app named "fourbit" with default choices.
> Make a new empty bitmap image in paint and set the width and height to 16
> pixels.
> Save it as "4biticon.bmp" with the 16 color bitmap option in the root
folder
> of you app.
(snip)
>   m_imagelist.Create( 16, 16, ILC_COLOR4, 0, 1);
>   CBitmap bm;
>   HBITMAP * hB;
>   hB = (HBITMAP*)::LoadImage(0, "4biticon.bmp", IMAGE_BITMAP, 0, 0,
>                                        LR_LOADFROMFILE |
> LR_CREATEDIBSECTION);
>   if (hB)
>   {
>     bm.Attach(hB);
>     m_imagelist.Add(&bm,RGB(0,0,0));
>     m_list.SetImageList(&m_imagelist,LVSIL_SMALL);
>     m_list.InsertColumn(0,"",LVCFMT_LEFT,100);
>     m_list.InsertItem(0,"item1",0);
>   }
>

You must set the background colour for each icon in the image-list.
Currently, you're initializing the imagelist without any background colour
(so no transparancy will be used).
Usually you do so by adding images seperately (AddIcon(..)). When adding a
bitmap, containing the icons for the list you must ensure to have a general
background colour for all images. Then set the background seperatly:
>     m_imagelist.Add(&bm,RGB(0,0,0));
The 2nd parameter will be the backcolour used, you're using black for that.
When each icon in the bitmap has different backcolour, you're in trouble
(you then should edit the icons first by changing the colours to a general
backcolour).
So when cyan is the general backcolour, you must set the exact RGB-colour as
2nd parameter when adding the bitmap.

cu.
-- 
Laurens Koehoorn


0
11/20/2004 6:01:32 AM
Thanks for replying Laurens.

"LhK-Soft" <someone@somewhere.net> wrote in message 
news:419eddc2$0$7831$ba620e4c@news.skynet.be...

> You must set the background colour for each icon in the image-list.
> Currently, you're initializing the imagelist without any background colour
> (so no transparancy will be used).

That's fine with me I don't want transparency I just want my images loaded 
as they are, works for 24bit images why not for 4 bit?
However this makes no sense as you will see from my original post that I am 
already setting a background color of black for each image as it is loaded. 
I also checked the general background color and found that it was already 
black so why should I have to set it to RGB(255,0,0) to get an already white 
image to show as white?

> Usually you do so by adding images seperately (AddIcon(..)).
AddIcon() doesn't seem to be a member of CImageList. Do you mean Add(HICON)? 
If so it won't work as I'm loading bitmaps.

>When adding a
> bitmap, containing the icons for the list you must ensure to have a 
> general
> background colour for all images.
There is no bitmap containing the icons for the list, in the final app there 
is a variable number of icons and so they must be loaded 1 by 1 at run time.

I don't want transparenecy so why should I set a background other than 
black?


 >Then set the background seperatly:
>>     m_imagelist.Add(&bm,RGB(0,0,0));
> The 2nd parameter will be the backcolour used, you're using black for 
> that.
It's true, that's what I did but the white image with the black background 
shows as cyan.


> When each icon in the bitmap has different backcolour, you're in trouble
> (you then should edit the icons first by changing the colours to a general
> backcolour).
My bitmaps don't have any background color they are just bitmaps.
This same code works just fine for 16 pixel square images in 24 bit color 
it's only the 4 bit that doesn't render correctly. Why?

> So when cyan is the general backcolour, you must set the exact RGB-colour 
> as
> 2nd parameter when adding the bitmap.
Cyan is *not* the background color. Why should I have to put anything but 
RGB(0,0,0) in the second parameter?
I'm missing something here.
When I check the background it returns RGB(0,0,0). Doesn't matter if I set 
the background color to RGB(0,0,0) and each image to RGB(0,0,0) it still 
shows the *all* white image as CYAN. I've tried this on two operating 
systems on two different computers. Same result: cyan for a pure white 
image.

I have a workaround setting the background as RGB(255,0,0) but that seems 
like a kluge. I shouldn't have to do that.
Thanks for your suggestions anyway.
Johnny 


0
gbl_user99 (30)
11/24/2004 12:31:51 AM
Reply:

Similar Artilces:

Embedded Chart doesn't show data value on treadline.
I have an embedded chart that I input data on a monthly basis. This month it is not showing the data that I input. It shows that trendline but not the value. I've gone into the Format Data Series tab and don't see anything that is out of wack. Can any one help? Does the chart have the min. or max. value specified for either the x or the y axis? If so, that might result in the new value not being shown. Does the chart series include the cell(s) with the new values? Click the plotted series. Check the range reference in the formula bar. -- Regards, Tushar Mehta www.tushar-m...

Add lines or blanks to report
I am using a report to create a roster for attendees. The attendees are invited and loaded into the database prior to the course. The report has, in it's detail section, the following text boxes: 1. running sum 2. Attendee (control source: [qry_Attendees]![Attendee]) 3. Employee ID (control source: [qry_Attendees]![EE_ID]) 4. Signature (signed by attendee) The problem is that many times there are more attendees than were originally invited. How can I provide them space to sign the printed roster? I'd like to have the whole page filled with Attendee, EE_ID and Signature lines r...

Refresh Slide Show
Is there a way to refresh every slide in the slide show using vba. I found the follow that will refresh the current slide but I need every slide to refresh/reset. I also realize I can put a blank slide between each slide with animation set to zero but that will make my show have a lot more slides than I really want. Sub RefreshSlide() Dim lSlideIndex As Long lSlideIndex = SlideShowWindows(1).View.CurrentShowPosition SlideShowWindows(1).View.GotoSlide lSlideIndex End Sub -- Mike Mast Special Education Preschool Teacher On 4/29/10 11:37 AM, Preschool Mike wrote: > Is t...

Automate Add-in
I distribute some workbooks that rely on the Analysis ToolPak. The recipients have a problem if the ToolPak is not installed. Upon opening the workbook, how can I : 1. Determine and remember if the ToolPak is already installed 2. Install the ToolPak if not already installed 3. Prior to closing the workbook, returning the ToolPak installation status to what it was initially -- Gary's Student GS, The following added to the "ThisWorkbook" module seems to work. Note that if the module level variable value is lost then the ToolPak will be left installed on Excel. '-----...

How to show data between two dates?
I have a list of tenants and the dates they moved in and out of their flats. I need to show which weeks within a specific period that the flats were filled - either by showing the tenants intials or a tick. A B C D E F G H Unit No Client Start End 04-01 11-01 18-01 25-01 1 JB 23-11 06-02 JB 2 GK 05-01 GK GK GK GK 3 LB 01-12 28-02 LB LB LB LB Does anybody know how is best to do this? We've tried using an IF formula but it doesn't work if their is a start and end date. ...

ColHdgs=Years show up as series not as legend labels #3
Hi Bernard - thanks for your helpful info. There's no way around it. We'll modify the macro to insert a blank column before th year-headings and data series, and input a row label for the dat series. You detailed responses and assistance is surely appreciated. ExcelProf =========== Bernard Liengme Guest Posts: n/a Re: ColHdgs=Years show up as series not as legend labels If I put the years in A1:A4 and the data in B1:B4, select A1:B4 an make a chart then I get a chart with two data series. Just as you say, th years are not used as the x-category values. Excel needs a blank hea...

Smut e-mails w/o FROM address
How can I get these mails into my Adult Junk folder? Here is the message (as best as I can remember): There is no FROM address, so it cannot be added to junk e-mail folder. Emma <anonymous@discussions.microsoft.com> wrote: > How can I get these mails into my Adult Junk folder? > Here is the message (as best as I can remember): There is > no FROM address, so it cannot be added to junk e-mail > folder. You'll have to create a rule that filters on some other criterion than the From address. -- Brian Tillman Couldn't you set up another rule to delete emails with &...

Add text automatically by recognized value
I'm trying to create a formula where it recognizes the first three digits of an item number at the same time entering the department name in the cell next to it. So let's say the item number R33569 for dept. WRP, I would only need it to recognize the R33 while entering WRP in the column next to the item number. This is what I got on my work sheet Column C Item Number R33569 R33456 R33447 In the column to the right or left doesn't matter which I need to say the dept. name. So how can i do that without having go through the hundreds of partnumbers that I have. ...

Images from file into datagridview
Hi, I really appreciate all the help I'm getting from this group. I'm loading a datagridview and I need to add thumbnails to it based on a string that's returned from the database. So first I load the data, then I create and add a datagridviewimagecolumn. The reason I'm adding a column to show the photo is that the rest of the grid is bound but the images aren't stored in the database. They're stored on file. Then based on a string column returned to the datagrid I loop through my newly created image column creating a bitmap for each row. I think cre...

can't add windows component
OS windows XP SP3 When trying to add windows components through the control panel or with the windows CD, I receive the following message... "SETUP WAS UNABLE TO OPEN INFORMATION FILE MSNMSN.INF"..... error code is 0x2 at line 0 ...contact administrator On Apr 14, 5:45=A0pm, MPW <M...@discussions.microsoft.com> wrote: > OS windows XP SP3 > When trying to add windows components through the control panel or with t= he > windows CD, I receive the following message... "SETUP WAS UNABLE TO OPEN > INFORMATION FILE MSNMSN.INF"..... error code is 0x2...

Not show the data in the query
Hello, I transfer the excel data to database, since I want bulit it's data base. I found it that query will not show anything, if nothing filled in the other table, like gender table. My question is, is it the reason?. in the linked field ( foreign key) is empty, can we proceed entering anther records. For example we have member table( member id) lingked to called table, if there is no call for this member, I will proceed to the next member with the call data, can we proceed entering the data? Thanks in advance for any idea provided. -- H. Frank Situmorang Use an outer join Det...

KB955759 is crashing IE6 and WMP11 under XP /w SP3
I am using XP Professional /w SP3. The following update is IMHO malfunctioning as after applying it, IE6 and Windows Media Player 9 will not start anymore: Update for Windows Server 2003, Windows XP and Windows 2000 (KB955759) After restoring my system to a restore point right prior to the installation of the above update it is working again fine. Nothing else was installed in between. This behaviour is a reoccuring one (tried it 2 times). As I noticed, I am "not alone out there" experiencing this problem. See e.g. thread named 'Hekp! IE8 problem after Window...

Outlook Signature w/Vcard missing information
When I create a signature that includes a Vcard, the telephone numbers on the contact card disappear. The information in most definately on the contact card, but once the vcard is attached to an Outlook e-mail message if you open the vcard, the telephone numbers are missing. ...

Errors compiling DLL with MFC and C-Runtime libraries
Hi, I created a DLL a while ago that compiled with no problem. I had to revisit the project to address a bug and when I went to compile it, I get the following build error: [...] Done Searching Libraries nafxcw.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype nafxcw.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype nafxcw.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc (Outpu...

popup in outlook wreaking havoc w/Acrobat users
Have been getting popup windows in Outlook every time I a) compose a new message and b)every time I receive email saying a program is trying to access my email address book; further asks if I want to allow it. Only way to compose or read email is to allow it. I since understand this is a recent problem w/anyone who has Microsoft XP and runs Adobe Acrobat. Anyone else who has this problem and has solved it please tell me what you did - I'm losing my sanity! Look up MS KB article 838871 on support.microsoft.com - it has all the information ... >-----Original Message----- >Ha...

MOSS 2007 Licensing w/ SQL Reporting Services
After review the installation guide it appears that I will have to install the MOSS 2007 WFE on our SQL Server to use the SSRS Sharepoint integration. So to use the SSRS SharePoint integration do I need to have an additional server license of MOSS so I can install the WFE on our SQL Server? Thanks, You don't need to install SharePoint on SQL. You do need to install the SSRS component on your SharePoint however. -- Daniel A. Galant Imagine what we could be... if we could just imagine. "Kai Stankey" <KaiStankey@discussions.microsoft.com> wrote in me...

Unable to add colleagues to my profile
Running SharePoint 2007 in a Server 2003 AD domain. I am able to see all of the users in the domain when I search for them on the add colleague page but when I hit OK I get the following error: "Jon Q cannot be found in the User Profile Store. Please contact an administrator. " Any idea what this means / how to fix it? ------=_NextPart_0001_82C0B022 Content-Type: text/plain Content-Transfer-Encoding: 7bit Hello JM, Make sure that the use profile and membership data is imported in SSP correctly which is required to use My Site Features. Check if the profile ...

how to replace funtion call in MFC app with my function code:- tzset() ->my_tzset()
hi, I wanted to change tzset() & isindst() functionality, for this i modified the vc src file crt/src/tzset.c and linked with my application, chnages were made with cansole application without mfc, but with mdi mfc application, orignal code was used for localtime & other time function instead of modified tzfuntions. Then I decided to replace original function by traping the function call & calling modified function insted of orignal one but no success. I would like to know which technique is used when someone modifies the orignal vc code. Regards. dilbir ...

Set Height Property of image control
I've tried to set the image height of an image control in the OnOpen code: Me.ctlImage.Height = 1.193 * Me.ctlImage.Width such that it will conform to the aspect ratio of images to be displayed. The assignment statement didn't have any affect. With a debug stop after the statement, neither the height or width show any value. What do I need to do here to set the Height property of the image control? Thanks, Bill I see I need to do two things. One is that the width needs to be obtained with the ImageWidth property. And two, that I need to deal with these quantities being in twi...

Supplier can be add to store or HQ?
I did try to add some new supplier in HQ and use worksheet 206 (inventory - supplier update). I connect the HQ server and client server. I realize that the new supplier are not update to store database. why? It does not work in opposit way either when I try to add new supplier to store database and try to upload to HQ database(using worksheet 401). Does anyone know why? Note:when connect between HQ server and client it shows that there is update for Inventory-supplier. Thank you very much for any help QN QN, Did you add the supplier to the worksheet? Look at the Contents tab of ...

Matrix item's Default Quantity is set to 1 Bug
RMS SO 2.0 When you create a new matrix item or add a dimension to an existing matrix item it wrongly sets the default Quantity on Hand and Quantity Available to 1 for all the products within the Matrix. I'm surprised that nobody else mentioned this in this NG since this causes huge inventory problems! When I reported this to MS they replied with the following: "The issue on matrix item's quantity that defaults to '1' is a known bug and has a fix request already." Since MS refuses to publicly make available a list with "Known Problems/Bugs/Issues" ...

Odd MFC+GDI MDI problem
I've recently been tasked to troubleshoot a problem, and I'm stuck. I didn't write the software, and the code is, frankly, a mess. I'm not particularly strong with MFC, and there's no architectural documentation or comments, and navigating the execution flow alone is sapping all my time, so I thought I'd pause that for a moment and post the symptoms. Maybe somebody has experienced this before and can tell me better where to look. The program is a simple "real-time data report" program that reads data off a server on the network and displays a report about th...

Gmail not showing in inbox Outlook 2007
Outlook 2007 on MS Windows 7 does not import gmail to in-box. All Mail and other gmail folders contain email in Outlook 2007. Gmail downloads into iPhone but not to in-box of Outlook 2007. Previously using MS Windows Vista and MS Outlook 2003 with no issues accessing gmail to iphone and in-box of outlook 2003. If you are saying your Gmail appears in a seperate data file (Personal Folder set) then you have configured the Outlook gmail account as Imap, and it is functioning correctly. You would need to configure the gmail account as a pop/stmp account in order for it to u...

CodeBehind not working or not compiling in VS2008 asp.net w/ infragistics
i have a website developed in vs2008, i have upgraded the version of infragistics controls its was using from 9.2 to 10.1. afterwards the codebehind doesnt seem to be compiling and only using the code that was there before i upgraded. i can drop controls on the page adn they show up but when i add code to modify the functionality of the page load for those controls nothing happens. also when i double click on the example asp button, it creates a script function on the html page instead of going to the code behind?? any help is appreciated! ...

HTTP Client: MFC Sockets or MFC WinInet?
Hello. I am building a very simple HTTP client. My requirements are but to send and receive XML requests. Currently, I have been using a combination of CSocket, CSocketFile and CArchive, as described in a MSDN resource [1]. However, while searching for more documentation, I bumped into an API (WinInet) which offers classes such as CHttpConnection. Should I stick to MFC's socket API or shoud I go for the other option? What would the tradeoffs be? In other words, what would you currently recommend for a simple HTTP client application? [1] http://msdn.microsoft.com/library/default.a...