NO

Author Topic: How to do a list of scrollable image buttons ?  (Read 5297 times)

Seltsamuel

  • Guest
How to do a list of scrollable image buttons ?
« on: July 20, 2009, 12:16:36 PM »
Hi,

im a little bit lost, windows programming is not really my deal and i think this one is a little more complicated:

I have a dialog and inside this dialog i wanna have a stripe of about 100 pixels in the middle of the dialog where i can have
a list of image buttons. When there are more buttons than fitting on the window i want to have it scrollable. The buttonlist must be dynamic created (its type of a program launcher presenting found programs as clickable images).

How can i do this beast with PellesC ??
I already worked with Dialogs and checkboxes multiselectboxes .. .. but listviews give me headache as they seem not to have the functionality i need. Did i look into the wrong direction?
Right and left of the imagebuttonlist are checkboxes and a background graphic for options. The single images are about 30*100 Pixels
and are webbanner style

Any suggestions?

Greetings

Seltsamuel

JohnF

  • Guest
Re: How to do a list of scrollable image buttons ?
« Reply #1 on: July 20, 2009, 06:12:17 PM »
I've not done it myself but maybe you should look at controls that have an xxx_OWNERDRAW flag. Maybe even a listbox.

John

JohnF

  • Guest
Re: How to do a list of scrollable image buttons ?
« Reply #2 on: July 23, 2009, 03:13:42 PM »
Here is a project that does what you want. It's C++ but you might be able to translate it to C.

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

Although I expect the easiest way would be to use a listview with an image list.

After you have made the image list, pass it to the listview which sizes the rows and displays the images.

This is what I've used on a ComboBox just to give you an idea.

Code: [Select]
HIMAGELIST hSmallC = ImageList_Create(16, 16, ILC_COLOR8 | TRUE, 7, 0);

for(int i=10; i<19; i++)
{
ImageList_AddIcon(hSmallC, LoadIcon(g_hInst, MAKEINTRESOURCE(i)));
}
SndMsg(hwndCombo, CBEM_SETIMAGELIST, 0, (LPARAM)hSmallC);

The above adds icons but you can also use bitmaps.

John

« Last Edit: July 23, 2009, 03:34:21 PM by JohnF »

Seltsamuel

  • Guest
Re: How to do a list of scrollable image buttons ?
« Reply #3 on: July 25, 2009, 04:14:07 PM »
Hi,

many thanks i will give it a try :-)
i assume i can capture the click events as "Button" clicks ?

I will report here how it goes

Greetings

Seltsamuel

JohnF

  • Guest
Re: How to do a list of scrollable image buttons ?
« Reply #4 on: July 25, 2009, 04:32:39 PM »
Hi,

many thanks i will give it a try :-)
i assume i can capture the click events as "Button" clicks ?

I will report here how it goes

Greetings

Seltsamuel

No. You will need to react to WM_NOTIFY and then LVN_ITEMCHANGED which is gained with

Code: [Select]
int OnNotify(HWND hwnd, LPARAM lParam)
{
LPNM_LISTVIEW lpnmlv;
lpnmlv = (LPNM_LISTVIEW) lParam;
int idx;

switch(lpnmlv->hdr.code)
{
         case LVN_ITEMCHANGED:


John

CProgrammer

  • Guest
Re: How to do a list of scrollable image buttons ?
« Reply #5 on: August 16, 2009, 10:05:05 PM »
I am attaching a zip file that contains annotated code that demonstrates how to set up bitmaps in a list box using Pelles C version 6. The attached zip file also includes a PDF document that outlines how to do this. The codecould be shortened in places, but I have left in in an 'extended' state to make it easier to understand.

Enjoy!

Seltsamuel

  • Guest
Re: How to do a list of scrollable image buttons ?
« Reply #6 on: August 17, 2009, 01:06:17 PM »
Hi,

many thanks i will look into this :-)

EDIT:
I recognized that on minimizing the Window there is no Scrollbar inside the Listbox.
Inside The Formdesigner i see vertical scrolling is active so why no bar appears?

The PDF is missing too, i assume because of the small allowed size for attachments here :-)

Greetings

Seltsamuel
« Last Edit: August 17, 2009, 01:20:42 PM by Seltsamuel »

CProgrammer

  • Guest
Re: How to do a list of scrollable image buttons ?
« Reply #7 on: August 17, 2009, 06:40:04 PM »
Hi,

I have attached the PDF file to this reply.

The scroll bars appear automatically when the list box holds more items than can be seen on the screen. To show this, use the resource editor to reduce the height of the list box so that it is the height of about two of the exemplar bitmaps. Recompile the program. You should find that the scroll bars appear automatically as the list box is too small to show all the bitmaps at the same time.

Seltsamuel

  • Guest
Re: How to do a list of scrollable image buttons ?
« Reply #8 on: August 17, 2009, 10:23:26 PM »
Hi,

ah, many thanks for your replys and help.

As i understand the box itself not resizes (when i make the window smaller) but when content tries to expand it will give Scrollbars.
The window minimize is nothing i have to deal with in my case but i always try to understand things i use.

Greetings

Seltsamuel