How to Programmatecally Display Icons in CListBox

Hi,

I wanted to Programmatecally Display Icon in CListBox.

Here is the brief Code:

CListBox m_listbox;

m_listbox.Create(CBS_DROPDOWNLIST | WS_BORDER | WS_VSCROLL | WS_CHILD
|
                         WS_VISIBLE | LBS_STANDARD | LBS_HASSTRINGS ,
p, this,IDC_LIST);

m_listbox.SetFont(&m_Font);

I wanted to add icon to each string in the list box. It is equivalent
to auto suggest in VS when u press Ctrl+Space.

Thanks a lot in advance.
0
mmp.cse (1)
5/2/2008 9:38:09 AM
vc.mfc 33608 articles. 0 followers. Follow

9 Replies
521 Views

Similar Articles

[PageSpeed] 28

You will have to create an owner draw listbox, and do the painting yourself.

Here is an example:
http://www.codeproject.com/KB/combobox/combobold.aspx


AliR.


"Mahesh" <mmp.cse@gmail.com> wrote in message 
news:ebe4932e-c752-4ecb-b17d-c8fb1d8a9f25@y22g2000prd.googlegroups.com...
> Hi,
>
> I wanted to Programmatecally Display Icon in CListBox.
>
> Here is the brief Code:
>
> CListBox m_listbox;
>
> m_listbox.Create(CBS_DROPDOWNLIST | WS_BORDER | WS_VSCROLL | WS_CHILD
> |
>                         WS_VISIBLE | LBS_STANDARD | LBS_HASSTRINGS ,
> p, this,IDC_LIST);
>
> m_listbox.SetFont(&m_Font);
>
> I wanted to add icon to each string in the list box. It is equivalent
> to auto suggest in VS when u press Ctrl+Space.
>
> Thanks a lot in advance. 


0
AliR3470 (3236)
5/2/2008 2:00:00 PM
Posted the wrong link

http://www.codeproject.com/KB/combobox/combobold.aspx

AliR.


"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
news:g7FSj.652$nW2.11@nlpi064.nbdc.sbc.com...
> You will have to create an owner draw listbox, and do the painting 
> yourself.
>
> Here is an example:
> http://www.codeproject.com/KB/combobox/combobold.aspx
>
>
> AliR.
>
>
> "Mahesh" <mmp.cse@gmail.com> wrote in message 
> news:ebe4932e-c752-4ecb-b17d-c8fb1d8a9f25@y22g2000prd.googlegroups.com...
>> Hi,
>>
>> I wanted to Programmatecally Display Icon in CListBox.
>>
>> Here is the brief Code:
>>
>> CListBox m_listbox;
>>
>> m_listbox.Create(CBS_DROPDOWNLIST | WS_BORDER | WS_VSCROLL | WS_CHILD
>> |
>>                         WS_VISIBLE | LBS_STANDARD | LBS_HASSTRINGS ,
>> p, this,IDC_LIST);
>>
>> m_listbox.SetFont(&m_Font);
>>
>> I wanted to add icon to each string in the list box. It is equivalent
>> to auto suggest in VS when u press Ctrl+Space.
>>
>> Thanks a lot in advance.
>
> 


0
AliR3470 (3236)
5/2/2008 2:13:10 PM
AliR (VC++ MVP) wrote:
> You will have to create an owner draw listbox, and do the painting yourself.
> 
> Here is an example:
> http://www.codeproject.com/KB/combobox/

No, you don't need owner-drawing for a combobox
0
jack7275 (1)
5/2/2008 2:17:09 PM
I don't even you how to respond to this.  If I was a smartass then I would 
say something like.  "Oh yeah!"

He said listbox, the example is a comobox, but then again, the approach is 
exactly the same, since the drop down part of a combobox is in fact a 
listbox!

But enlighten us with your wisdom please.  People around here don't give 
much credit or thought to one liners.

AliR.


"jack" <jack@mexes.com> wrote in message news:fvf782$c2q$1@aioe.org...
> AliR (VC++ MVP) wrote:
>> You will have to create an owner draw listbox, and do the painting 
>> yourself.
>>
>> Here is an example:
>> http://www.codeproject.com/KB/combobox/
>
> No, you don't need owner-drawing for a combobox 


0
AliR3470 (3236)
5/2/2008 2:19:31 PM
Why are you creating this dynamically?  There are legitimate reasons to create a control
dynamically, but if this is a dialog, you should do this at design time.

It has to be owner-draw.  I tend to use bitmaps because they are easier than icons, and
you can use an owner-draw listbox.  You can also use icons and DrawIcon, but you will need
to use ::LoadImage to get the 16x16 icon.  You will use a DrawItem method of an owner-draw
listbox to do this.

I have several examples of owner-draw listbox on my MVP TIps site.  A fairly elaborate one
is my Logging ListBox Control, but it will show you the key ideas of owner-draw list boxes
				joe



On Fri, 2 May 2008 02:38:09 -0700 (PDT), Mahesh <mmp.cse@gmail.com> wrote:

>Hi,
>
>I wanted to Programmatecally Display Icon in CListBox.
>
>Here is the brief Code:
>
>CListBox m_listbox;
>
>m_listbox.Create(CBS_DROPDOWNLIST | WS_BORDER | WS_VSCROLL | WS_CHILD
>|
>                         WS_VISIBLE | LBS_STANDARD | LBS_HASSTRINGS ,
>p, this,IDC_LIST);
>
>m_listbox.SetFont(&m_Font);
>
>I wanted to add icon to each string in the list box. It is equivalent
>to auto suggest in VS when u press Ctrl+Space.
>
>Thanks a lot in advance.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
5/2/2008 2:35:13 PM
I ment to say

"I don't even know how to respond to this."


AliR.


"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
news:zpFSj.655$nW2.260@nlpi064.nbdc.sbc.com...
>I don't even you how to respond to this.  If I was a smartass then I would 
>say something like.  "Oh yeah!"
>
> He said listbox, the example is a comobox, but then again, the approach is 
> exactly the same, since the drop down part of a combobox is in fact a 
> listbox!
>
> But enlighten us with your wisdom please.  People around here don't give 
> much credit or thought to one liners.
>
> AliR.
>
>
> "jack" <jack@mexes.com> wrote in message news:fvf782$c2q$1@aioe.org...
>> AliR (VC++ MVP) wrote:
>>> You will have to create an owner draw listbox, and do the painting 
>>> yourself.
>>>
>>> Here is an example:
>>> http://www.codeproject.com/KB/combobox/
>>
>> No, you don't need owner-drawing for a combobox
>
> 

0
AliR3470 (3236)
5/3/2008 1:18:26 AM
> AliR (VC++ MVP) wrote:
>> You will have to create an owner draw listbox, and do the painting 
>> yourself.
>> 
>> Here is an example:
>> http://www.codeproject.com/KB/combobox/
>
> No, you don't need owner-drawing for a combobox

Right.
A hammer to crack a nut...


0
fgh (2)
5/3/2008 2:50:22 AM
Have you ever tried to crack black walnuts?  A hammer is sometimes adequate, providing you
are strong.

The point is, you only need to write one (exactly one) owner-draw listbox/combobox in your
life.  After that, you copy and paste as required, and it is very nearly zero cost to add
it to a project.
				joe

On Sat, 03 May 2008 04:50:22 +0200, "Alain" <fgh@pkc.com> wrote:

>> AliR (VC++ MVP) wrote:
>>> You will have to create an owner draw listbox, and do the painting 
>>> yourself.
>>> 
>>> Here is an example:
>>> http://www.codeproject.com/KB/combobox/
>>
>> No, you don't need owner-drawing for a combobox
>
>Right.
>A hammer to crack a nut...
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
5/3/2008 3:00:36 AM
Take a look at this code as well. I think this could be adapted to a drop 
down pretty easily.

http://www.codeproject.com/KB/combobox/clistboxst.aspx?display=PrintAll

Tom

"Mahesh" <mmp.cse@gmail.com> wrote in message 
news:ebe4932e-c752-4ecb-b17d-c8fb1d8a9f25@y22g2000prd.googlegroups.com...
> Hi,
>
> I wanted to Programmatecally Display Icon in CListBox.
>
> Here is the brief Code:
>
> CListBox m_listbox;
>
> m_listbox.Create(CBS_DROPDOWNLIST | WS_BORDER | WS_VSCROLL | WS_CHILD
> |
>                         WS_VISIBLE | LBS_STANDARD | LBS_HASSTRINGS ,
> p, this,IDC_LIST);
>
> m_listbox.SetFont(&m_Font);
>
> I wanted to add icon to each string in the list box. It is equivalent
> to auto suggest in VS when u press Ctrl+Space.
>
> Thanks a lot in advance. 

0
tom.nospam (3240)
5/5/2008 3:13:06 PM
Reply:

Similar Artilces:

GIF displaying #2
Hi, Does anybody have the C/C++ code to display GIF images in windows environment? I know that there is a bunch of function for BMP file, how about other image format? Regards, Nianwei Hi, Check out the Gdiplus API on microsoft's MSDN site. There are loads of articles to help you out. "Nianwei Xing" <nxing@is2.dal.ca> wrote in message news:3F15DF8B.2040605@is2.dal.ca... > Hi, > > Does anybody have the C/C++ code to display GIF images in windows > environment? I know that there is a bunch of function for BMP file, how > about other image format? >...

envelope icon notification
i get the envelope in the bottom right notification area when i have a new email. problem is when i click on the email to read it in outlook the envelope doesn't go away unless i click on another email which was already read. this only happens on my home pc, not at work...any ideas? -- dvoe ...

Can you display thumbnails of attached images ?
I would like to be able to display thumbnails of attached images, instead of simply seeing their icons. Essentially, that would mean that the attachment has been opened. The Office Outlook has been developed with businesses in mind, and attachments cannot be opened automatically. "Tristan Beard" <Tristan Beard@discussions.microsoft.com> wrote in message news:DBFD133C-22D4-4B6D-A65D-3F32C74EC6E4@microsoft.com... >I would like to be able to display thumbnails of attached images, instead >of > simply seeing their icons. ...

"Not enough system resources to display correctly" error
I get this error message when I ran my excel application with 10 charts (each in its own worksheet) which are continually updating with DDE link. I'm running Excel in Windows XP Personal Edition with the Pentium processor running around 1.2 GHz with 512MB of memory. Can somebody tell me what's wrong ? Do I need more memory ? Thank you very much. Hiromichi Watari ...

Disappearing page navigation icons
I'm running Publisher 2000 on a computer running Windows XP Pro with 240Mb RAM. From time to time, the page navigation icons (thumbnails) in the lower left-hand corner of the Publisher window disappear. If I minimize and then maximize the Publisher window, the thumbnails re- appear. Anyone have any ideas about whats going on? view, status bar -- Mary Sauer MS MVP http://dgl.microsoft.com/ http://mvps.org/msauer/ "Charlie Woller" <cwoller@4lpi.com> wrote in message news:0bbc01c344bd$3568e380$a001280a@phx.gbl... > I'm running Publisher 2000 on a computer running...

Font displays as squares rather than as characters...
I can use Estrangelo Edessa in Word but not in Excel. Is there something I can do so that it works correctly in Excel? ...

Contact name display -- Boss wants it different
I posted this in an exchange newsgroup, but got no reply, so I'm narrowing down my post to Outlook. Sorry if you already read it earlier. Please, here are questions we have about display of info in the "address card" view of a public folder : 1. We'd like to show the job title as a third line in the gray highlighted header, thus: Business Name Contact First Name Contact Last Name Job Title I can show the job title down in the address info box, with the prefix "job title:", but would prefer to have a three-line gray highlighted header, if possible. 2. We want t...

Hyperlink ("Text to Display")
Hello from Steved I have 2 issues please. 1. "Text to Display" is greyed out How can I edit,so I can change for example it is displaying 025 but I would like it to display Richmond Rd. 2. How does one turn off the WEB toolbar please as each time I Hyperlink the WEB tool bar pops up. Thankyou. ...

How to display animated GIF easily .. any system/ms contorl for this
Was wondering if there is a way to display an animated GIF easily .. maybe a variation / extension of the animation control ? -- All the best Thanks for the exponential performance info. "Doug Harrison [MVP]" <dsh@mvps.org> wrote in message news:<c1ibo01rf22ds149ukckbqhqb9bt3jsheq@4ax.com>... > It seems more likely you corrupted the heap somewhere. Show the call stack > and the code surrounding the crash site. Also give the exact exception type. > Also give compiler version and service pack. I take it you do have C++ > exceptions enabled for your ...

Displaying MailBox in Outlook 2002
I am running Microsoft Outlook 2002, and when I go into tools -> accounts -> view or change current -> change -> more settings -> and click on the advanced tab to add... a mailbox, I type in the correct mailbox name (i.g. ASFAX) and click add. Click OK throughout, and when I get back to my Folder List, I click on the ASFAX and it says "Unable to display the folder. Microsoft Outlook could not access the specified folder location." I know the name of the folder is correct, and it works fine. Other people in my organization can access this mailbox just as d...

icons refresh to much when close folders
When i close my windows exploer or any folder pc keep refreshing icons & slows pc down, i herd there fix for this? using win xp sp3, i have my folder set to list mode so i see the text & windows classic mode not the current xp style. thanks Go here: http://www.kellys-korner-xp.com/xp_tweaks.htm Scroll to Line 157, left side "Prevent automatic icon and folder refresh" It's a registry file...right-click the link and save it to your desktop: http://www.kellys-korner-xp.com/regs_edits/disablerefresh.reg Double-click the "disablerefresh.reg"...

Win XP "Microsoft Outlook Profiles" icon
In my control panel on Windows XP Professional, the Microsoft Outlook Profiles icon is the only one that appears lo-res, all jaggy and unpolished. Is there a way I can upgrade or replace that icon with a better-made one? I'm looked around, but haven't found anything on this topic. Thanks, Freeze ...

[Issue] Template sharing not displaying
I am trying to add security around mailmerge templates and only displaying them to certain users through sharing. I am able to share the templates I add but the interface only allows the users to choose a "Personal" or "Organization" template making the shared templates not display. Through the FilteredMailMergeTemplate view I can see the template, so the sharing is working, but the OOTB UI doesn't display it. Any plans on fixing this issue? Thanks ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the mo...

page cannot be displayed
I am unable to download anything from microsoft.com, i try and get the page cannot be displayed message no matter what i try to download. Thanks for sharing. "cowboysfan" <cowboysfan@discussions.microsoft.com> wrote in message news:D1B511C1-B8C6-4220-9C64-8858A0648935@microsoft.com... >I am unable to download anything from microsoft.com, i try and get the page > cannot be displayed message no matter what i try to download. what anti-virus app is installed and is the subscription still current? cowboysfan wrote: > I am unable to download anything f...

Where is the "Favorite" Icon in Outlook 2003, that I had in Outlo.
I just upgrade my Office 2000, to Office 2003. Although I like many of the new features, I really miss the "Favorites Feature" that I had on my Outlook 2000. Does Outlook 2003 have the same feature, and if so how do I access it. Thanks Warpstar, Favorites has been removed, since Outlook was not meant to be a web browser. Your favorites are still in Internet Explorer. Cheers "Warpstar" <Warpstar@discussions.microsoft.com> wrote in message news:229F04AE-79A5-459C-BBDB-315FD3C0C419@microsoft.com... >I just upgrade my Office 2000, to Office 2003. Althoug...

OWA 2003
I have Exchange 2003 on win2k3 server. If I connect to "http://server/Exchange" all the icons in OWA show up as red x's. If I connect to "http://localhost/Exchange" everything works fine. I've checked the directory permissions on all the folders in c:\exchsrvr\exchweb\* and they are set appropriately. I've also followed the advice I've found in other posts on this list and nothing is working. TIA. -Scott When you look at the properties of the red X normally you can see a path, fully qualified or otherwise, is this a valid path for the browser and do...

Vector PowerPoint OLE Items Display Poorly
I've used PowerPoint slides in my Access databases to display relatively simple vector graphics for quite some time. However, recently, the quality of the graphics has seriously degraded. Specifically, what used to be a smooth line, circle, oval, or whatever, now displays as several jagged steps. It's as if the points used to represent the vector element are being rounded to some nearest value causing a loss of quality in the drawing. The details of what I'm doing is as follows: OS: Windows XP Professional Software: Access 2003 and PowerPoint 2003 Table: Three fields, I...

Small icon on emails
I am a 75 year old recent convert from XP to Win7 and WLM and have had very little problems. The only thing that I would like to find out about is.... When I receive an email there is always an icon of a little person in the left hand corner. Can I get rid of this? Can I change it? Or What??? Thanks you in anticipation. The little person is because you are signed in to Live Services. You do not have to sign in to receive email. Signing in syncs your Calendar and Contacts with the online Calendar and Contacts. Alt + T, Options, Connection, Stop signing in. -- Ron Somm...

Error bars won't display with named formula/range data
Hi all, I have a bit of a problem with Y error bars on a line chart. I'm tying to add custom error bars using a named formula but no error bars are displayed. If i use an array formula to display the values on a worksheet and select this range as the custom error bar then all is displayed fine. Also, if i use the named formula as a new series then all plots ok. The named formula is: =IssueCluster!DGH_Comparison-IssueCluster!DGH_Current It calculates the difference between the values in 2 cell ranges. Is this happening because the named formula is not evaluating itself? If so, is the...

Win7 and Excel07
When I open an Excel 2007 sheet from Pinned or Recent Items, rather than appearing in permanent Excel 2007 icon in Taskbar, it appears in a NEW/TEMPORARY Excel 2007 Icon. Any ideas to fix ? Thanks tomhass ...

Formula to display Count of Days in given month, using list of Start and End Dates
I have a large number of rows that contain a start date and end date. I am attempting to generate a count of days within that date range that are in a particular month, for example, Jan of 2011. Any suggestions for a formula that could be used to display the amounts shown in Column C would be helpful. Layout is: A B C Start Date End Date Count of Days in Jan2011 1/10/11 4/7/11 21 2/6/11 3/1/11 0 12/20/10 2/15/11 31 Etc. Dave, I think the best way is to create a table f...

How to remove standard desktop icons in Win CE 5.0
Hi, I am trying to delete standard desktop icons in Win CE 5.0, such as Recycle Bin, My Device, Media Player and Internet Explorer. I wrote an application which runs at boot-up time. In that application, I added the following statements to delete the registry keys for desktop icons. But it did not work. RegDeleteKey( HKEY_LOCAL_MACHINE, TEXT("Explorer\\Desktop\\{000214A0-0000-0000-C000-000000000046}") ); RegDeleteKey( HKEY_LOCAL_MACHINE, TEXT("Explorer\\Desktop\\{000214A1-0000-0000-C000-000000000046}") ); Any one knows how, please help. Thanks. JH ...

Contributor level icons
Why do contributor level icons show up in some Access newsgroups, but not in others? Do they only apply to selected newsgroups within Access, or to the Access Newsgroup as a whole? -- Email address is not valid. Please reply to newsgroup only. On Tue, 6 Nov 2007 08:22:01 -0800, Dale Fye <dale.fye@nospam.com> wrote: >Why do contributor level icons show up in some Access newsgroups, but not in >others? Do they only apply to selected newsgroups within Access, or to the >Access Newsgroup as a whole? The icons are not part of the newsgroups at all. They are an additional ...

Replied icon does not appear on relied to emails
After I click Reply to reply to a received email the envelope icon does not change to a Replied To icon with the grey left pointing arrow icon. Glancing at my Inbox I therefore cannot tell if I have replied or not. Also the info bar does not indicate that a reply has been sent. I am using Outlook 2003. How can I correct this? Thanks for any help. Did you ever get a response/resolution for this? We are having the same problem and I have been unable to get it resolved. Thanks, Pam "David Rhys Davies" wrote: > After I click Reply to reply to a received email the envelope ic...

How do I sum the displayed values in a stacked chart?
Hi Everyone, I've set up a stacked column chart. In each colum I have stacked up two values. I'm trying to figure out if I can show the summed value of the two values in the chart, and still maintain the automated updates if I change any of my data. Right now, the only way I know how to do this tpying the summed value in. The problem I'm having is that I lose the ability to have the values automatically updates if I do that. Is there any solution to this? Thank you very much for your help. Hi, Explanation here, http://www.andypope.info/charts/StackColTotal.htm Chee...