?
Solved

Create a Popup List with Icons

Posted on 2003-03-10
23
Medium Priority
?
295 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:JohnMcCann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 10
  • +1
23 Comments
 
LVL 10

Expert Comment

by:aeklund
ID: 8105936
If I undertand you correctly, your want a popup menu with images?

http://www.vbaccelerator.com/codelib/cpopmenu/article.htm
0
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8106009
No that is no good. Thankyou anyway.

I am interested in using the functionality of the listbox.

0
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8119963
A request has been posted to community support to delete this question.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8123861
PAQ'd and points refunded.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8212334
did you try with a listview control instead?
0
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8217313
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8246950
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
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8248505
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8248701
AFAIK, LBS_USEICON is for Unix as you already suspect.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8262982
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
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8263559
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8269702
"... 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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8269707
or we are talking to some similar to VB Editor/Intellisense list (that what you see when push a dot...)
0
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8273399
We are talking about an 'ImageCombo' style control.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8275557
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
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8275654
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8275785
Spreasheet is harder than this. I think it will be more more difficult to get.
0
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8277741
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8278679
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
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8278755
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8283948
i am not familiar with ChartSpace object, sorry.
Mschart would be enought, it depends on requirements and how flexible he control is.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8284127
Since it appears that you know enought C, check this:
http://63.236.18.13/controls/index.shtml under "Charting and analogue controls"
0
 
LVL 5

Author Comment

by:JohnMcCann
ID: 8320382
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question