I have splitted my Application window into two using createWindowEx().Now i have two windows...In my First window I need to display images as list of thumbnails,In another window i need to view the image as user selects the particular thumbnail from the first window.
My Question is How to display multiple images in a single window as thumbnails.
How to do this using only Win32API and c++.
You Have both given me Good idea about how to do this..
Can You also Explain me about the Following Questions:
Things I want to get clear:These Question may be silly but i need to get clear to proceed in my work since i am newbie in Win32api.
For Win32API I usually refer through the book "Programming Windows" by Charles Petzold.
But i couldnot find any information regarding about ListView control and Static Control so i have doubt whether it is Contained in win32api,because i should not use MFC concepts.
Q) Whether ListView Control and Static Control is contained in Win32API(i.e Whether it is Pure Win32api) because i am working in my project using win32api and c++.
Q)What is Resource Script Files(i.e resource.h and .rc files) whether we need to create and make use of resource files in order to use ListView Control and Static Control to create images and Displaying it in thumbnail window.this question i asked because this thumbnail window is like one of the user interface controls.
Q) What is ComCtl32.dll and what is its use.
Answers to these questions could Help me to Proceed.
Thanks
I guess Mr. Petzold didn't feel the need to cover them all in his book.
2) The rc file basically describe the resources you want embedded in your EXE or DLL. Resources are things like bitmaps, icons, cursors, strings, and menus. You would use bitmap or icon resources for toolbar buttons and menu item images, for example.
You probably don't want to use resources in your case since I assume you want to display any images on disk and not just a specific set of images.
Resources are essential in large applications so you probably want to learn more about them at some point. This might be a good starting place:
Thanks knn9.You have given me clear explanation.
can you also explain me the following Questions
Q)
Is it possible to create ListView control and Static control for displaying List of Images in Thumbnail Window and Viewing it in Viewer Window without using Resource Script Files.
I have this doubt because Both ListView control and Static control uses WM_COMMAND message.
I ask this Question because Images are going to be selected by user(as this can be one of the UserInterface)
Is it Possible to get mouse events and scroll events in Static control.Because Static Control does not Process WM_MOUSEMOVE and WM_MOUSEWHEEL.
I need to use mouse events in the Viewer Window.
I have followed the Steps that you have suggested here:
one more doubt I have is:
do we need to have Listview control window for creating a ImageList control in it or can I use a normal window using CreateWindowEx without specifying WC_LISTVIEW?
1)I created ListView Window using CreateWindowEx(specifying WC_LISTVIEW)
2)For creating ImageList i Used ImageList_Create()
3)For Adding Images i used ImageList_Add()
4)For Drawing Images in it i used ImageList_Draw()
so everything works fine i could draw images one by one..
i have posted sample Image(Window that i have created)in the below link for your reference http://s27.postimg.org/o08rlhg1v/Thumbnail.jpg
Now i need to apply some styles that will make ImageList looks like Adobe Reader Thumbnails,I should also highlight the selected image from the list.(i.e Like Adobe Reader Thumbnails exactly).
Please Suggest me how to achieve this.
do we need to have Listview control window for creating a ImageList control in it or can I use a normal window using CreateWindowEx without specifying WC_LISTVIEW?
I don't really understand this question :/
I think you're asking whether you need the listview control at all. If so, then no. Of course you can tile images with static controls or directly on the window with a backbuffer or whatever.
Now i need to apply some styles that will make ImageList looks like Adobe Reader Thumbnails,I should also highlight the selected image from the list.(i.e Like Adobe Reader Thumbnails exactly).
Not sure what adobe looks like but the list-view control already shows a selection box around the selected item. Is there something wrong with that?
I have created Listview control window and successfully created Thumbnail Images using Imagelists control.
Now I need to get the Index of the selected image from the Imagelist control so that we can draw the selected image in Bigger size static window control.
Note:I could get WM_NOTIFY and NM_CLICK message from this control, but after this step I dont have any idea on how to get the index of the selected image from the Imagelist control.
Scenario:
Listview control is the window it contains listview item and iimages are created using Imagelist that have been placed Listview control(i.e subitems contain images)
But LVM_GETITEM gets the item index but the Imagelists are placed inside Listview item this means i need to get the subitem index of the item(i.e the image placed in listview item)
my code is :
case WM_NOTIFY :
{
switch(LOWORD(wParam))
{
case IDC_LIST:
I dont know where my code is wrong.please correct me
Please help me to get the index of the subitem(i.e image contained in item)
i.e to get the Index of the current selected image from the Listview control
On selecting the thumbnails i need to display the corresponding image in viewer window you can refer the above link how will my window look like this my requirement
According to the documentation for the LVITEM structure:
iImage
Type: int
Index of the item's icon in the control's image list. This applies to both the large and small image list. If this member is the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the list-view control sends the parent an LVN_GETDISPINFO notification code to retrieve the index when it needs to display the image.
So, you have to store the image index yourself and provide it when requested via LVN_GETDISPINFO.
how to get the image index for the current selected image created using Imagelist which is placed in ListView control the using LVITEM structure member iImage
1. I have a function called "populate_thumb_nails" which will create thumbnail images using ListView and ImageList control using below code.
2. There is no issues if I call this function from WM_Create in Windows 8 but in XP machine it's not creating thumbnails (Blank white background appearing).
3. To solve this I tried to call "populate_thumb_nails" function from WM_Paint in XP... its seems like working but thumbnails redrawing recursively.
4. Pls clarify my below doubts and suggest
1. Whether shoud I call this "populate_thumb_nails" function only once in WM_Create or should I call also in WM_Paint?
2. I have added two images in ImageList using "ImageList_Add() function but only one image has drawn instead of two.
if I did any mistake in code pls point it out.
//This will create thumb window and register the win proc for that window.
CreateWindowEx(WS_EX_WINDOWEDGE, className.c_str(), winName.c_str(),
WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL,
0, 0, (int)thumbnailWndSize.iWidth,
(int)thumbnailWndSize.iHeight, hParentWnd, NULL, hInstance, NULL ); //successfully created
//this is the corresponding window proc
LRESULT CALLBACK wnd_proc_thumbnail(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_CREATE :
{
return populate_thumb_nails(hWnd); //this function will create thumbnails using ListView and ImageList controls
}
case WM_PAINT:
{
return populate_thumb_nails(hWnd); //to solve xp issue denoted in point 2. is this preferred solution?
}
case WM_NOTIFY :
{
return 0;
}
default:
{
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
}