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 static HBITMAP static_bitmap
;
43 static INT_PTR CALLBACK
ConnectingProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
48 static void PopulateListView(HWND List
)
50 struct gphoto2_file
*file
;
54 LIST_FOR_EACH_ENTRY( file
, &activeDS
.files
, struct gphoto2_file
, entry
)
56 if (strstr(file
->filename
,".JPG") || strstr(file
->filename
,".jpg"))
58 item
.mask
= LVIF_PARAM
| LVIF_TEXT
| LVIF_IMAGE
;
61 item
.pszText
= file
->filename
;
63 item
.lParam
= (LPARAM
)file
;
65 SendMessageA(List
, LVM_INSERTITEMA
,0,(LPARAM
)&item
);
71 static void PopulateImageList(HIMAGELIST
*iList
, HWND list
)
73 struct gphoto2_file
*file
;
78 CreateDialogW(GPHOTO2_instance
,(LPWSTR
)MAKEINTRESOURCE(IDD_CONNECTING
),
79 NULL
, ConnectingProc
);
81 LIST_FOR_EACH_ENTRY( file
, &activeDS
.files
, struct gphoto2_file
, entry
)
83 if (strstr(file
->filename
,".JPG") || strstr(file
->filename
,".jpg"))
89 _get_gphoto2_file_as_DIB(file
->folder
, file
->filename
,
90 GP_FILE_TYPE_PREVIEW
, 0, &bitmap
);
94 GetObjectA(bitmap
,sizeof(BITMAP
),(LPVOID
)&bmpInfo
);
98 *iList
= ImageList_Create(bmpInfo
.bmWidth
,
99 bmpInfo
.bmHeight
,ILC_COLOR24
, 10,10);
101 SendMessageW(list
, LVM_SETICONSPACING
, 0,
102 MAKELONG(bmpInfo
.bmWidth
+6, bmpInfo
.bmHeight
+15) ); }
104 rc
= ImageList_Add(*iList
, bitmap
, 0);
106 DeleteObject(static_bitmap
);
107 static_bitmap
= bitmap
;
108 SendMessageW(GetDlgItem(progress_dialog
,IDC_BITMAP
),STM_SETIMAGE
,
109 IMAGE_BITMAP
, (LPARAM
)static_bitmap
);
110 RedrawWindow(progress_dialog
,NULL
,NULL
,RDW_INTERNALPAINT
|RDW_UPDATENOW
|RDW_ALLCHILDREN
);
113 EndDialog(progress_dialog
,0);
117 static INT_PTR CALLBACK
DialogProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
123 HIMAGELIST ilist
= 0;
124 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
125 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),FALSE
);
127 PopulateImageList(&ilist
,list
);
129 SendMessageA(list
, LVM_SETIMAGELIST
,LVSIL_NORMAL
,(LPARAM
)ilist
);
130 PopulateListView(list
);
134 if (((LPNMHDR
)lParam
)->code
== LVN_ITEMCHANGED
)
136 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
137 int count
= SendMessageA(list
,LVM_GETSELECTEDCOUNT
,0,0);
139 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),TRUE
);
141 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),FALSE
);
145 switch LOWORD(wParam
)
152 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
153 int count
= SendMessageA(list
,LVM_GETSELECTEDCOUNT
,0,0);
162 count
= SendMessageA(list
,LVM_GETITEMCOUNT
,0,0);
163 for ( i
= 0; i
< count
; i
++)
165 INT state
= 0x00000000;
167 state
= SendMessageA(list
,LVM_GETITEMSTATE
,i
,
173 struct gphoto2_file
*file
;
176 item
.mask
= LVIF_PARAM
;
180 SendMessageA(list
,LVM_GETITEMA
,0,(LPARAM
)&item
);
182 file
= (struct gphoto2_file
*)item
.lParam
;
183 file
->download
= TRUE
;
192 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
193 int count
= SendMessageA(list
,LVM_GETITEMCOUNT
,0,0);
202 for ( i
= 0; i
< count
; i
++)
205 struct gphoto2_file
*file
;
208 item
.mask
= LVIF_PARAM
;
212 SendMessageA(list
,LVM_GETITEMA
,0,(LPARAM
)&item
);
214 file
= (struct gphoto2_file
*)item
.lParam
;
215 file
->download
= TRUE
;
227 BOOL
DoCameraUI(void)
229 return DialogBoxW(GPHOTO2_instance
,
230 (LPWSTR
)MAKEINTRESOURCE(IDD_CAMERAUI
),NULL
, DialogProc
);
233 static INT_PTR CALLBACK
ProgressProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM
239 HWND
TransferringDialogBox(HWND dialog
, DWORD progress
)
242 dialog
= CreateDialogW(GPHOTO2_instance
,
243 (LPWSTR
)MAKEINTRESOURCE(IDD_DIALOG1
), NULL
, ProgressProc
);
251 RedrawWindow(dialog
,NULL
,NULL
,
252 RDW_INTERNALPAINT
|RDW_UPDATENOW
|RDW_ALLCHILDREN
);