Create a Popup List with Icons

I would like to create a popup list window that has icons, text and the list items are of a certain height 26 pixels.  I would like the popup list to appear flat similar to a standard combo popup list.

I have tried using CreateWindowEx with LBS_USEICON and cannot seem to get this to work without drawing the item myself.

I use

nItem = SendMessage(m_hWndPopUp, LB_ADDSTRING, 0, "Some Text")
SendMessage m_hWndPopUp, LB_SETITEMDATA, nItem, SomePicture.Handle

to set the itemdata.

I have also found that I cannot trap the WM_MEASUREITEM and WM_DRAWITEM of the popup list unless I create a popup window and place it on that.

Can anyone supply me with CreateWindowEx code to create the window and verify I am ading the data correcctly and possibly explain why I am having problems with the MEASUREITEM and DRAWITEM events.

Or alternatively point me to a site with a good VB Example of LBS_USEICON

Thanks in advance for any help given
LVL 5
JohnMcCannAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SpideyModConnect With a Mentor Commented:
PAQ'd and points refunded.
0
 
aeklundCommented:
If I undertand you correctly, your want a popup menu with images?

http://www.vbaccelerator.com/codelib/cpopmenu/article.htm
0
 
JohnMcCannAuthor Commented:
No that is no good. Thankyou anyway.

I am interested in using the functionality of the listbox.

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
JohnMcCannAuthor Commented:
A request has been posted to community support to delete this question.
0
 
Richie_SimonettiIT OperationsCommented:
did you try with a listview control instead?
0
 
JohnMcCannAuthor Commented:
Richie_Simonetti,
Thanks for your response, I have coded the popup list but came across the argument LBS_USEICON and had thought this may enable me to reduce the code required.  It turns out LBS_USEICON is for unix.  I had considered using the listview but felt  the listbox matched my requirements better and is more likely yto wok on all taarget platforms.


Thankyou again


John McCann
0
 
Richie_SimonettiIT OperationsCommented:
Maybe i am wrong but i think thi is what you were looking for:

http://www.vbaccelerator.com/home/VB/Code/Controls/Combo_and_List_Boxes/index.asp
0
 
JohnMcCannAuthor Commented:
Richie_Simonetti,

Thanks again for your time.
I have already looked at VBAccelerator Combo and Listboxes.
I have also already code the rock I needed and have currently moved on.

I am curious of one thing though assuming we are coding an owner drawn combo with a popup list (Not the standard combo).

I would have like to create a popup list that can have Icons/Pictures in one colummn and text in the second.  With the text being displayed wrapped  Not all of the combos I needed to create had text wrapped.  I had hoped I can just create the list as follows.  

CreateWindowEx(dwExStyle, WC_LIST_BOX, "", dwStyle, nLeft,, nTop, nWidth, nHeight, hWndParent, 0, App.hInstance, lpParam)

Appending LBS_USEICON to my dwStyle param.  I couldn't get this to work.  I also has quite serious problems with LBS_OWNERDRAWVARIABLE and the corresponding WM_MEASUREITEM.

How would you code the CreateWindowEx function and would you use a static form to display it on?

Basic Requirements
1) Minimal code (e.g. with LBS_USEICON which I think is for unix)
2) To appear like a standard combobox list portion.
3) To have one column icon and one text.

If you give me anything better than I've got I'll quite happly give you 500 points and a grade of A.  I'll even make it 1000 if your code contains LBS_USEICON and works on windows.

Regards


John McCann
0
 
Richie_SimonettiIT OperationsCommented:
AFAIK, LBS_USEICON is for Unix as you already suspect.
0
 
Richie_SimonettiIT OperationsCommented:
just a q: Why do you need LBS_USEICON?, if it is a flag used in Unix, we cannot use in Windows.
Let me clarify something: You need a popup list with one icon and one text when the user selects an item from the drop down and that list should be populated according to what user selected?
0
 
JohnMcCannAuthor Commented:
These Usercontrol(s) contain static information.  The List is populated only once during creation.  These controls are shared across numerous applications.  A good example (But no quite what I am after) would be a color picker thats was Multi lingual eg. If your PC is in english it would say red or french rouge.  The list portion must be able to display wrapped text and the edit portion a variety of heights.

Thankyou again for your time
0
 
Richie_SimonettiIT OperationsCommented:
"... the edit portion a variety of heights..."
Sorry, we are talking of the same "List" object?
List boxes hasn't edit portion, combobox has it.
0
 
Richie_SimonettiIT OperationsCommented:
or we are talking to some similar to VB Editor/Intellisense list (that what you see when push a dot...)
0
 
JohnMcCannAuthor Commented:
We are talking about an 'ImageCombo' style control.
0
 
Richie_SimonettiIT OperationsCommented:
Well, vaccelerator has some like that, did you see it?.
Anyway, this is the closest i could found:
http://www.vbbox.com/code/ownlist.zip
Also take a look http://www.vbbox.com/codebox.htm where you could find some exelent examples.
Also, check this http://www.mvps.org/vbvision/_samples/PopUp_Listbox_Demo.zip
http://www.mvps.org/vbvision/_samples/Virtual_Listbox_Demo.zip
(from http://www.mvps.org/vbvision/grouped_demos.htm#Listbox_&_Combobox) which has popup list box.
I think that concatenating several parts of those resources, we could get what you need.
0
 
JohnMcCannAuthor Commented:
Thankyou,

Just glancing I have looked at most of those examples and they are defiinatly the better ones.  I hav developed the controls as you said "I think that concatenating several parts of those resources, we could get what you need."

I am very grateful for your time and have posted some points for you here.  I have not looked at all of the examples yet but will later.  I don't suppose you've had any thoughts on the spreadsheet example.

Also my emails JohnMcCann_UK@Hotmail.com

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20575441.html
0
 
Richie_SimonettiIT OperationsCommented:
Spreasheet is harder than this. I think it will be more more difficult to get.
0
 
JohnMcCannAuthor Commented:
I have downloaded

http://www.vbbox.com/code/ownlist.zip

This example is spot on.

1) I modified it to use Owner draw variable and it worked first time.
2) I have modified my CreateWindowEx function to mimic it and it worked.

I have increased the points for you to 500

Thanks again

I have also looked at some of the examples and this code will DEFINATLY come in handy for developing other parts of the applications.
0
 
Richie_SimonettiIT OperationsCommented:
Know what?, to me the vbaccelerator example was the way to go. I have been playing with both examples and vbacc is the most similar to a plain CB with images or LB by the way.
Glad to see that something of my comment was useful.
Cheers
(i am still digging with spreadsheet but the c code is for 16bits so i have to modify for VC++ 6 before get any useful. I did try translating it to VB but my C is not so good.
Cheers
0
 
JohnMcCannAuthor Commented:
I agree some of the other examples are much better.

But

I can do all the stlying of the listbox myself that is not a problem.  

My problem is

a) being lazly, though I just found a very simple way of creating listboxes (LBS_USEICON)

b) I had problems with LBS_OWNERDRAWVARIABLE (for wrapped text).  All of the examples I have played with fall over on LBS_OWNERDRAWVARIABLE (ish, they dont crash).  And I struggle to catch the WM_MEASUREITEM.  

I am not sure what was wrong with my code or the 100's of combination I did try.  But that code seems to have it.

I orignaly had a listBox on the UserControl that had its style set to Checkboxes so that I could catch the DrawItem.  This Listbox would then be placed on a popup form.

I even moved the code from the vbBox example straight into a usercontol added some limited style propertys and it worked (I now have an Owner Drawn ListBox) this I also could not get working before.

Thankyuu again (I find myself saying that alot).


I have another problem that will appear soon what are my chart options? eg. controls not propertys.

I initaly used the ChartSpace object from Microsoft (Office Web Components).  This dependancy must be removed.  I am probably going to use MSChart but I am not sure if there is anything better.  I would consider Owner Drawn and have an example somewhere that uses a PictureBox
0
 
Richie_SimonettiIT OperationsCommented:
i am not familiar with ChartSpace object, sorry.
Mschart would be enought, it depends on requirements and how flexible he control is.
0
 
Richie_SimonettiIT OperationsCommented:
Since it appears that you know enought C, check this:
http://63.236.18.13/controls/index.shtml under "Charting and analogue controls"
0
 
JohnMcCannAuthor Commented:
Thankyou again Richie_Simonetti.

I have posted some points for you here

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20575441.html
0
All Courses

From novice to tech pro — start learning today.