4 * Copyright 2006 CodeWeavers, Aric Stewart
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
37 #include "gphoto2_i.h"
38 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(twain);
43 static HBITMAP static_bitmap;
45 static INT_PTR CALLBACK ConnectingProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
50 static void PopulateListView(HWND List)
52 struct gphoto2_file *file;
56 LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
58 if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
60 memset(&item,0,sizeof(item));
61 item.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE ;
63 item.pszText = file->filename;
65 item.lParam= (LPARAM)file;
67 SendMessageA(List, LVM_INSERTITEMA,0,(LPARAM)&item);
73 static void PopulateImageList(HIMAGELIST *iList, HWND list)
75 struct gphoto2_file *file;
80 CreateDialogW(GPHOTO2_instance,(LPWSTR)MAKEINTRESOURCE(IDD_CONNECTING),
81 NULL, ConnectingProc);
83 LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
85 if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
91 _get_gphoto2_file_as_DIB(file->folder, file->filename,
92 GP_FILE_TYPE_PREVIEW, 0, &bitmap);
96 GetObjectA(bitmap,sizeof(BITMAP),(LPVOID)&bmpInfo);
100 *iList = ImageList_Create(bmpInfo.bmWidth,
101 bmpInfo.bmHeight,ILC_COLOR24, 10,10);
103 SendMessageW(list, LVM_SETICONSPACING, 0,
104 MAKELONG(bmpInfo.bmWidth+6, bmpInfo.bmHeight+15) ); }
106 rc = ImageList_Add(*iList, bitmap, 0);
108 DeleteObject(static_bitmap);
109 static_bitmap = bitmap;
110 SendMessageW(GetDlgItem(progress_dialog,IDC_BITMAP),STM_SETIMAGE,
111 IMAGE_BITMAP, (LPARAM)static_bitmap);
112 RedrawWindow(progress_dialog,NULL,NULL,RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
115 EndDialog(progress_dialog,0);
119 static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
125 HIMAGELIST ilist = 0;
126 HWND list = GetDlgItem(hwnd,IDC_LIST1);
127 EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
129 PopulateImageList(&ilist,list);
131 SendMessageA(list, LVM_SETIMAGELIST,LVSIL_NORMAL,(LPARAM)ilist);
132 PopulateListView(list);
136 if (((LPNMHDR)lParam)->code == LVN_ITEMCHANGED)
138 HWND list = GetDlgItem(hwnd,IDC_LIST1);
139 int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
141 EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),TRUE);
143 EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
147 switch LOWORD(wParam)
154 HWND list = GetDlgItem(hwnd,IDC_LIST1);
155 int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
164 count = SendMessageA(list,LVM_GETITEMCOUNT,0,0);
165 for ( i = 0; i < count; i++)
167 INT state = 0x00000000;
169 state = SendMessageA(list,LVM_GETITEMSTATE,i,
175 struct gphoto2_file *file;
177 memset(&item,0,sizeof(item));
179 item.mask = LVIF_PARAM;
182 SendMessageA(list,LVM_GETITEMA,0,(LPARAM)&item);
184 file = (struct gphoto2_file*)item.lParam;
185 file->download = TRUE;
194 HWND list = GetDlgItem(hwnd,IDC_LIST1);
195 int count = SendMessageA(list,LVM_GETITEMCOUNT,0,0);
204 for ( i = 0; i < count; i++)
207 struct gphoto2_file *file;
209 memset(&item,0,sizeof(item));
211 item.mask = LVIF_PARAM;
214 SendMessageA(list,LVM_GETITEMA,0,(LPARAM)&item);
216 file = (struct gphoto2_file*)item.lParam;
217 file->download = TRUE;
231 return DialogBoxW(GPHOTO2_instance,
232 (LPWSTR)MAKEINTRESOURCE(IDD_CAMERAUI),NULL, DialogProc);
235 static INT_PTR CALLBACK ProgressProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
241 HWND TransferringDialogBox(HWND dialog, DWORD progress)
244 dialog = CreateDialogW(GPHOTO2_instance,
245 (LPWSTR)MAKEINTRESOURCE(IDD_DIALOG1), NULL, ProgressProc);
253 RedrawWindow(dialog,NULL,NULL,
254 RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);