4 * Copyright 2000, 2003, 2004, 2005 Martin Fuchs
5 * Copyright 2006 Jason Green
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/port.h"
26 /* for unix filesystem function calls */
28 #include <sys/types.h>
43 #define _MAX_FNAME 256
44 #define _MAX_DIR _MAX_FNAME
45 #define _MAX_EXT _MAX_FNAME
49 #ifdef NONAMELESSUNION
50 #define UNION_MEMBER(x) DUMMYUNIONNAME.x
52 #define UNION_MEMBER(x) x
57 #define DEFAULT_SPLIT_POS 300
59 #define DEFAULT_SPLIT_POS 200
62 static const WCHAR registry_key
[] = { 'S','o','f','t','w','a','r','e','\\',
64 'W','i','n','e','F','i','l','e','\0'};
65 static const WCHAR reg_start_x
[] = { 's','t','a','r','t','X','\0'};
66 static const WCHAR reg_start_y
[] = { 's','t','a','r','t','Y','\0'};
67 static const WCHAR reg_width
[] = { 'w','i','d','t','h','\0'};
68 static const WCHAR reg_height
[] = { 'h','e','i','g','h','t','\0'};
69 static const WCHAR reg_logfont
[] = { 'l','o','g','f','o','n','t','\0'};
79 typedef struct _Entry
{
90 #ifndef _NO_EXTENSIONS
91 BY_HANDLE_FILE_INFORMATION bhfi
;
93 enum ENTRY_TYPE etype
;
104 TCHAR path
[MAX_PATH
];
105 TCHAR volname
[_MAX_FNAME
];
115 COL_ATTRIBUTES
= 0x08,
117 #ifdef _NO_EXTENSIONS
118 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
122 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
|COL_INDEX
|COL_LINKS
135 #ifndef _NO_EXTENSIONS
139 #ifndef _NO_EXTENSIONS
145 int positions
[COLUMNS
+1];
157 int focus_pane
; /* 0: left 1: right */
160 BOOL header_wdths_ok
;
162 TCHAR path
[MAX_PATH
];
163 TCHAR filter_pattern
[MAX_PATH
];
167 SORT_ORDER sortOrder
;
172 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
);
173 static void set_curdir(ChildWnd
* child
, Entry
* entry
, int idx
, HWND hwnd
);
174 static void refresh_child(ChildWnd
* child
);
175 static void refresh_drives(void);
176 static void get_path(Entry
* dir
, PTSTR path
);
177 static void format_date(const FILETIME
* ft
, TCHAR
* buffer
, int visible_cols
);
179 static LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
180 static LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
181 static LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
185 WINEFILE_GLOBALS Globals
;
187 static int last_split
;
189 /* some common string constants */
190 static const TCHAR sEmpty
[] = {'\0'};
191 static const WCHAR sSpace
[] = {' ', '\0'};
192 static const TCHAR sNumFmt
[] = {'%','d','\0'};
193 static const TCHAR sQMarks
[] = {'?','?','?','\0'};
195 /* window class names */
196 static const TCHAR sWINEFILEFRAME
[] = {'W','F','S','_','F','r','a','m','e','\0'};
197 static const TCHAR sWINEFILETREE
[] = {'W','F','S','_','T','r','e','e','\0'};
200 /* #define LONGLONGARG _T("I64") */
201 static const TCHAR sLongHexFmt
[] = {'%','I','6','4','X','\0'};
202 static const TCHAR sLongNumFmt
[] = {'%','I','6','4','d','\0'};
204 /* #define LONGLONGARG _T("L") */
205 static const TCHAR sLongHexFmt
[] = {'%','L','X','\0'};
206 static const TCHAR sLongNumFmt
[] = {'%','L','d','\0'};
210 /* load resource string */
211 static LPTSTR
load_string(LPTSTR buffer
, UINT id
)
213 LoadString(Globals
.hInstance
, id
, buffer
, BUFFER_LEN
);
218 #define RS(b, i) load_string(b, i)
221 /* display error message for the specified WIN32 error code */
222 static void display_error(HWND hwnd
, DWORD error
)
224 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
227 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_FROM_SYSTEM
,
228 0, error
, MAKELANGID(LANG_NEUTRAL
,SUBLANG_DEFAULT
), (PTSTR
)&msg
, 0, NULL
))
229 MessageBox(hwnd
, msg
, RS(b2
,IDS_WINEFILE
), MB_OK
);
231 MessageBox(hwnd
, RS(b1
,IDS_ERROR
), RS(b2
,IDS_WINEFILE
), MB_OK
);
237 /* display network error message using WNetGetLastError() */
238 static void display_network_error(HWND hwnd
)
240 TCHAR msg
[BUFFER_LEN
], provider
[BUFFER_LEN
], b2
[BUFFER_LEN
];
243 if (WNetGetLastError(&error
, msg
, BUFFER_LEN
, provider
, BUFFER_LEN
) == NO_ERROR
)
244 MessageBox(hwnd
, msg
, RS(b2
,IDS_WINEFILE
), MB_OK
);
247 static VOID
WineLicense(HWND Wnd
)
249 WCHAR cap
[20], text
[1024];
250 LoadStringW(Globals
.hInstance
, IDS_LICENSE
, text
, 1024);
251 LoadStringW(Globals
.hInstance
, IDS_LICENSE_CAPTION
, cap
, 20);
252 MessageBoxW(Wnd
, text
, cap
, MB_ICONINFORMATION
| MB_OK
);
255 static VOID
WineWarranty(HWND Wnd
)
257 WCHAR cap
[20], text
[1024];
258 LoadStringW(Globals
.hInstance
, IDS_WARRANTY
, text
, 1024);
259 LoadStringW(Globals
.hInstance
, IDS_WARRANTY_CAPTION
, cap
, 20);
260 MessageBoxW(Wnd
, text
, cap
, MB_ICONEXCLAMATION
| MB_OK
);
263 static inline BOOL
get_check(HWND hwnd
, INT id
)
265 return BST_CHECKED
&SendMessageW(GetDlgItem(hwnd
, id
), BM_GETSTATE
, 0, 0);
268 static inline INT
set_check(HWND hwnd
, INT id
, BOOL on
)
270 return SendMessageW(GetDlgItem(hwnd
, id
), BM_SETCHECK
, on
?BST_CHECKED
:BST_UNCHECKED
, 0);
273 static inline void choose_font(HWND hwnd
)
275 WCHAR dlg_name
[BUFFER_LEN
], dlg_info
[BUFFER_LEN
];
279 HDC hdc
= GetDC(hwnd
);
280 chFont
.lStructSize
= sizeof(CHOOSEFONT
);
281 chFont
.hwndOwner
= hwnd
;
283 chFont
.lpLogFont
= &lFont
;
284 chFont
.Flags
= CF_SCREENFONTS
| CF_FORCEFONTEXIST
| CF_LIMITSIZE
| CF_NOSCRIPTSEL
;
285 chFont
.rgbColors
= RGB(0,0,0);
286 chFont
.lCustData
= 0;
287 chFont
.lpfnHook
= NULL
;
288 chFont
.lpTemplateName
= NULL
;
289 chFont
.hInstance
= Globals
.hInstance
;
290 chFont
.lpszStyle
= NULL
;
291 chFont
.nFontType
= SIMULATED_FONTTYPE
;
293 chFont
.nSizeMax
= 24;
295 if (ChooseFontW(&chFont
)) {
299 DeleteObject(Globals
.hfont
);
300 Globals
.hfont
= CreateFontIndirectW(&lFont
);
301 hFontOld
= SelectObject(hdc
, Globals
.hfont
);
302 GetTextExtentPoint32W(hdc
, sSpace
, 1, &Globals
.spaceSize
);
304 /* change font in all open child windows */
305 for(childWnd
=GetWindow(Globals
.hmdiclient
,GW_CHILD
); childWnd
; childWnd
=GetNextWindow(childWnd
,GW_HWNDNEXT
)) {
306 ChildWnd
* child
= (ChildWnd
*) GetWindowLongPtrW(childWnd
, GWLP_USERDATA
);
307 SendMessageW(child
->left
.hwnd
, WM_SETFONT
, (WPARAM
)Globals
.hfont
, TRUE
);
308 SendMessageW(child
->right
.hwnd
, WM_SETFONT
, (WPARAM
)Globals
.hfont
, TRUE
);
309 SendMessageW(child
->left
.hwnd
, LB_SETITEMHEIGHT
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
310 SendMessageW(child
->right
.hwnd
, LB_SETITEMHEIGHT
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
311 InvalidateRect(child
->left
.hwnd
, NULL
, TRUE
);
312 InvalidateRect(child
->right
.hwnd
, NULL
, TRUE
);
315 SelectObject(hdc
, hFontOld
);
317 else if (CommDlgExtendedError()) {
318 LoadStringW(Globals
.hInstance
, IDS_FONT_SEL_DLG_NAME
, dlg_name
, BUFFER_LEN
);
319 LoadStringW(Globals
.hInstance
, IDS_FONT_SEL_ERROR
, dlg_info
, BUFFER_LEN
);
320 MessageBoxW(hwnd
, dlg_info
, dlg_name
, MB_OK
);
323 ReleaseDC(hwnd
, hdc
);
330 /* call vswprintf() in msvcrt.dll */
331 /*TODO: fix swprintf() in non-msvcrt mode, so that this dynamic linking function can be removed */
332 static int msvcrt_swprintf(WCHAR
* buffer
, const WCHAR
* fmt
, ...)
334 static int (__cdecl
*pvswprintf
)(WCHAR
*, const WCHAR
*, va_list) = NULL
;
339 HMODULE hModMsvcrt
= LoadLibraryA("msvcrt");
340 pvswprintf
= (int(__cdecl
*)(WCHAR
*,const WCHAR
*,va_list)) GetProcAddress(hModMsvcrt
, "vswprintf");
344 ret
= (*pvswprintf
)(buffer
, fmt
, ap
);
350 static LPCWSTR
my_wcsrchr(LPCWSTR str
, WCHAR c
)
365 #define _tcsrchr my_wcsrchr
367 #define _tcsrchr strrchr
370 #endif /* __WINE__ */
373 /* allocate and initialise a directory entry */
374 static Entry
* alloc_entry(void)
376 Entry
* entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(Entry
));
378 #ifdef _SHELL_FOLDERS
380 entry
->folder
= NULL
;
387 /* free a directory entry */
388 static void free_entry(Entry
* entry
)
390 #ifdef _SHELL_FOLDERS
391 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
392 DestroyIcon(entry
->hicon
);
394 if (entry
->folder
&& entry
->folder
!=Globals
.iDesktop
)
395 IShellFolder_Release(entry
->folder
);
398 IMalloc_Free(Globals
.iMalloc
, entry
->pidl
);
401 HeapFree(GetProcessHeap(), 0, entry
);
404 /* recursively free all child entries */
405 static void free_entries(Entry
* dir
)
407 Entry
*entry
, *next
=dir
->down
;
423 static void read_directory_win(Entry
* dir
, LPCTSTR path
)
425 Entry
* first_entry
= NULL
;
429 int level
= dir
->level
+ 1;
430 WIN32_FIND_DATA w32fd
;
432 #ifndef _NO_EXTENSIONS
436 TCHAR buffer
[MAX_PATH
], *p
;
437 for(p
=buffer
; *path
; )
444 hFind
= FindFirstFile(buffer
, &w32fd
);
446 if (hFind
!= INVALID_HANDLE_VALUE
) {
448 #ifdef _NO_EXTENSIONS
449 /* hide directory entry "." */
450 if (w32fd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
451 LPCTSTR name
= w32fd
.cFileName
;
453 if (name
[0]=='.' && name
[1]=='\0')
457 entry
= alloc_entry();
465 memcpy(&entry
->data
, &w32fd
, sizeof(WIN32_FIND_DATA
));
468 entry
->expanded
= FALSE
;
469 entry
->scanned
= FALSE
;
470 entry
->level
= level
;
472 #ifndef _NO_EXTENSIONS
473 entry
->etype
= ET_WINDOWS
;
474 entry
->bhfi_valid
= FALSE
;
476 lstrcpy(p
, entry
->data
.cFileName
);
478 hFile
= CreateFile(buffer
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
,
479 0, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0);
481 if (hFile
!= INVALID_HANDLE_VALUE
) {
482 if (GetFileInformationByHandle(hFile
, &entry
->bhfi
))
483 entry
->bhfi_valid
= TRUE
;
490 } while(FindNextFile(hFind
, &w32fd
));
498 dir
->down
= first_entry
;
503 static Entry
* find_entry_win(Entry
* dir
, LPCTSTR name
)
507 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
509 LPCTSTR q
= entry
->data
.cFileName
;
512 if (!*p
|| *p
== '\\' || *p
== '/')
514 } while(tolower(*p
++) == tolower(*q
++));
517 q
= entry
->data
.cAlternateFileName
;
520 if (!*p
|| *p
== '\\' || *p
== '/')
522 } while(tolower(*p
++) == tolower(*q
++));
529 static Entry
* read_tree_win(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
531 TCHAR buffer
[MAX_PATH
];
532 Entry
* entry
= &root
->entry
;
536 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
538 #ifndef _NO_EXTENSIONS
539 entry
->etype
= ET_WINDOWS
;
543 while(*s
&& *s
!= '\\' && *s
!= '/')
546 while(*s
== '\\' || *s
== '/')
552 read_directory(entry
, buffer
, sortOrder
, hwnd
);
555 entry
->expanded
= TRUE
;
560 entry
= find_entry_win(entry
, s
);
563 SetCursor(old_cursor
);
569 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
571 static BOOL
time_to_filetime(const time_t* t
, FILETIME
* ftime
)
573 struct tm
* tm
= gmtime(t
);
579 stime
.wYear
= tm
->tm_year
+1900;
580 stime
.wMonth
= tm
->tm_mon
+1;
581 /* stime.wDayOfWeek */
582 stime
.wDay
= tm
->tm_mday
;
583 stime
.wHour
= tm
->tm_hour
;
584 stime
.wMinute
= tm
->tm_min
;
585 stime
.wSecond
= tm
->tm_sec
;
587 return SystemTimeToFileTime(&stime
, ftime
);
590 static void read_directory_unix(Entry
* dir
, LPCTSTR path
)
592 Entry
* first_entry
= NULL
;
597 int level
= dir
->level
+ 1;
599 char cpath
[MAX_PATH
];
601 WideCharToMultiByte(CP_UNIXCP
, 0, path
, -1, cpath
, MAX_PATH
, NULL
, NULL
);
603 const char* cpath
= path
;
606 pdir
= opendir(cpath
);
611 char buffer
[MAX_PATH
], *p
;
614 for(p
=buffer
,s
=cpath
; *s
; )
617 if (p
==buffer
|| p
[-1]!='/')
620 while((ent
=readdir(pdir
))) {
621 entry
= alloc_entry();
629 entry
->etype
= ET_UNIX
;
631 strcpy(p
, ent
->d_name
);
633 MultiByteToWideChar(CP_UNIXCP
, 0, p
, -1, entry
->data
.cFileName
, MAX_PATH
);
635 lstrcpy(entry
->data
.cFileName
, p
);
638 if (!stat(buffer
, &st
)) {
639 entry
->data
.dwFileAttributes
= p
[0]=='.'? FILE_ATTRIBUTE_HIDDEN
: 0;
641 if (S_ISDIR(st
.st_mode
))
642 entry
->data
.dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
644 entry
->data
.nFileSizeLow
= st
.st_size
& 0xFFFFFFFF;
645 entry
->data
.nFileSizeHigh
= st
.st_size
>> 32;
647 memset(&entry
->data
.ftCreationTime
, 0, sizeof(FILETIME
));
648 time_to_filetime(&st
.st_atime
, &entry
->data
.ftLastAccessTime
);
649 time_to_filetime(&st
.st_mtime
, &entry
->data
.ftLastWriteTime
);
651 entry
->bhfi
.nFileIndexLow
= ent
->d_ino
;
652 entry
->bhfi
.nFileIndexHigh
= 0;
654 entry
->bhfi
.nNumberOfLinks
= st
.st_nlink
;
656 entry
->bhfi_valid
= TRUE
;
658 entry
->data
.nFileSizeLow
= 0;
659 entry
->data
.nFileSizeHigh
= 0;
660 entry
->bhfi_valid
= FALSE
;
665 entry
->expanded
= FALSE
;
666 entry
->scanned
= FALSE
;
667 entry
->level
= level
;
678 dir
->down
= first_entry
;
682 static Entry
* find_entry_unix(Entry
* dir
, LPCTSTR name
)
686 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
688 LPCTSTR q
= entry
->data
.cFileName
;
691 if (!*p
|| *p
== '/')
693 } while(*p
++ == *q
++);
699 static Entry
* read_tree_unix(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
701 TCHAR buffer
[MAX_PATH
];
702 Entry
* entry
= &root
->entry
;
706 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
708 entry
->etype
= ET_UNIX
;
711 while(*s
&& *s
!= '/')
720 read_directory(entry
, buffer
, sortOrder
, hwnd
);
723 entry
->expanded
= TRUE
;
728 entry
= find_entry_unix(entry
, s
);
731 SetCursor(old_cursor
);
736 #endif /* !defined(_NO_EXTENSIONS) && defined(__WINE__) */
739 #ifdef _SHELL_FOLDERS
742 #define get_strret get_strretW
743 #define path_from_pidl path_from_pidlW
745 #define get_strret get_strretA
746 #define path_from_pidl path_from_pidlA
750 static void free_strret(STRRET
* str
)
752 if (str
->uType
== STRRET_WSTR
)
753 IMalloc_Free(Globals
.iMalloc
, str
->UNION_MEMBER(pOleStr
));
759 static LPSTR
strcpyn(LPSTR dest
, LPCSTR source
, size_t count
)
764 for(s
=source
; count
&&(*d
++=*s
++); )
770 static void get_strretA(STRRET
* str
, const SHITEMID
* shiid
, LPSTR buffer
, int len
)
774 WideCharToMultiByte(CP_ACP
, 0, str
->UNION_MEMBER(pOleStr
), -1, buffer
, len
, NULL
, NULL
);
778 strcpyn(buffer
, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), len
);
782 strcpyn(buffer
, str
->UNION_MEMBER(cStr
), len
);
786 static HRESULT
path_from_pidlA(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPSTR buffer
, int len
)
790 /* SHGDN_FORPARSING: get full path of id list */
791 HRESULT hr
= IShellFolder_GetDisplayNameOf(folder
, pidl
, SHGDN_FORPARSING
, &str
);
794 get_strretA(&str
, &pidl
->mkid
, buffer
, len
);
804 static LPWSTR
wcscpyn(LPWSTR dest
, LPCWSTR source
, size_t count
)
809 for(s
=source
; count
&&(*d
++=*s
++); )
815 static void get_strretW(STRRET
* str
, const SHITEMID
* shiid
, LPWSTR buffer
, int len
)
819 wcscpyn(buffer
, str
->UNION_MEMBER(pOleStr
), len
);
823 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), -1, buffer
, len
);
827 MultiByteToWideChar(CP_ACP
, 0, str
->UNION_MEMBER(cStr
), -1, buffer
, len
);
832 static HRESULT
name_from_pidl(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPTSTR buffer
, int len
, SHGDNF flags
)
836 HRESULT hr
= IShellFolder_GetDisplayNameOf(folder
, pidl
, flags
, &str
);
839 get_strret(&str
, &pidl
->mkid
, buffer
, len
);
848 static HRESULT
path_from_pidlW(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPWSTR buffer
, int len
)
852 /* SHGDN_FORPARSING: get full path of id list */
853 HRESULT hr
= IShellFolder_GetDisplayNameOf(folder
, pidl
, SHGDN_FORPARSING
, &str
);
856 get_strretW(&str
, &pidl
->mkid
, buffer
, len
);
865 /* create an item id list from a file system path */
867 static LPITEMIDLIST
get_path_pidl(LPTSTR path
, HWND hwnd
)
874 LPWSTR buffer
= path
;
876 WCHAR buffer
[MAX_PATH
];
877 MultiByteToWideChar(CP_ACP
, 0, path
, -1, buffer
, MAX_PATH
);
880 hr
= IShellFolder_ParseDisplayName(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
888 /* convert an item id list from relative to absolute (=relative to the desktop) format */
890 static LPITEMIDLIST
get_to_absolute_pidl(Entry
* entry
, HWND hwnd
)
892 if (entry
->up
&& entry
->up
->etype
==ET_SHELL
) {
893 IShellFolder
* folder
= entry
->up
->folder
;
894 WCHAR buffer
[MAX_PATH
];
896 HRESULT hr
= path_from_pidlW(folder
, entry
->pidl
, buffer
, MAX_PATH
);
902 hr
= IShellFolder_ParseDisplayName(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
907 } else if (entry
->etype
== ET_WINDOWS
) {
908 TCHAR path
[MAX_PATH
];
910 get_path(entry
, path
);
912 return get_path_pidl(path
, hwnd
);
913 } else if (entry
->pidl
)
914 return ILClone(entry
->pidl
);
920 static HICON
extract_icon(IShellFolder
* folder
, LPCITEMIDLIST pidl
)
922 IExtractIcon
* pExtract
;
924 if (SUCCEEDED(IShellFolder_GetUIObjectOf(folder
, 0, 1, (LPCITEMIDLIST
*)&pidl
, &IID_IExtractIcon
, 0, (LPVOID
*)&pExtract
))) {
925 TCHAR path
[_MAX_PATH
];
930 if (SUCCEEDED(IExtractIconW_GetIconLocation(pExtract
, GIL_FORSHELL
, path
, _MAX_PATH
, &idx
, &flags
))) {
931 if (!(flags
& GIL_NOTFILENAME
)) {
933 idx
= 0; /* special case for some control panel applications */
935 if ((int)ExtractIconEx(path
, idx
, 0, &hicon
, 1) > 0)
936 flags
&= ~GIL_DONTCACHE
;
938 HICON hIconLarge
= 0;
940 HRESULT hr
= IExtractIconW_Extract(pExtract
, path
, idx
, &hIconLarge
, &hicon
, MAKELONG(0/*GetSystemMetrics(SM_CXICON)*/,GetSystemMetrics(SM_CXSMICON
)));
943 DestroyIcon(hIconLarge
);
954 static Entry
* find_entry_shell(Entry
* dir
, LPCITEMIDLIST pidl
)
958 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
959 if (entry
->pidl
->mkid
.cb
== pidl
->mkid
.cb
&&
960 !memcmp(entry
->pidl
, pidl
, entry
->pidl
->mkid
.cb
))
967 static Entry
* read_tree_shell(Root
* root
, LPITEMIDLIST pidl
, SORT_ORDER sortOrder
, HWND hwnd
)
969 Entry
* entry
= &root
->entry
;
971 LPITEMIDLIST next_pidl
= pidl
;
972 IShellFolder
* folder
;
973 IShellFolder
* child
= NULL
;
976 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
978 #ifndef _NO_EXTENSIONS
979 entry
->etype
= ET_SHELL
;
982 folder
= Globals
.iDesktop
;
985 entry
->pidl
= next_pidl
;
986 entry
->folder
= folder
;
991 /* copy first element of item idlist */
992 next_pidl
= IMalloc_Alloc(Globals
.iMalloc
, pidl
->mkid
.cb
+sizeof(USHORT
));
993 memcpy(next_pidl
, pidl
, pidl
->mkid
.cb
);
994 ((LPITEMIDLIST
)((LPBYTE
)next_pidl
+pidl
->mkid
.cb
))->mkid
.cb
= 0;
996 hr
= IShellFolder_BindToObject(folder
, next_pidl
, 0, &IID_IShellFolder
, (void**)&child
);
1000 read_directory(entry
, NULL
, sortOrder
, hwnd
);
1003 entry
->expanded
= TRUE
;
1005 next
= find_entry_shell(entry
, next_pidl
);
1012 /* go to next element */
1013 pidl
= (LPITEMIDLIST
) ((LPBYTE
)pidl
+pidl
->mkid
.cb
);
1016 SetCursor(old_cursor
);
1022 static void fill_w32fdata_shell(IShellFolder
* folder
, LPCITEMIDLIST pidl
, SFGAOF attribs
, WIN32_FIND_DATA
* w32fdata
)
1024 if (!(attribs
& SFGAO_FILESYSTEM
) ||
1025 FAILED(SHGetDataFromIDList(folder
, pidl
, SHGDFIL_FINDDATA
, w32fdata
, sizeof(WIN32_FIND_DATA
)))) {
1026 WIN32_FILE_ATTRIBUTE_DATA fad
;
1027 IDataObject
* pDataObj
;
1029 STGMEDIUM medium
= {0, {0}, 0};
1030 FORMATETC fmt
= {Globals
.cfStrFName
, 0, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
1032 HRESULT hr
= IShellFolder_GetUIObjectOf(folder
, 0, 1, &pidl
, &IID_IDataObject
, 0, (LPVOID
*)&pDataObj
);
1034 if (SUCCEEDED(hr
)) {
1035 hr
= IDataObject_GetData(pDataObj
, &fmt
, &medium
);
1037 IDataObject_Release(pDataObj
);
1039 if (SUCCEEDED(hr
)) {
1040 LPCTSTR path
= (LPCTSTR
)GlobalLock(medium
.UNION_MEMBER(hGlobal
));
1041 UINT sem_org
= SetErrorMode(SEM_FAILCRITICALERRORS
);
1043 if (GetFileAttributesEx(path
, GetFileExInfoStandard
, &fad
)) {
1044 w32fdata
->dwFileAttributes
= fad
.dwFileAttributes
;
1045 w32fdata
->ftCreationTime
= fad
.ftCreationTime
;
1046 w32fdata
->ftLastAccessTime
= fad
.ftLastAccessTime
;
1047 w32fdata
->ftLastWriteTime
= fad
.ftLastWriteTime
;
1049 if (!(fad
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
1050 w32fdata
->nFileSizeLow
= fad
.nFileSizeLow
;
1051 w32fdata
->nFileSizeHigh
= fad
.nFileSizeHigh
;
1055 SetErrorMode(sem_org
);
1057 GlobalUnlock(medium
.UNION_MEMBER(hGlobal
));
1058 GlobalFree(medium
.UNION_MEMBER(hGlobal
));
1063 if (attribs
& (SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
))
1064 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
1066 if (attribs
& SFGAO_READONLY
)
1067 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_READONLY
;
1069 if (attribs
& SFGAO_COMPRESSED
)
1070 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_COMPRESSED
;
1074 static void read_directory_shell(Entry
* dir
, HWND hwnd
)
1076 IShellFolder
* folder
= dir
->folder
;
1077 int level
= dir
->level
+ 1;
1080 IShellFolder
* child
;
1081 IEnumIDList
* idlist
;
1083 Entry
* first_entry
= NULL
;
1090 hr
= IShellFolder_EnumObjects(folder
, hwnd
, SHCONTF_FOLDERS
|SHCONTF_NONFOLDERS
|SHCONTF_INCLUDEHIDDEN
|SHCONTF_SHAREABLE
|SHCONTF_STORAGE
, &idlist
);
1092 if (SUCCEEDED(hr
)) {
1094 #define FETCH_ITEM_COUNT 32
1095 LPITEMIDLIST pidls
[FETCH_ITEM_COUNT
];
1100 memset(pidls
, 0, sizeof(pidls
));
1102 hr
= IEnumIDList_Next(idlist
, FETCH_ITEM_COUNT
, pidls
, &cnt
);
1109 for(n
=0; n
<cnt
; ++n
) {
1110 entry
= alloc_entry();
1113 first_entry
= entry
;
1118 memset(&entry
->data
, 0, sizeof(WIN32_FIND_DATA
));
1119 entry
->bhfi_valid
= FALSE
;
1121 attribs
= ~SFGAO_FILESYSTEM
; /*SFGAO_HASSUBFOLDER|SFGAO_FOLDER; SFGAO_FILESYSTEM sorgt dafür, daß "My Documents" anstatt von "Martin's Documents" angezeigt wird */
1123 hr
= IShellFolder_GetAttributesOf(folder
, 1, (LPCITEMIDLIST
*)&pidls
[n
], &attribs
);
1125 if (SUCCEEDED(hr
)) {
1126 if (attribs
!= (SFGAOF
)~SFGAO_FILESYSTEM
) {
1127 fill_w32fdata_shell(folder
, pidls
[n
], attribs
, &entry
->data
);
1129 entry
->bhfi_valid
= TRUE
;
1135 entry
->pidl
= pidls
[n
];
1137 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1138 hr
= IShellFolder_BindToObject(folder
, pidls
[n
], 0, &IID_IShellFolder
, (void**)&child
);
1141 entry
->folder
= child
;
1143 entry
->folder
= NULL
;
1146 entry
->folder
= NULL
;
1148 if (!entry
->data
.cFileName
[0])
1149 /*hr = */name_from_pidl(folder
, pidls
[n
], entry
->data
.cFileName
, MAX_PATH
, /*SHGDN_INFOLDER*/0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/);
1151 /* get display icons for files and virtual objects */
1152 if (!(entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1153 !(attribs
& SFGAO_FILESYSTEM
)) {
1154 entry
->hicon
= extract_icon(folder
, pidls
[n
]);
1157 entry
->hicon
= (HICON
)-1; /* don't try again later */
1162 entry
->expanded
= FALSE
;
1163 entry
->scanned
= FALSE
;
1164 entry
->level
= level
;
1166 #ifndef _NO_EXTENSIONS
1167 entry
->etype
= ET_SHELL
;
1168 entry
->bhfi_valid
= FALSE
;
1175 IEnumIDList_Release(idlist
);
1181 dir
->down
= first_entry
;
1182 dir
->scanned
= TRUE
;
1185 #endif /* _SHELL_FOLDERS */
1188 /* sort order for different directory/file types */
1197 /* distinguish between ".", ".." and any other directory names */
1198 static int TypeOrderFromDirname(LPCTSTR name
)
1200 if (name
[0] == '.') {
1201 if (name
[1] == '\0')
1202 return TO_DOT
; /* "." */
1204 if (name
[1]=='.' && name
[2]=='\0')
1205 return TO_DOTDOT
; /* ".." */
1208 return TO_OTHER_DIR
; /* anything else */
1211 /* directories first... */
1212 static int compareType(const WIN32_FIND_DATA
* fd1
, const WIN32_FIND_DATA
* fd2
)
1214 int order1
= fd1
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1215 int order2
= fd2
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1217 /* Handle "." and ".." as special case and move them at the very first beginning. */
1218 if (order1
==TO_DIR
&& order2
==TO_DIR
) {
1219 order1
= TypeOrderFromDirname(fd1
->cFileName
);
1220 order2
= TypeOrderFromDirname(fd2
->cFileName
);
1223 return order2
==order1
? 0: order1
<order2
? -1: 1;
1227 static int compareName(const void* arg1
, const void* arg2
)
1229 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1230 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1232 int cmp
= compareType(fd1
, fd2
);
1236 return lstrcmpi(fd1
->cFileName
, fd2
->cFileName
);
1239 static int compareExt(const void* arg1
, const void* arg2
)
1241 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1242 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1243 const TCHAR
*name1
, *name2
, *ext1
, *ext2
;
1245 int cmp
= compareType(fd1
, fd2
);
1249 name1
= fd1
->cFileName
;
1250 name2
= fd2
->cFileName
;
1252 ext1
= _tcsrchr(name1
, '.');
1253 ext2
= _tcsrchr(name2
, '.');
1265 cmp
= lstrcmpi(ext1
, ext2
);
1269 return lstrcmpi(name1
, name2
);
1272 static int compareSize(const void* arg1
, const void* arg2
)
1274 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1275 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1277 int cmp
= compareType(fd1
, fd2
);
1281 cmp
= fd2
->nFileSizeHigh
- fd1
->nFileSizeHigh
;
1288 cmp
= fd2
->nFileSizeLow
- fd1
->nFileSizeLow
;
1290 return cmp
<0? -1: cmp
>0? 1: 0;
1293 static int compareDate(const void* arg1
, const void* arg2
)
1295 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1296 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1298 int cmp
= compareType(fd1
, fd2
);
1302 return CompareFileTime(&fd2
->ftLastWriteTime
, &fd1
->ftLastWriteTime
);
1306 static int (*sortFunctions
[])(const void* arg1
, const void* arg2
) = {
1307 compareName
, /* SORT_NAME */
1308 compareExt
, /* SORT_EXT */
1309 compareSize
, /* SORT_SIZE */
1310 compareDate
/* SORT_DATE */
1314 static void SortDirectory(Entry
* dir
, SORT_ORDER sortOrder
)
1316 Entry
* entry
= dir
->down
;
1321 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1325 array
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(Entry
*));
1328 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1331 /* call qsort with the appropriate compare function */
1332 qsort(array
, len
, sizeof(array
[0]), sortFunctions
[sortOrder
]);
1334 dir
->down
= array
[0];
1336 for(p
=array
; --len
; p
++)
1341 HeapFree(GetProcessHeap(), 0, array
);
1346 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
1348 TCHAR buffer
[MAX_PATH
];
1353 #ifdef _SHELL_FOLDERS
1354 if (dir
->etype
== ET_SHELL
)
1356 read_directory_shell(dir
, hwnd
);
1358 if (Globals
.prescan_node
) {
1367 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1368 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1369 read_directory_shell(entry
, hwnd
);
1370 SortDirectory(entry
, sortOrder
);
1376 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1377 if (dir
->etype
== ET_UNIX
)
1379 read_directory_unix(dir
, path
);
1381 if (Globals
.prescan_node
) {
1390 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1391 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1392 lstrcpy(d
, entry
->data
.cFileName
);
1393 read_directory_unix(entry
, buffer
);
1394 SortDirectory(entry
, sortOrder
);
1401 read_directory_win(dir
, path
);
1403 if (Globals
.prescan_node
) {
1412 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1413 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1414 lstrcpy(d
, entry
->data
.cFileName
);
1415 read_directory_win(entry
, buffer
);
1416 SortDirectory(entry
, sortOrder
);
1421 SortDirectory(dir
, sortOrder
);
1425 static Entry
* read_tree(Root
* root
, LPCTSTR path
, LPITEMIDLIST pidl
, LPTSTR drv
, SORT_ORDER sortOrder
, HWND hwnd
)
1427 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1428 static const TCHAR sSlash
[] = {'/', '\0'};
1430 static const TCHAR sBackslash
[] = {'\\', '\0'};
1432 #ifdef _SHELL_FOLDERS
1435 /* read shell namespace tree */
1436 root
->drive_type
= DRIVE_UNKNOWN
;
1439 load_string(root
->volname
, IDS_DESKTOP
);
1441 load_string(root
->fs
, IDS_SHELL
);
1443 return read_tree_shell(root
, pidl
, sortOrder
, hwnd
);
1447 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1450 /* read unix file system tree */
1451 root
->drive_type
= GetDriveType(path
);
1453 lstrcat(drv
, sSlash
);
1454 load_string(root
->volname
, IDS_ROOT_FS
);
1456 load_string(root
->fs
, IDS_UNIXFS
);
1458 lstrcpy(root
->path
, sSlash
);
1460 return read_tree_unix(root
, path
, sortOrder
, hwnd
);
1464 /* read WIN32 file system tree */
1465 root
->drive_type
= GetDriveType(path
);
1467 lstrcat(drv
, sBackslash
);
1468 GetVolumeInformation(drv
, root
->volname
, _MAX_FNAME
, 0, 0, &root
->fs_flags
, root
->fs
, _MAX_DIR
);
1470 lstrcpy(root
->path
, drv
);
1472 return read_tree_win(root
, path
, sortOrder
, hwnd
);
1476 /* flags to filter different file types */
1478 TF_DIRECTORIES
= 0x01,
1480 TF_DOCUMENTS
= 0x04,
1487 static ChildWnd
* alloc_child_window(LPCTSTR path
, LPITEMIDLIST pidl
, HWND hwnd
)
1489 TCHAR drv
[_MAX_DRIVE
+1], dir
[_MAX_DIR
], name
[_MAX_FNAME
], ext
[_MAX_EXT
];
1490 TCHAR dir_path
[MAX_PATH
];
1491 TCHAR b1
[BUFFER_LEN
];
1492 static const TCHAR sAsterics
[] = {'*', '\0'};
1494 ChildWnd
* child
= HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd
));
1495 Root
* root
= &child
->root
;
1498 memset(child
, 0, sizeof(ChildWnd
));
1500 child
->left
.treePane
= TRUE
;
1501 child
->left
.visible_cols
= 0;
1503 child
->right
.treePane
= FALSE
;
1504 #ifndef _NO_EXTENSIONS
1505 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_INDEX
|COL_LINKS
;
1507 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
;
1510 child
->pos
.length
= sizeof(WINDOWPLACEMENT
);
1511 child
->pos
.flags
= 0;
1512 child
->pos
.showCmd
= SW_SHOWNORMAL
;
1513 child
->pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
1514 child
->pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
1515 child
->pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
1516 child
->pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
1518 child
->focus_pane
= 0;
1519 child
->split_pos
= DEFAULT_SPLIT_POS
;
1520 child
->sortOrder
= SORT_NAME
;
1521 child
->header_wdths_ok
= FALSE
;
1525 lstrcpy(child
->path
, path
);
1527 _tsplitpath(path
, drv
, dir
, name
, ext
);
1530 lstrcpy(child
->filter_pattern
, sAsterics
);
1531 child
->filter_flags
= TF_ALL
;
1533 root
->entry
.level
= 0;
1535 lstrcpy(dir_path
, drv
);
1536 lstrcat(dir_path
, dir
);
1537 entry
= read_tree(root
, dir_path
, pidl
, drv
, child
->sortOrder
, hwnd
);
1539 #ifdef _SHELL_FOLDERS
1540 if (root
->entry
.etype
== ET_SHELL
)
1541 load_string(root
->entry
.data
.cFileName
, IDS_DESKTOP
);
1544 wsprintf(root
->entry
.data
.cFileName
, RS(b1
,IDS_TITLEFMT
), drv
, root
->fs
);
1546 root
->entry
.data
.dwFileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
1548 child
->left
.root
= &root
->entry
;
1549 child
->right
.root
= NULL
;
1551 set_curdir(child
, entry
, 0, hwnd
);
1557 /* free all memory associated with a child window */
1558 static void free_child_window(ChildWnd
* child
)
1560 free_entries(&child
->root
.entry
);
1561 HeapFree(GetProcessHeap(), 0, child
);
1565 /* get full path of specified directory entry */
1566 static void get_path(Entry
* dir
, PTSTR path
)
1572 #ifdef _SHELL_FOLDERS
1573 if (dir
->etype
== ET_SHELL
)
1583 hr
= IShellFolder_GetAttributesOf(dir
->folder
, 1, (LPCITEMIDLIST
*)&dir
->pidl
, &attribs
);
1585 if (SUCCEEDED(hr
) && (attribs
&SFGAO_FILESYSTEM
)) {
1586 IShellFolder
* parent
= dir
->up
? dir
->up
->folder
: Globals
.iDesktop
;
1588 hr
= path_from_pidl(parent
, dir
->pidl
, path
, MAX_PATH
);
1594 for(entry
=dir
; entry
; level
++) {
1600 name
= entry
->data
.cFileName
;
1603 for(l
=0; *s
&& *s
!= '/' && *s
!= '\\'; s
++)
1609 memmove(path
+l
+1, path
, len
*sizeof(TCHAR
));
1610 memcpy(path
+1, name
, l
*sizeof(TCHAR
));
1613 #ifndef _NO_EXTENSIONS
1614 if (entry
->etype
== ET_UNIX
)
1623 memmove(path
+l
, path
, len
*sizeof(TCHAR
));
1624 memcpy(path
, name
, l
*sizeof(TCHAR
));
1631 #ifndef _NO_EXTENSIONS
1632 if (entry
->etype
== ET_UNIX
)
1643 static windowOptions
load_registry_settings(void)
1651 RegOpenKeyExW( HKEY_CURRENT_USER
, registry_key
,
1652 0, KEY_QUERY_VALUE
, &hKey
);
1654 size
= sizeof(DWORD
);
1656 if( RegQueryValueExW( hKey
, reg_start_x
, NULL
, &type
,
1657 (LPBYTE
) &opts
.start_x
, &size
) != ERROR_SUCCESS
)
1658 opts
.start_x
= CW_USEDEFAULT
;
1660 if( RegQueryValueExW( hKey
, reg_start_y
, NULL
, &type
,
1661 (LPBYTE
) &opts
.start_y
, &size
) != ERROR_SUCCESS
)
1662 opts
.start_y
= CW_USEDEFAULT
;
1664 if( RegQueryValueExW( hKey
, reg_width
, NULL
, &type
,
1665 (LPBYTE
) &opts
.width
, &size
) != ERROR_SUCCESS
)
1666 opts
.width
= CW_USEDEFAULT
;
1668 if( RegQueryValueExW( hKey
, reg_height
, NULL
, &type
,
1669 (LPBYTE
) &opts
.height
, &size
) != ERROR_SUCCESS
)
1670 opts
.height
= CW_USEDEFAULT
;
1671 size
=sizeof(logfont
);
1672 if( RegQueryValueExW( hKey
, reg_logfont
, NULL
, &type
,
1673 (LPBYTE
) &logfont
, &size
) != ERROR_SUCCESS
)
1674 GetObject(GetStockObject(DEFAULT_GUI_FONT
),sizeof(logfont
),&logfont
);
1676 RegCloseKey( hKey
);
1678 Globals
.hfont
= CreateFontIndirect(&logfont
);
1682 static void save_registry_settings(void)
1689 wi
.cbSize
= sizeof( WINDOWINFO
);
1690 GetWindowInfo(Globals
.hMainWnd
, &wi
);
1691 width
= wi
.rcWindow
.right
- wi
.rcWindow
.left
;
1692 height
= wi
.rcWindow
.bottom
- wi
.rcWindow
.top
;
1694 if ( RegOpenKeyExW( HKEY_CURRENT_USER
, registry_key
,
1695 0, KEY_SET_VALUE
, &hKey
) != ERROR_SUCCESS
)
1697 /* Unable to save registry settings - try to create key */
1698 if ( RegCreateKeyExW( HKEY_CURRENT_USER
, registry_key
,
1699 0, NULL
, REG_OPTION_NON_VOLATILE
,
1700 KEY_SET_VALUE
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
1702 /* FIXME: Cannot create key */
1706 /* Save all of the settings */
1707 RegSetValueExW( hKey
, reg_start_x
, 0, REG_DWORD
,
1708 (LPBYTE
) &wi
.rcWindow
.left
, sizeof(DWORD
) );
1709 RegSetValueExW( hKey
, reg_start_y
, 0, REG_DWORD
,
1710 (LPBYTE
) &wi
.rcWindow
.top
, sizeof(DWORD
) );
1711 RegSetValueExW( hKey
, reg_width
, 0, REG_DWORD
,
1712 (LPBYTE
) &width
, sizeof(DWORD
) );
1713 RegSetValueExW( hKey
, reg_height
, 0, REG_DWORD
,
1714 (LPBYTE
) &height
, sizeof(DWORD
) );
1715 GetObject(Globals
.hfont
, sizeof(logfont
), &logfont
);
1716 RegSetValueExW( hKey
, reg_logfont
, 0, REG_BINARY
,
1717 (LPBYTE
) &logfont
, sizeof(LOGFONT
) );
1719 /* TODO: Save more settings here (List vs. Detailed View, etc.) */
1720 RegCloseKey( hKey
);
1723 static void resize_frame_rect(HWND hwnd
, PRECT prect
)
1728 if (IsWindowVisible(Globals
.htoolbar
)) {
1729 SendMessage(Globals
.htoolbar
, WM_SIZE
, 0, 0);
1730 GetClientRect(Globals
.htoolbar
, &rt
);
1731 prect
->top
= rt
.bottom
+3;
1732 prect
->bottom
-= rt
.bottom
+3;
1735 if (IsWindowVisible(Globals
.hdrivebar
)) {
1736 SendMessage(Globals
.hdrivebar
, WM_SIZE
, 0, 0);
1737 GetClientRect(Globals
.hdrivebar
, &rt
);
1738 new_top
= --prect
->top
+ rt
.bottom
+3;
1739 MoveWindow(Globals
.hdrivebar
, 0, prect
->top
, rt
.right
, new_top
, TRUE
);
1740 prect
->top
= new_top
;
1741 prect
->bottom
-= rt
.bottom
+2;
1744 if (IsWindowVisible(Globals
.hstatusbar
)) {
1745 int parts
[] = {300, 500};
1747 SendMessage(Globals
.hstatusbar
, WM_SIZE
, 0, 0);
1748 SendMessage(Globals
.hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1749 GetClientRect(Globals
.hstatusbar
, &rt
);
1750 prect
->bottom
-= rt
.bottom
;
1753 MoveWindow(Globals
.hmdiclient
, prect
->left
-1,prect
->top
-1,prect
->right
+2,prect
->bottom
+1, TRUE
);
1756 static void resize_frame(HWND hwnd
, int cx
, int cy
)
1765 resize_frame_rect(hwnd
, &rect
);
1768 static void resize_frame_client(HWND hwnd
)
1772 GetClientRect(hwnd
, &rect
);
1774 resize_frame_rect(hwnd
, &rect
);
1778 static HHOOK hcbthook
;
1779 static ChildWnd
* newchild
= NULL
;
1781 static LRESULT CALLBACK
CBTProc(int code
, WPARAM wparam
, LPARAM lparam
)
1783 if (code
==HCBT_CREATEWND
&& newchild
) {
1784 ChildWnd
* child
= newchild
;
1787 child
->hwnd
= (HWND
) wparam
;
1788 SetWindowLongPtr(child
->hwnd
, GWLP_USERDATA
, (LPARAM
)child
);
1791 return CallNextHookEx(hcbthook
, code
, wparam
, lparam
);
1794 static HWND
create_child_window(ChildWnd
* child
)
1796 MDICREATESTRUCT mcs
;
1799 mcs
.szClass
= sWINEFILETREE
;
1800 mcs
.szTitle
= (LPTSTR
)child
->path
;
1801 mcs
.hOwner
= Globals
.hInstance
;
1802 mcs
.x
= child
->pos
.rcNormalPosition
.left
;
1803 mcs
.y
= child
->pos
.rcNormalPosition
.top
;
1804 mcs
.cx
= child
->pos
.rcNormalPosition
.right
-child
->pos
.rcNormalPosition
.left
;
1805 mcs
.cy
= child
->pos
.rcNormalPosition
.bottom
-child
->pos
.rcNormalPosition
.top
;
1809 hcbthook
= SetWindowsHookEx(WH_CBT
, CBTProc
, 0, GetCurrentThreadId());
1812 child
->hwnd
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDICREATE
, 0, (LPARAM
)&mcs
);
1814 UnhookWindowsHookEx(hcbthook
);
1818 UnhookWindowsHookEx(hcbthook
);
1820 SendMessage(child
->left
.hwnd
, LB_SETITEMHEIGHT
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
1821 SendMessage(child
->right
.hwnd
, LB_SETITEMHEIGHT
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
1823 idx
= SendMessage(child
->left
.hwnd
, LB_FINDSTRING
, 0, (LPARAM
)child
->left
.cur
);
1824 SendMessage(child
->left
.hwnd
, LB_SETCURSEL
, idx
, 0);
1830 struct ExecuteDialog
{
1831 TCHAR cmd
[MAX_PATH
];
1835 static INT_PTR CALLBACK
ExecuteDialogDlgProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1837 static struct ExecuteDialog
* dlg
;
1841 dlg
= (struct ExecuteDialog
*) lparam
;
1845 int id
= (int)wparam
;
1848 GetWindowText(GetDlgItem(hwnd
, 201), dlg
->cmd
, MAX_PATH
);
1849 dlg
->cmdshow
= get_check(hwnd
,214) ? SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
1850 EndDialog(hwnd
, id
);
1851 } else if (id
== IDCANCEL
)
1852 EndDialog(hwnd
, id
);
1861 static INT_PTR CALLBACK
DestinationDlgProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1863 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
1867 SetWindowLongPtr(hwnd
, GWLP_USERDATA
, lparam
);
1868 SetWindowText(GetDlgItem(hwnd
, 201), (LPCTSTR
)lparam
);
1872 int id
= (int)wparam
;
1876 LPTSTR dest
= (LPTSTR
) GetWindowLongPtr(hwnd
, GWLP_USERDATA
);
1877 GetWindowText(GetDlgItem(hwnd
, 201), dest
, MAX_PATH
);
1878 EndDialog(hwnd
, id
);
1882 EndDialog(hwnd
, id
);
1886 MessageBox(hwnd
, RS(b1
,IDS_NO_IMPL
), RS(b2
,IDS_WINEFILE
), MB_OK
);
1898 struct FilterDialog
{
1899 TCHAR pattern
[MAX_PATH
];
1903 static INT_PTR CALLBACK
FilterDialogDlgProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1905 static struct FilterDialog
* dlg
;
1909 dlg
= (struct FilterDialog
*) lparam
;
1910 SetWindowText(GetDlgItem(hwnd
, IDC_VIEW_PATTERN
), dlg
->pattern
);
1911 set_check(hwnd
, IDC_VIEW_TYPE_DIRECTORIES
, dlg
->flags
&TF_DIRECTORIES
);
1912 set_check(hwnd
, IDC_VIEW_TYPE_PROGRAMS
, dlg
->flags
&TF_PROGRAMS
);
1913 set_check(hwnd
, IDC_VIEW_TYPE_DOCUMENTS
, dlg
->flags
&TF_DOCUMENTS
);
1914 set_check(hwnd
, IDC_VIEW_TYPE_OTHERS
, dlg
->flags
&TF_OTHERS
);
1915 set_check(hwnd
, IDC_VIEW_TYPE_HIDDEN
, dlg
->flags
&TF_HIDDEN
);
1919 int id
= (int)wparam
;
1924 GetWindowText(GetDlgItem(hwnd
, IDC_VIEW_PATTERN
), dlg
->pattern
, MAX_PATH
);
1926 flags
|= get_check(hwnd
, IDC_VIEW_TYPE_DIRECTORIES
) ? TF_DIRECTORIES
: 0;
1927 flags
|= get_check(hwnd
, IDC_VIEW_TYPE_PROGRAMS
) ? TF_PROGRAMS
: 0;
1928 flags
|= get_check(hwnd
, IDC_VIEW_TYPE_DOCUMENTS
) ? TF_DOCUMENTS
: 0;
1929 flags
|= get_check(hwnd
, IDC_VIEW_TYPE_OTHERS
) ? TF_OTHERS
: 0;
1930 flags
|= get_check(hwnd
, IDC_VIEW_TYPE_HIDDEN
) ? TF_HIDDEN
: 0;
1934 EndDialog(hwnd
, id
);
1935 } else if (id
== IDCANCEL
)
1936 EndDialog(hwnd
, id
);
1945 struct PropertiesDialog
{
1946 TCHAR path
[MAX_PATH
];
1951 /* Structure used to store enumerated languages and code pages. */
1952 struct LANGANDCODEPAGE
{
1957 static LPCSTR InfoStrings
[] = {
1973 static void PropDlg_DisplayValue(HWND hlbox
, HWND hedit
)
1975 int idx
= SendMessage(hlbox
, LB_GETCURSEL
, 0, 0);
1977 if (idx
!= LB_ERR
) {
1978 LPCTSTR pValue
= (LPCTSTR
) SendMessage(hlbox
, LB_GETITEMDATA
, idx
, 0);
1981 SetWindowText(hedit
, pValue
);
1985 static void CheckForFileInfo(struct PropertiesDialog
* dlg
, HWND hwnd
, LPCTSTR strFilename
)
1987 static TCHAR sBackSlash
[] = {'\\','\0'};
1988 static TCHAR sTranslation
[] = {'\\','V','a','r','F','i','l','e','I','n','f','o','\\','T','r','a','n','s','l','a','t','i','o','n','\0'};
1989 static TCHAR sStringFileInfo
[] = {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o','\\',
1990 '%','0','4','x','%','0','4','x','\\','%','s','\0'};
1991 DWORD dwVersionDataLen
= GetFileVersionInfoSize(strFilename
, NULL
);
1993 if (dwVersionDataLen
) {
1994 dlg
->pVersionData
= HeapAlloc(GetProcessHeap(), 0, dwVersionDataLen
);
1996 if (GetFileVersionInfo(strFilename
, 0, dwVersionDataLen
, dlg
->pVersionData
)) {
2000 if (VerQueryValue(dlg
->pVersionData
, sBackSlash
, &pVal
, &nValLen
)) {
2001 if (nValLen
== sizeof(VS_FIXEDFILEINFO
)) {
2002 VS_FIXEDFILEINFO
* pFixedFileInfo
= (VS_FIXEDFILEINFO
*)pVal
;
2003 char buffer
[BUFFER_LEN
];
2005 sprintf(buffer
, "%d.%d.%d.%d",
2006 HIWORD(pFixedFileInfo
->dwFileVersionMS
), LOWORD(pFixedFileInfo
->dwFileVersionMS
),
2007 HIWORD(pFixedFileInfo
->dwFileVersionLS
), LOWORD(pFixedFileInfo
->dwFileVersionLS
));
2009 SetDlgItemTextA(hwnd
, IDC_STATIC_PROP_VERSION
, buffer
);
2013 /* Read the list of languages and code pages. */
2014 if (VerQueryValue(dlg
->pVersionData
, sTranslation
, &pVal
, &nValLen
)) {
2015 struct LANGANDCODEPAGE
* pTranslate
= (struct LANGANDCODEPAGE
*)pVal
;
2016 struct LANGANDCODEPAGE
* pEnd
= (struct LANGANDCODEPAGE
*)((LPBYTE
)pVal
+nValLen
);
2018 HWND hlbox
= GetDlgItem(hwnd
, IDC_LIST_PROP_VERSION_TYPES
);
2020 /* Read the file description for each language and code page. */
2021 for(; pTranslate
<pEnd
; ++pTranslate
) {
2024 for(p
=InfoStrings
; *p
; ++p
) {
2025 TCHAR subblock
[200];
2032 LPCSTR pInfoString
= *p
;
2034 MultiByteToWideChar(CP_ACP
, 0, pInfoString
, -1, infoStr
, 100);
2036 #define infoStr pInfoString
2038 wsprintf(subblock
, sStringFileInfo
, pTranslate
->wLanguage
, pTranslate
->wCodePage
, infoStr
);
2040 /* Retrieve file description for language and code page */
2041 if (VerQueryValue(dlg
->pVersionData
, subblock
, (PVOID
)&pTxt
, &nValLen
)) {
2042 int idx
= SendMessage(hlbox
, LB_ADDSTRING
, 0L, (LPARAM
)infoStr
);
2043 SendMessage(hlbox
, LB_SETITEMDATA
, idx
, (LPARAM
) pTxt
);
2048 SendMessage(hlbox
, LB_SETCURSEL
, 0, 0);
2050 PropDlg_DisplayValue(hlbox
, GetDlgItem(hwnd
,IDC_LIST_PROP_VERSION_VALUES
));
2056 static INT_PTR CALLBACK
PropertiesDialogDlgProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
2058 static struct PropertiesDialog
* dlg
;
2061 case WM_INITDIALOG
: {
2062 static const TCHAR sByteFmt
[] = {'%','s',' ','B','y','t','e','s','\0'};
2063 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
2064 LPWIN32_FIND_DATA pWFD
;
2067 dlg
= (struct PropertiesDialog
*) lparam
;
2068 pWFD
= (LPWIN32_FIND_DATA
) &dlg
->entry
.data
;
2070 GetWindowText(hwnd
, b1
, MAX_PATH
);
2071 wsprintf(b2
, b1
, pWFD
->cFileName
);
2072 SetWindowText(hwnd
, b2
);
2074 format_date(&pWFD
->ftLastWriteTime
, b1
, COL_DATE
|COL_TIME
);
2075 SetWindowText(GetDlgItem(hwnd
, IDC_STATIC_PROP_LASTCHANGE
), b1
);
2077 size
= ((ULONGLONG
)pWFD
->nFileSizeHigh
<< 32) | pWFD
->nFileSizeLow
;
2078 _stprintf(b1
, sLongNumFmt
, size
);
2079 wsprintf(b2
, sByteFmt
, b1
);
2080 SetWindowText(GetDlgItem(hwnd
, IDC_STATIC_PROP_SIZE
), b2
);
2082 SetWindowText(GetDlgItem(hwnd
, IDC_STATIC_PROP_FILENAME
), pWFD
->cFileName
);
2083 SetWindowText(GetDlgItem(hwnd
, IDC_STATIC_PROP_PATH
), dlg
->path
);
2085 set_check(hwnd
, IDC_CHECK_READONLY
, pWFD
->dwFileAttributes
&FILE_ATTRIBUTE_READONLY
);
2086 set_check(hwnd
, IDC_CHECK_ARCHIVE
, pWFD
->dwFileAttributes
&FILE_ATTRIBUTE_ARCHIVE
);
2087 set_check(hwnd
, IDC_CHECK_COMPRESSED
, pWFD
->dwFileAttributes
&FILE_ATTRIBUTE_COMPRESSED
);
2088 set_check(hwnd
, IDC_CHECK_HIDDEN
, pWFD
->dwFileAttributes
&FILE_ATTRIBUTE_HIDDEN
);
2089 set_check(hwnd
, IDC_CHECK_SYSTEM
, pWFD
->dwFileAttributes
&FILE_ATTRIBUTE_SYSTEM
);
2091 CheckForFileInfo(dlg
, hwnd
, dlg
->path
);
2095 int id
= (int)wparam
;
2097 switch(HIWORD(wparam
)) {
2098 case LBN_SELCHANGE
: {
2099 HWND hlbox
= GetDlgItem(hwnd
, IDC_LIST_PROP_VERSION_TYPES
);
2100 PropDlg_DisplayValue(hlbox
, GetDlgItem(hwnd
,IDC_LIST_PROP_VERSION_VALUES
));
2105 if (id
==IDOK
|| id
==IDCANCEL
)
2106 EndDialog(hwnd
, id
);
2112 HeapFree(GetProcessHeap(), 0, dlg
->pVersionData
);
2113 dlg
->pVersionData
= NULL
;
2120 static void show_properties_dlg(Entry
* entry
, HWND hwnd
)
2122 struct PropertiesDialog dlg
;
2124 memset(&dlg
, 0, sizeof(struct PropertiesDialog
));
2125 get_path(entry
, dlg
.path
);
2126 memcpy(&dlg
.entry
, entry
, sizeof(Entry
));
2128 DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_DIALOG_PROPERTIES
), hwnd
, PropertiesDialogDlgProc
, (LPARAM
)&dlg
);
2132 #ifndef _NO_EXTENSIONS
2134 static struct FullScreenParameters
{
2144 static void frame_get_clientspace(HWND hwnd
, PRECT prect
)
2148 if (!IsIconic(hwnd
))
2149 GetClientRect(hwnd
, prect
);
2153 GetWindowPlacement(hwnd
, &wp
);
2155 prect
->left
= prect
->top
= 0;
2156 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
2157 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
2158 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
2159 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
2160 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
2163 if (IsWindowVisible(Globals
.htoolbar
)) {
2164 GetClientRect(Globals
.htoolbar
, &rt
);
2165 prect
->top
+= rt
.bottom
+2;
2168 if (IsWindowVisible(Globals
.hdrivebar
)) {
2169 GetClientRect(Globals
.hdrivebar
, &rt
);
2170 prect
->top
+= rt
.bottom
+2;
2173 if (IsWindowVisible(Globals
.hstatusbar
)) {
2174 GetClientRect(Globals
.hstatusbar
, &rt
);
2175 prect
->bottom
-= rt
.bottom
;
2179 static BOOL
toggle_fullscreen(HWND hwnd
)
2183 if ((g_fullscreen
.mode
=!g_fullscreen
.mode
)) {
2184 GetWindowRect(hwnd
, &g_fullscreen
.orgPos
);
2185 g_fullscreen
.wasZoomed
= IsZoomed(hwnd
);
2187 Frame_CalcFrameClient(hwnd
, &rt
);
2188 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
2189 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
2191 rt
.left
= g_fullscreen
.orgPos
.left
-rt
.left
;
2192 rt
.top
= g_fullscreen
.orgPos
.top
-rt
.top
;
2193 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+g_fullscreen
.orgPos
.right
-rt
.right
;
2194 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+g_fullscreen
.orgPos
.bottom
-rt
.bottom
;
2196 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
2198 MoveWindow(hwnd
, g_fullscreen
.orgPos
.left
, g_fullscreen
.orgPos
.top
,
2199 g_fullscreen
.orgPos
.right
-g_fullscreen
.orgPos
.left
,
2200 g_fullscreen
.orgPos
.bottom
-g_fullscreen
.orgPos
.top
, TRUE
);
2202 if (g_fullscreen
.wasZoomed
)
2203 ShowWindow(hwnd
, WS_MAXIMIZE
);
2206 return g_fullscreen
.mode
;
2209 static void fullscreen_move(HWND hwnd
)
2212 GetWindowRect(hwnd
, &pos
);
2214 Frame_CalcFrameClient(hwnd
, &rt
);
2215 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
2216 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
2218 rt
.left
= pos
.left
-rt
.left
;
2219 rt
.top
= pos
.top
-rt
.top
;
2220 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
2221 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
2223 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
2229 static void toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
)
2231 BOOL vis
= IsWindowVisible(hchild
);
2233 CheckMenuItem(Globals
.hMenuOptions
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
2235 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
2237 #ifndef _NO_EXTENSIONS
2238 if (g_fullscreen
.mode
)
2239 fullscreen_move(hwnd
);
2242 resize_frame_client(hwnd
);
2245 static BOOL
activate_drive_window(LPCTSTR path
)
2247 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
2250 _tsplitpath(path
, drv1
, 0, 0, 0);
2252 /* search for a already open window for the same drive */
2253 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
2254 ChildWnd
* child
= (ChildWnd
*) GetWindowLongPtr(child_wnd
, GWLP_USERDATA
);
2257 _tsplitpath(child
->root
.path
, drv2
, 0, 0, 0);
2259 if (!lstrcmpi(drv2
, drv1
)) {
2260 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
2262 if (IsIconic(child_wnd
))
2263 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
2273 static BOOL
activate_fs_window(LPCTSTR filesys
)
2277 /* search for a already open window of the given file system name */
2278 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
2279 ChildWnd
* child
= (ChildWnd
*) GetWindowLongPtr(child_wnd
, GWLP_USERDATA
);
2282 if (!lstrcmpi(child
->root
.fs
, filesys
)) {
2283 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
2285 if (IsIconic(child_wnd
))
2286 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
2296 static LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
2298 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
2302 if (Globals
.saveSettings
)
2303 save_registry_settings();
2305 DestroyWindow(hwnd
);
2307 /* clear handle variables */
2308 Globals
.hMenuFrame
= 0;
2309 Globals
.hMenuView
= 0;
2310 Globals
.hMenuOptions
= 0;
2311 Globals
.hMainWnd
= 0;
2312 Globals
.hmdiclient
= 0;
2313 Globals
.hdrivebar
= 0;
2320 case WM_INITMENUPOPUP
: {
2321 HWND hwndClient
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
2323 if (!SendMessage(hwndClient
, WM_INITMENUPOPUP
, wparam
, lparam
))
2328 UINT cmd
= LOWORD(wparam
);
2329 HWND hwndClient
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
2331 if (SendMessage(hwndClient
, WM_DISPATCH_COMMAND
, wparam
, lparam
))
2334 if (cmd
>=ID_DRIVE_FIRST
&& cmd
<=ID_DRIVE_FIRST
+0xFF) {
2335 TCHAR drv
[_MAX_DRIVE
], path
[MAX_PATH
];
2337 LPCTSTR root
= Globals
.drives
;
2340 for(i
=cmd
-ID_DRIVE_FIRST
; i
--; root
++)
2344 if (activate_drive_window(root
))
2347 _tsplitpath(root
, drv
, 0, 0, 0);
2349 if (!SetCurrentDirectory(drv
)) {
2350 display_error(hwnd
, GetLastError());
2354 GetCurrentDirectory(MAX_PATH
, path
); /*TODO: store last directory per drive */
2355 child
= alloc_child_window(path
, NULL
, hwnd
);
2357 if (!create_child_window(child
))
2358 HeapFree(GetProcessHeap(), 0, child
);
2359 } else switch(cmd
) {
2361 SendMessage(hwnd
, WM_CLOSE
, 0, 0);
2364 case ID_WINDOW_NEW
: {
2365 TCHAR path
[MAX_PATH
];
2368 GetCurrentDirectory(MAX_PATH
, path
);
2369 child
= alloc_child_window(path
, NULL
, hwnd
);
2371 if (!create_child_window(child
))
2372 HeapFree(GetProcessHeap(), 0, child
);
2379 case ID_WINDOW_CASCADE
:
2380 SendMessage(Globals
.hmdiclient
, WM_MDICASCADE
, 0, 0);
2383 case ID_WINDOW_TILE_HORZ
:
2384 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
2387 case ID_WINDOW_TILE_VERT
:
2388 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
2391 case ID_WINDOW_ARRANGE
:
2392 SendMessage(Globals
.hmdiclient
, WM_MDIICONARRANGE
, 0, 0);
2395 case ID_SELECT_FONT
:
2399 case ID_VIEW_TOOL_BAR
:
2400 toggle_child(hwnd
, cmd
, Globals
.htoolbar
);
2403 case ID_VIEW_DRIVE_BAR
:
2404 toggle_child(hwnd
, cmd
, Globals
.hdrivebar
);
2407 case ID_VIEW_STATUSBAR
:
2408 toggle_child(hwnd
, cmd
, Globals
.hstatusbar
);
2411 case ID_VIEW_SAVESETTINGS
:
2412 Globals
.saveSettings
= !Globals
.saveSettings
;
2413 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_SAVESETTINGS
,
2414 Globals
.saveSettings
? MF_CHECKED
: MF_UNCHECKED
);
2418 struct ExecuteDialog dlg
;
2420 memset(&dlg
, 0, sizeof(struct ExecuteDialog
));
2422 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), hwnd
, ExecuteDialogDlgProc
, (LPARAM
)&dlg
) == IDOK
) {
2423 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
2425 if ((int)hinst
<= 32)
2426 display_error(hwnd
, GetLastError());
2430 case ID_CONNECT_NETWORK_DRIVE
: {
2431 DWORD ret
= WNetConnectionDialog(hwnd
, RESOURCETYPE_DISK
);
2432 if (ret
== NO_ERROR
)
2434 else if (ret
!= (DWORD
)-1) {
2435 if (ret
== ERROR_EXTENDED_ERROR
)
2436 display_network_error(hwnd
);
2438 display_error(hwnd
, ret
);
2442 case ID_DISCONNECT_NETWORK_DRIVE
: {
2443 DWORD ret
= WNetDisconnectDialog(hwnd
, RESOURCETYPE_DISK
);
2444 if (ret
== NO_ERROR
)
2446 else if (ret
!= (DWORD
)-1) {
2447 if (ret
== ERROR_EXTENDED_ERROR
)
2448 display_network_error(hwnd
);
2450 display_error(hwnd
, ret
);
2454 case ID_FORMAT_DISK
: {
2455 UINT sem_org
= SetErrorMode(0); /* Get the current Error Mode settings. */
2456 SetErrorMode(sem_org
& ~SEM_FAILCRITICALERRORS
); /* Force O/S to handle */
2457 SHFormatDrive(hwnd
, 0 /* A: */, SHFMT_ID_DEFAULT
, 0);
2458 SetErrorMode(sem_org
); /* Put it back the way it was. */
2462 WinHelp(hwnd
, RS(b1
,IDS_WINEFILE
), HELP_INDEX
, 0);
2465 #ifndef _NO_EXTENSIONS
2466 case ID_VIEW_FULLSCREEN
:
2467 CheckMenuItem(Globals
.hMenuOptions
, cmd
, toggle_fullscreen(hwnd
)?MF_CHECKED
:0);
2471 case ID_DRIVE_UNIX_FS
: {
2472 TCHAR path
[MAX_PATH
];
2474 char cpath
[MAX_PATH
];
2478 if (activate_fs_window(RS(b1
,IDS_UNIXFS
)))
2482 getcwd(cpath
, MAX_PATH
);
2483 MultiByteToWideChar(CP_UNIXCP
, 0, cpath
, -1, path
, MAX_PATH
);
2485 getcwd(path
, MAX_PATH
);
2487 child
= alloc_child_window(path
, NULL
, hwnd
);
2489 if (!create_child_window(child
))
2490 HeapFree(GetProcessHeap(), 0, child
);
2493 #ifdef _SHELL_FOLDERS
2494 case ID_DRIVE_SHELL_NS
: {
2495 TCHAR path
[MAX_PATH
];
2498 if (activate_fs_window(RS(b1
,IDS_SHELL
)))
2501 GetCurrentDirectory(MAX_PATH
, path
);
2502 child
= alloc_child_window(path
, get_path_pidl(path
,hwnd
), hwnd
);
2504 if (!create_child_window(child
))
2505 HeapFree(GetProcessHeap(), 0, child
);
2510 /*TODO: There are even more menu items! */
2512 #ifndef _NO_EXTENSIONS
2515 WineLicense(Globals
.hMainWnd
);
2518 case ID_NO_WARRANTY
:
2519 WineWarranty(Globals
.hMainWnd
);
2523 ShellAbout(hwnd
, RS(b2
,IDS_WINE
), RS(b1
,IDS_WINEFILE
), 0);
2528 ShellAbout(hwnd
, RS(b1
,IDS_WINEFILE
), NULL
, 0);
2530 #endif /* _NO_EXTENSIONS */
2533 /*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE)
2534 STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE);
2535 else */if ((cmd
<IDW_FIRST_CHILD
|| cmd
>=IDW_FIRST_CHILD
+0x100) &&
2536 (cmd
<SC_SIZE
|| cmd
>SC_RESTORE
))
2537 MessageBox(hwnd
, RS(b2
,IDS_NO_IMPL
), RS(b1
,IDS_WINEFILE
), MB_OK
);
2539 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
2544 resize_frame(hwnd
, LOWORD(lparam
), HIWORD(lparam
));
2545 break; /* do not pass message to DefFrameProc */
2547 case WM_DEVICECHANGE
:
2548 SendMessage(hwnd
, WM_COMMAND
, MAKELONG(ID_REFRESH
,0), 0);
2551 #ifndef _NO_EXTENSIONS
2552 case WM_GETMINMAXINFO
: {
2553 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
2555 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
2556 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
2559 case FRM_CALC_CLIENT
:
2560 frame_get_clientspace(hwnd
, (PRECT
)lparam
);
2562 #endif /* _NO_EXTENSIONS */
2565 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
2572 static TCHAR g_pos_names
[COLUMNS
][20] = {
2576 static const int g_pos_align
[] = {
2578 HDF_LEFT
, /* Name */
2579 HDF_RIGHT
, /* Size */
2580 HDF_LEFT
, /* CDate */
2581 #ifndef _NO_EXTENSIONS
2582 HDF_LEFT
, /* ADate */
2583 HDF_LEFT
, /* MDate */
2584 HDF_LEFT
, /* Index */
2585 HDF_CENTER
, /* Links */
2587 HDF_CENTER
, /* Attributes */
2588 #ifndef _NO_EXTENSIONS
2589 HDF_LEFT
/* Security */
2593 static void resize_tree(ChildWnd
* child
, int cx
, int cy
)
2595 HDWP hdwp
= BeginDeferWindowPos(4);
2603 cx
= child
->split_pos
+ SPLIT_WIDTH
/2;
2605 #ifndef _NO_EXTENSIONS
2613 SendMessage(child
->left
.hwndHeader
, HDM_LAYOUT
, 0, (LPARAM
)&hdl
);
2615 DeferWindowPos(hdwp
, child
->left
.hwndHeader
, wp
.hwndInsertAfter
,
2616 wp
.x
-1, wp
.y
, child
->split_pos
-SPLIT_WIDTH
/2+1, wp
.cy
, wp
.flags
);
2617 DeferWindowPos(hdwp
, child
->right
.hwndHeader
, wp
.hwndInsertAfter
,
2618 rt
.left
+cx
+1, wp
.y
, wp
.cx
-cx
+2, wp
.cy
, wp
.flags
);
2620 #endif /* _NO_EXTENSIONS */
2622 DeferWindowPos(hdwp
, child
->left
.hwnd
, 0, rt
.left
, rt
.top
, child
->split_pos
-SPLIT_WIDTH
/2-rt
.left
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
2623 DeferWindowPos(hdwp
, child
->right
.hwnd
, 0, rt
.left
+cx
+1, rt
.top
, rt
.right
-cx
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
2625 EndDeferWindowPos(hdwp
);
2629 #ifndef _NO_EXTENSIONS
2631 static HWND
create_header(HWND parent
, Pane
* pane
, int id
)
2636 HWND hwnd
= CreateWindow(WC_HEADER
, 0, WS_CHILD
|WS_VISIBLE
|HDS_HORZ
|HDS_FULLDRAG
/*TODO: |HDS_BUTTONS + sort orders*/,
2637 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2641 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), FALSE
);
2643 hdi
.mask
= HDI_TEXT
|HDI_WIDTH
|HDI_FORMAT
;
2645 for(idx
=0; idx
<COLUMNS
; idx
++) {
2646 hdi
.pszText
= g_pos_names
[idx
];
2647 hdi
.fmt
= HDF_STRING
| g_pos_align
[idx
];
2648 hdi
.cxy
= pane
->widths
[idx
];
2649 SendMessage(hwnd
, HDM_INSERTITEM
, idx
, (LPARAM
) &hdi
);
2655 #endif /* _NO_EXTENSIONS */
2658 static void init_output(HWND hwnd
)
2660 static const WCHAR s1000
[] = {'1','0','0','0','\0'};
2663 HDC hdc
= GetDC(hwnd
);
2665 if (GetNumberFormatW(LOCALE_USER_DEFAULT
, 0, s1000
, 0, b
, 16) > 4)
2666 Globals
.num_sep
= b
[1];
2668 Globals
.num_sep
= '.';
2670 old_font
= SelectObject(hdc
, Globals
.hfont
);
2671 GetTextExtentPoint32W(hdc
, sSpace
, 1, &Globals
.spaceSize
);
2672 SelectObject(hdc
, old_font
);
2673 ReleaseDC(hwnd
, hdc
);
2676 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
);
2679 /* calculate preferred width for all visible columns */
2681 static BOOL
calc_widths(Pane
* pane
, BOOL anyway
)
2683 int col
, x
, cx
, spc
=3*Globals
.spaceSize
.cx
;
2684 int entries
= SendMessage(pane
->hwnd
, LB_GETCOUNT
, 0, 0);
2685 int orgWidths
[COLUMNS
];
2686 int orgPositions
[COLUMNS
+1];
2692 memcpy(orgWidths
, pane
->widths
, sizeof(orgWidths
));
2693 memcpy(orgPositions
, pane
->positions
, sizeof(orgPositions
));
2696 for(col
=0; col
<COLUMNS
; col
++)
2697 pane
->widths
[col
] = 0;
2699 hdc
= GetDC(pane
->hwnd
);
2700 hfontOld
= SelectObject(hdc
, Globals
.hfont
);
2702 for(cnt
=0; cnt
<entries
; cnt
++) {
2703 Entry
* entry
= (Entry
*) SendMessage(pane
->hwnd
, LB_GETITEMDATA
, cnt
, 0);
2712 dis
.hwndItem
= pane
->hwnd
;
2714 dis
.rcItem
.left
= 0;
2716 dis
.rcItem
.right
= 0;
2717 dis
.rcItem
.bottom
= 0;
2718 /*dis.itemData = 0; */
2720 draw_item(pane
, &dis
, entry
, COLUMNS
);
2723 SelectObject(hdc
, hfontOld
);
2724 ReleaseDC(pane
->hwnd
, hdc
);
2727 for(col
=0; col
<COLUMNS
; col
++) {
2728 pane
->positions
[col
] = x
;
2729 cx
= pane
->widths
[col
];
2734 if (cx
< IMAGE_WIDTH
)
2737 pane
->widths
[col
] = cx
;
2743 pane
->positions
[COLUMNS
] = x
;
2745 SendMessage(pane
->hwnd
, LB_SETHORIZONTALEXTENT
, x
, 0);
2748 if (!memcmp(orgWidths
, pane
->widths
, sizeof(orgWidths
)))
2751 /* don't move, if only collapsing an entry */
2752 if (!anyway
&& pane
->widths
[0]<orgWidths
[0] &&
2753 !memcmp(orgWidths
+1, pane
->widths
+1, sizeof(orgWidths
)-sizeof(int))) {
2754 pane
->widths
[0] = orgWidths
[0];
2755 memcpy(pane
->positions
, orgPositions
, sizeof(orgPositions
));
2760 InvalidateRect(pane
->hwnd
, 0, TRUE
);
2766 /* calculate one preferred column width */
2768 static void calc_single_width(Pane
* pane
, int col
)
2772 int entries
= SendMessage(pane
->hwnd
, LB_GETCOUNT
, 0, 0);
2776 pane
->widths
[col
] = 0;
2778 hdc
= GetDC(pane
->hwnd
);
2779 hfontOld
= SelectObject(hdc
, Globals
.hfont
);
2781 for(cnt
=0; cnt
<entries
; cnt
++) {
2782 Entry
* entry
= (Entry
*) SendMessage(pane
->hwnd
, LB_GETITEMDATA
, cnt
, 0);
2790 dis
.hwndItem
= pane
->hwnd
;
2792 dis
.rcItem
.left
= 0;
2794 dis
.rcItem
.right
= 0;
2795 dis
.rcItem
.bottom
= 0;
2796 /*dis.itemData = 0; */
2798 draw_item(pane
, &dis
, entry
, col
);
2801 SelectObject(hdc
, hfontOld
);
2802 ReleaseDC(pane
->hwnd
, hdc
);
2804 cx
= pane
->widths
[col
];
2807 cx
+= 3*Globals
.spaceSize
.cx
;
2809 if (cx
< IMAGE_WIDTH
)
2813 pane
->widths
[col
] = cx
;
2815 x
= pane
->positions
[col
] + cx
;
2817 for(; col
<COLUMNS
; ) {
2818 pane
->positions
[++col
] = x
;
2819 x
+= pane
->widths
[col
];
2822 SendMessage(pane
->hwnd
, LB_SETHORIZONTALEXTENT
, x
, 0);
2826 static BOOL
pattern_match(LPCTSTR str
, LPCTSTR pattern
)
2828 for( ; *str
&&*pattern
; str
++,pattern
++) {
2829 if (*pattern
== '*') {
2831 while(*pattern
== '*');
2837 if (*str
==*pattern
&& pattern_match(str
, pattern
))
2842 else if (*str
!=*pattern
&& *pattern
!='?')
2846 if (*str
|| *pattern
)
2847 if (*pattern
!='*' || pattern
[1]!='\0')
2853 static BOOL
pattern_imatch(LPCTSTR str
, LPCTSTR pattern
)
2855 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
2858 lstrcpy(b2
, pattern
);
2862 return pattern_match(b1
, b2
);
2872 static enum FILE_TYPE
get_file_type(LPCTSTR filename
);
2875 /* insert listbox entries after index idx */
2877 static int insert_entries(Pane
* pane
, Entry
* dir
, LPCTSTR pattern
, int filter_flags
, int idx
)
2884 ShowWindow(pane
->hwnd
, SW_HIDE
);
2886 for(; entry
; entry
=entry
->next
) {
2888 if (pane
->treePane
&& !(entry
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
2892 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
2893 /* don't display entries "." and ".." in the left pane */
2894 if (pane
->treePane
&& entry
->data
.cFileName
[0] == '.')
2896 #ifndef _NO_EXTENSIONS
2897 entry
->data
.cFileName
[1] == '\0' ||
2899 (entry
->data
.cFileName
[1] == '.' && entry
->data
.cFileName
[2] == '\0'))
2902 /* filter directories in right pane */
2903 if (!pane
->treePane
&& !(filter_flags
&TF_DIRECTORIES
))
2907 /* filter using the file name pattern */
2909 if (!pattern_imatch(entry
->data
.cFileName
, pattern
))
2912 /* filter system and hidden files */
2913 if (!(filter_flags
&TF_HIDDEN
) && (entry
->data
.dwFileAttributes
&(FILE_ATTRIBUTE_HIDDEN
|FILE_ATTRIBUTE_SYSTEM
)))
2916 /* filter looking at the file type */
2917 if ((filter_flags
&(TF_PROGRAMS
|TF_DOCUMENTS
|TF_OTHERS
)) != (TF_PROGRAMS
|TF_DOCUMENTS
|TF_OTHERS
))
2918 switch(get_file_type(entry
->data
.cFileName
)) {
2920 if (!(filter_flags
& TF_PROGRAMS
))
2925 if (!(filter_flags
& TF_DOCUMENTS
))
2929 default: /* TF_OTHERS */
2930 if (!(filter_flags
& TF_OTHERS
))
2937 SendMessage(pane
->hwnd
, LB_INSERTSTRING
, idx
, (LPARAM
) entry
);
2939 if (pane
->treePane
&& entry
->expanded
)
2940 idx
= insert_entries(pane
, entry
->down
, pattern
, filter_flags
, idx
);
2943 ShowWindow(pane
->hwnd
, SW_SHOW
);
2949 static void format_bytes(LPTSTR buffer
, LONGLONG bytes
)
2951 static const TCHAR sFmtGB
[] = {'%', '.', '1', 'f', ' ', 'G', 'B', '\0'};
2952 static const TCHAR sFmtMB
[] = {'%', '.', '1', 'f', ' ', 'M', 'B', '\0'};
2953 static const TCHAR sFmtkB
[] = {'%', '.', '1', 'f', ' ', 'k', 'B', '\0'};
2955 float fBytes
= (float)bytes
;
2957 if (bytes
>= 1073741824) /* 1 GB */
2958 _stprintf(buffer
, sFmtGB
, fBytes
/1073741824.f
+.5f
);
2959 else if (bytes
>= 1048576) /* 1 MB */
2960 _stprintf(buffer
, sFmtMB
, fBytes
/1048576.f
+.5f
);
2961 else if (bytes
>= 1024) /* 1 kB */
2962 _stprintf(buffer
, sFmtkB
, fBytes
/1024.f
+.5f
);
2964 _stprintf(buffer
, sLongNumFmt
, bytes
);
2967 static void set_space_status(void)
2969 ULARGE_INTEGER ulFreeBytesToCaller
, ulTotalBytes
, ulFreeBytes
;
2970 TCHAR fmt
[64], b1
[64], b2
[64], buffer
[BUFFER_LEN
];
2972 if (GetDiskFreeSpaceEx(NULL
, &ulFreeBytesToCaller
, &ulTotalBytes
, &ulFreeBytes
)) {
2973 format_bytes(b1
, ulFreeBytesToCaller
.QuadPart
);
2974 format_bytes(b2
, ulTotalBytes
.QuadPart
);
2975 wsprintf(buffer
, RS(fmt
,IDS_FREE_SPACE_FMT
), b1
, b2
);
2977 lstrcpy(buffer
, sQMarks
);
2979 SendMessage(Globals
.hstatusbar
, SB_SETTEXT
, 0, (LPARAM
)buffer
);
2983 static WNDPROC g_orgTreeWndProc
;
2985 static void create_tree_window(HWND parent
, Pane
* pane
, int id
, int id_header
, LPCTSTR pattern
, int filter_flags
)
2987 static const TCHAR sListBox
[] = {'L','i','s','t','B','o','x','\0'};
2989 static int s_init
= 0;
2990 Entry
* entry
= pane
->root
;
2992 pane
->hwnd
= CreateWindow(sListBox
, sEmpty
, WS_CHILD
|WS_VISIBLE
|WS_HSCROLL
|WS_VSCROLL
|
2993 LBS_DISABLENOSCROLL
|LBS_NOINTEGRALHEIGHT
|LBS_OWNERDRAWFIXED
|LBS_NOTIFY
,
2994 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2996 SetWindowLongPtr(pane
->hwnd
, GWLP_USERDATA
, (LPARAM
)pane
);
2997 g_orgTreeWndProc
= (WNDPROC
) SetWindowLongPtr(pane
->hwnd
, GWLP_WNDPROC
, (LPARAM
)TreeWndProc
);
2999 SendMessage(pane
->hwnd
, WM_SETFONT
, (WPARAM
)Globals
.hfont
, FALSE
);
3001 /* insert entries into listbox */
3003 insert_entries(pane
, entry
, pattern
, filter_flags
, -1);
3005 /* calculate column widths */
3008 init_output(pane
->hwnd
);
3011 calc_widths(pane
, TRUE
);
3013 #ifndef _NO_EXTENSIONS
3014 pane
->hwndHeader
= create_header(parent
, pane
, id_header
);
3019 static void InitChildWindow(ChildWnd
* child
)
3021 create_tree_window(child
->hwnd
, &child
->left
, IDW_TREE_LEFT
, IDW_HEADER_LEFT
, NULL
, TF_ALL
);
3022 create_tree_window(child
->hwnd
, &child
->right
, IDW_TREE_RIGHT
, IDW_HEADER_RIGHT
, child
->filter_pattern
, child
->filter_flags
);
3026 static void format_date(const FILETIME
* ft
, TCHAR
* buffer
, int visible_cols
)
3034 if (!ft
->dwLowDateTime
&& !ft
->dwHighDateTime
)
3037 if (!FileTimeToLocalFileTime(ft
, &lft
))
3038 {err
: lstrcpy(buffer
,sQMarks
); return;}
3040 if (!FileTimeToSystemTime(&lft
, &systime
))
3043 if (visible_cols
& COL_DATE
) {
3044 len
= GetDateFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
, BUFFER_LEN
);
3049 if (visible_cols
& COL_TIME
) {
3051 buffer
[len
-1] = ' ';
3053 buffer
[len
++] = ' ';
3055 if (!GetTimeFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
+len
, BUFFER_LEN
-len
))
3061 static void calc_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
3063 RECT rt
= {0, 0, 0, 0};
3065 DrawText(dis
->hDC
, str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
3067 if (rt
.right
> pane
->widths
[col
])
3068 pane
->widths
[col
] = rt
.right
;
3071 static void calc_tabbed_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
3073 RECT rt
= {0, 0, 0, 0};
3075 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
3076 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
3078 DrawText(dis
->hDC
, str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
3079 /*FIXME rt (0,0) ??? */
3081 if (rt
.right
> pane
->widths
[col
])
3082 pane
->widths
[col
] = rt
.right
;
3086 static void output_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
, DWORD flags
)
3088 int x
= dis
->rcItem
.left
;
3091 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
3092 rt
.top
= dis
->rcItem
.top
;
3093 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
3094 rt
.bottom
= dis
->rcItem
.bottom
;
3096 DrawText(dis
->hDC
, str
, -1, &rt
, DT_SINGLELINE
|DT_NOPREFIX
|flags
);
3099 static void output_tabbed_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
3101 int x
= dis
->rcItem
.left
;
3104 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
3105 rt
.top
= dis
->rcItem
.top
;
3106 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
3107 rt
.bottom
= dis
->rcItem
.bottom
;
3109 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
3110 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
3112 DrawText(dis
->hDC
, str
, -1, &rt
, DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
3115 static void output_number(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
3117 int x
= dis
->rcItem
.left
;
3124 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
3125 rt
.top
= dis
->rcItem
.top
;
3126 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
3127 rt
.bottom
= dis
->rcItem
.bottom
;
3132 /* insert number separator characters */
3133 pos
= lstrlen(s
) % 3;
3139 *d
++ = Globals
.num_sep
;
3143 DrawText(dis
->hDC
, b
, d
-b
, &rt
, DT_RIGHT
|DT_SINGLELINE
|DT_NOPREFIX
|DT_END_ELLIPSIS
);
3147 static BOOL
is_exe_file(LPCTSTR ext
)
3149 static const TCHAR executable_extensions
[][4] = {
3154 #ifndef _NO_EXTENSIONS
3158 #endif /* _NO_EXTENSIONS */
3162 TCHAR ext_buffer
[_MAX_EXT
];
3163 const TCHAR (*p
)[4];
3167 for(s
=ext
+1,d
=ext_buffer
; (*d
=tolower(*s
)); s
++)
3170 for(p
=executable_extensions
; (*p
)[0]; p
++)
3171 if (!lstrcmpi(ext_buffer
, *p
))
3177 static BOOL
is_registered_type(LPCTSTR ext
)
3179 /* check if there exists a classname for this file extension in the registry */
3180 if (!RegQueryValue(HKEY_CLASSES_ROOT
, ext
, NULL
, NULL
))
3186 static enum FILE_TYPE
get_file_type(LPCTSTR filename
)
3188 LPCTSTR ext
= _tcsrchr(filename
, '.');
3192 if (is_exe_file(ext
))
3193 return FT_EXECUTABLE
;
3194 else if (is_registered_type(ext
))
3201 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
)
3203 TCHAR buffer
[BUFFER_LEN
];
3205 int visible_cols
= pane
->visible_cols
;
3206 COLORREF bkcolor
, textcolor
;
3207 RECT focusRect
= dis
->rcItem
;
3214 attrs
= entry
->data
.dwFileAttributes
;
3216 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) {
3217 if (entry
->data
.cFileName
[0] == '.' && entry
->data
.cFileName
[1] == '.'
3218 && entry
->data
.cFileName
[2] == '\0')
3219 img
= IMG_FOLDER_UP
;
3220 #ifndef _NO_EXTENSIONS
3221 else if (entry
->data
.cFileName
[0] == '.' && entry
->data
.cFileName
[1] == '\0')
3222 img
= IMG_FOLDER_CUR
;
3225 #ifdef _NO_EXTENSIONS
3228 (pane
->treePane
&& (dis
->itemState
&ODS_FOCUS
)))
3229 img
= IMG_OPEN_FOLDER
;
3233 switch(get_file_type(entry
->data
.cFileName
)) {
3234 case FT_EXECUTABLE
: img
= IMG_EXECUTABLE
; break;
3235 case FT_DOCUMENT
: img
= IMG_DOCUMENT
; break;
3236 default: img
= IMG_FILE
;
3244 if (pane
->treePane
) {
3246 img_pos
= dis
->rcItem
.left
+ entry
->level
*(IMAGE_WIDTH
+TREE_LINE_DX
);
3248 if (calcWidthCol
== -1) {
3250 int y
= dis
->rcItem
.top
+ IMAGE_HEIGHT
/2;
3253 HRGN hrgn_org
= CreateRectRgn(0, 0, 0, 0);
3256 rt_clip
.left
= dis
->rcItem
.left
;
3257 rt_clip
.top
= dis
->rcItem
.top
;
3258 rt_clip
.right
= dis
->rcItem
.left
+pane
->widths
[col
];
3259 rt_clip
.bottom
= dis
->rcItem
.bottom
;
3261 hrgn
= CreateRectRgnIndirect(&rt_clip
);
3263 if (!GetClipRgn(dis
->hDC
, hrgn_org
)) {
3264 DeleteObject(hrgn_org
);
3268 /* HGDIOBJ holdPen = SelectObject(dis->hDC, GetStockObject(BLACK_PEN)); */
3269 ExtSelectClipRgn(dis
->hDC
, hrgn
, RGN_AND
);
3272 if ((up
=entry
->up
) != NULL
) {
3273 MoveToEx(dis
->hDC
, img_pos
-IMAGE_WIDTH
/2, y
, 0);
3274 LineTo(dis
->hDC
, img_pos
-2, y
);
3276 x
= img_pos
- IMAGE_WIDTH
/2;
3279 x
-= IMAGE_WIDTH
+TREE_LINE_DX
;
3283 && (up
->next
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
3286 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
3287 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
3289 } while((up
=up
->up
) != NULL
);
3292 x
= img_pos
- IMAGE_WIDTH
/2;
3294 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
3295 LineTo(dis
->hDC
, x
, y
);
3299 && (entry
->next
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
)
3302 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
3304 SelectClipRgn(dis
->hDC
, hrgn_org
);
3305 if (hrgn_org
) DeleteObject(hrgn_org
);
3306 /* SelectObject(dis->hDC, holdPen); */
3307 } else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
) {
3308 int right
= img_pos
+ IMAGE_WIDTH
- TREE_LINE_DX
;
3310 if (right
> pane
->widths
[col
])
3311 pane
->widths
[col
] = right
;
3314 img_pos
= dis
->rcItem
.left
;
3317 img_pos
= dis
->rcItem
.left
;
3319 if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3320 pane
->widths
[col
] = IMAGE_WIDTH
;
3323 if (calcWidthCol
== -1) {
3324 focusRect
.left
= img_pos
-2;
3326 #ifdef _NO_EXTENSIONS
3327 if (pane
->treePane
&& entry
) {
3330 DrawText(dis
->hDC
, entry
->data
.cFileName
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
3332 focusRect
.right
= dis
->rcItem
.left
+pane
->positions
[col
+1]+TREE_LINE_DX
+ rt
.right
+2;
3336 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
)
3337 textcolor
= COLOR_COMPRESSED
;
3339 #endif /* _NO_EXTENSIONS */
3340 textcolor
= RGB(0,0,0);
3342 if (dis
->itemState
& ODS_FOCUS
) {
3343 textcolor
= RGB(255,255,255);
3344 bkcolor
= COLOR_SELECTION
;
3346 bkcolor
= RGB(255,255,255);
3349 hbrush
= CreateSolidBrush(bkcolor
);
3350 FillRect(dis
->hDC
, &focusRect
, hbrush
);
3351 DeleteObject(hbrush
);
3353 SetBkMode(dis
->hDC
, TRANSPARENT
);
3354 SetTextColor(dis
->hDC
, textcolor
);
3356 cx
= pane
->widths
[col
];
3358 if (cx
&& img
!=IMG_NONE
) {
3359 if (cx
> IMAGE_WIDTH
)
3362 #ifdef _SHELL_FOLDERS
3363 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
3364 DrawIconEx(dis
->hDC
, img_pos
, dis
->rcItem
.top
, entry
->hicon
, cx
, GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
3367 ImageList_DrawEx(Globals
.himl
, img
, dis
->hDC
,
3368 img_pos
, dis
->rcItem
.top
, cx
,
3369 IMAGE_HEIGHT
, bkcolor
, CLR_DEFAULT
, ILD_NORMAL
);
3376 #ifdef _NO_EXTENSIONS
3377 if (img
>= IMG_FOLDER_UP
)
3383 /* ouput file name */
3384 if (calcWidthCol
== -1)
3385 output_text(pane
, dis
, col
, entry
->data
.cFileName
, 0);
3386 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3387 calc_width(pane
, dis
, col
, entry
->data
.cFileName
);
3391 #ifdef _NO_EXTENSIONS
3392 if (!pane
->treePane
) {
3395 /* display file size */
3396 if (visible_cols
& COL_SIZE
) {
3397 #ifdef _NO_EXTENSIONS
3398 if (!(attrs
&FILE_ATTRIBUTE_DIRECTORY
))
3403 size
= ((ULONGLONG
)entry
->data
.nFileSizeHigh
<< 32) | entry
->data
.nFileSizeLow
;
3405 _stprintf(buffer
, sLongNumFmt
, size
);
3407 if (calcWidthCol
== -1)
3408 output_number(pane
, dis
, col
, buffer
);
3409 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3410 calc_width(pane
, dis
, col
, buffer
);/*TODO: not ever time enough */
3416 /* display file date */
3417 if (visible_cols
& (COL_DATE
|COL_TIME
)) {
3418 #ifndef _NO_EXTENSIONS
3419 format_date(&entry
->data
.ftCreationTime
, buffer
, visible_cols
);
3420 if (calcWidthCol
== -1)
3421 output_text(pane
, dis
, col
, buffer
, 0);
3422 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3423 calc_width(pane
, dis
, col
, buffer
);
3426 format_date(&entry
->data
.ftLastAccessTime
, buffer
, visible_cols
);
3427 if (calcWidthCol
== -1)
3428 output_text(pane
, dis
, col
, buffer
, 0);
3429 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3430 calc_width(pane
, dis
, col
, buffer
);
3432 #endif /* _NO_EXTENSIONS */
3434 format_date(&entry
->data
.ftLastWriteTime
, buffer
, visible_cols
);
3435 if (calcWidthCol
== -1)
3436 output_text(pane
, dis
, col
, buffer
, 0);
3437 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3438 calc_width(pane
, dis
, col
, buffer
);
3442 #ifndef _NO_EXTENSIONS
3443 if (entry
->bhfi_valid
) {
3444 ULONGLONG index
= ((ULONGLONG
)entry
->bhfi
.nFileIndexHigh
<< 32) | entry
->bhfi
.nFileIndexLow
;
3446 if (visible_cols
& COL_INDEX
) {
3447 _stprintf(buffer
, sLongHexFmt
, index
);
3449 if (calcWidthCol
== -1)
3450 output_text(pane
, dis
, col
, buffer
, DT_RIGHT
);
3451 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3452 calc_width(pane
, dis
, col
, buffer
);
3457 if (visible_cols
& COL_LINKS
) {
3458 wsprintf(buffer
, sNumFmt
, entry
->bhfi
.nNumberOfLinks
);
3460 if (calcWidthCol
== -1)
3461 output_text(pane
, dis
, col
, buffer
, DT_CENTER
);
3462 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3463 calc_width(pane
, dis
, col
, buffer
);
3469 #endif /* _NO_EXTENSIONS */
3471 /* show file attributes */
3472 if (visible_cols
& COL_ATTRIBUTES
) {
3473 #ifdef _NO_EXTENSIONS
3474 static const TCHAR s4Tabs
[] = {' ','\t',' ','\t',' ','\t',' ','\t',' ','\0'};
3475 lstrcpy(buffer
, s4Tabs
);
3477 static const TCHAR s11Tabs
[] = {' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\0'};
3478 lstrcpy(buffer
, s11Tabs
);
3481 if (attrs
& FILE_ATTRIBUTE_NORMAL
) buffer
[ 0] = 'N';
3483 if (attrs
& FILE_ATTRIBUTE_READONLY
) buffer
[ 2] = 'R';
3484 if (attrs
& FILE_ATTRIBUTE_HIDDEN
) buffer
[ 4] = 'H';
3485 if (attrs
& FILE_ATTRIBUTE_SYSTEM
) buffer
[ 6] = 'S';
3486 if (attrs
& FILE_ATTRIBUTE_ARCHIVE
) buffer
[ 8] = 'A';
3487 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
) buffer
[10] = 'C';
3488 #ifndef _NO_EXTENSIONS
3489 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) buffer
[12] = 'D';
3490 if (attrs
& FILE_ATTRIBUTE_ENCRYPTED
) buffer
[14] = 'E';
3491 if (attrs
& FILE_ATTRIBUTE_TEMPORARY
) buffer
[16] = 'T';
3492 if (attrs
& FILE_ATTRIBUTE_SPARSE_FILE
) buffer
[18] = 'P';
3493 if (attrs
& FILE_ATTRIBUTE_REPARSE_POINT
) buffer
[20] = 'Q';
3494 if (attrs
& FILE_ATTRIBUTE_OFFLINE
) buffer
[22] = 'O';
3495 if (attrs
& FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
) buffer
[24] = 'X';
3496 #endif /* _NO_EXTENSIONS */
3499 if (calcWidthCol
== -1)
3500 output_tabbed_text(pane
, dis
, col
, buffer
);
3501 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3502 calc_tabbed_width(pane
, dis
, col
, buffer
);
3508 if (flags.security) {
3509 static const TCHAR sSecTabs[] = {
3510 ' ','\t',' ','\t',' ','\t',' ',
3512 ' ','\t',' ','\t',' ','\t',' ',
3514 ' ','\t',' ','\t',' ','\t',' ',
3518 DWORD rights = get_access_mask();
3520 lstrcpy(buffer, sSecTabs);
3522 if (rights & FILE_READ_DATA) buffer[ 0] = 'R';
3523 if (rights & FILE_WRITE_DATA) buffer[ 2] = 'W';
3524 if (rights & FILE_APPEND_DATA) buffer[ 4] = 'A';
3525 if (rights & FILE_READ_EA) {buffer[6] = 'entry'; buffer[ 7] = 'R';}
3526 if (rights & FILE_WRITE_EA) {buffer[9] = 'entry'; buffer[10] = 'W';}
3527 if (rights & FILE_EXECUTE) buffer[12] = 'X';
3528 if (rights & FILE_DELETE_CHILD) buffer[14] = 'D';
3529 if (rights & FILE_READ_ATTRIBUTES) {buffer[16] = 'a'; buffer[17] = 'R';}
3530 if (rights & FILE_WRITE_ATTRIBUTES) {buffer[19] = 'a'; buffer[20] = 'W';}
3531 if (rights & WRITE_DAC) buffer[22] = 'C';
3532 if (rights & WRITE_OWNER) buffer[24] = 'O';
3533 if (rights & SYNCHRONIZE) buffer[26] = 'S';
3535 output_text(dis, col++, buffer, DT_LEFT, 3, psize);
3538 if (flags.description) {
3539 get_description(buffer);
3540 output_text(dis, col++, buffer, 0, psize);
3544 #ifdef _NO_EXTENSIONS
3547 /* draw focus frame */
3548 if ((dis
->itemState
&ODS_FOCUS
) && calcWidthCol
==-1) {
3549 /* Currently [04/2000] Wine neither behaves exactly the same */
3550 /* way as WIN 95 nor like Windows NT... */
3555 if (!(GetVersion() & 0x80000000)) { /* Windows NT? */
3556 LOGBRUSH lb
= {PS_SOLID
, RGB(255,255,255)};
3557 hpen
= ExtCreatePen(PS_COSMETIC
|PS_ALTERNATE
, 1, &lb
, 0, 0);
3559 hpen
= CreatePen(PS_DOT
, 0, RGB(255,255,255));
3561 lastPen
= SelectPen(dis
->hDC
, hpen
);
3562 lastBrush
= SelectObject(dis
->hDC
, GetStockObject(HOLLOW_BRUSH
));
3563 SetROP2(dis
->hDC
, R2_XORPEN
);
3564 Rectangle(dis
->hDC
, focusRect
.left
, focusRect
.top
, focusRect
.right
, focusRect
.bottom
);
3565 SelectObject(dis
->hDC
, lastBrush
);
3566 SelectObject(dis
->hDC
, lastPen
);
3569 #endif /* _NO_EXTENSIONS */
3573 #ifdef _NO_EXTENSIONS
3575 static void draw_splitbar(HWND hwnd
, int x
)
3578 HDC hdc
= GetDC(hwnd
);
3580 GetClientRect(hwnd
, &rt
);
3582 rt
.left
= x
- SPLIT_WIDTH
/2;
3583 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
3585 InvertRect(hdc
, &rt
);
3587 ReleaseDC(hwnd
, hdc
);
3590 #endif /* _NO_EXTENSIONS */
3593 #ifndef _NO_EXTENSIONS
3595 static void set_header(Pane
* pane
)
3598 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
3601 item
.mask
= HDI_WIDTH
;
3604 for(; x
+pane
->widths
[i
]<scroll_pos
&& i
<COLUMNS
; i
++) {
3605 x
+= pane
->widths
[i
];
3606 SendMessage(pane
->hwndHeader
, HDM_SETITEM
, i
, (LPARAM
) &item
);
3610 x
+= pane
->widths
[i
];
3611 item
.cxy
= x
- scroll_pos
;
3612 SendMessage(pane
->hwndHeader
, HDM_SETITEM
, i
++, (LPARAM
) &item
);
3614 for(; i
<COLUMNS
; i
++) {
3615 item
.cxy
= pane
->widths
[i
];
3616 x
+= pane
->widths
[i
];
3617 SendMessage(pane
->hwndHeader
, HDM_SETITEM
, i
, (LPARAM
) &item
);
3622 static LRESULT
pane_notify(Pane
* pane
, NMHDR
* pnmh
)
3624 switch(pnmh
->code
) {
3625 case HDN_ITEMCHANGED
: {
3626 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
3627 int idx
= phdn
->iItem
;
3628 int dx
= phdn
->pitem
->cxy
- pane
->widths
[idx
];
3632 GetClientRect(pane
->hwnd
, &clnt
);
3634 pane
->widths
[idx
] += dx
;
3636 for(i
=idx
; ++i
<=COLUMNS
; )
3637 pane
->positions
[i
] += dx
;
3640 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
3644 rt_scr
.left
= pane
->positions
[idx
+1]-scroll_pos
;
3646 rt_scr
.right
= clnt
.right
;
3647 rt_scr
.bottom
= clnt
.bottom
;
3649 rt_clip
.left
= pane
->positions
[idx
]-scroll_pos
;
3651 rt_clip
.right
= clnt
.right
;
3652 rt_clip
.bottom
= clnt
.bottom
;
3654 if (rt_scr
.left
< 0) rt_scr
.left
= 0;
3655 if (rt_clip
.left
< 0) rt_clip
.left
= 0;
3657 ScrollWindowEx(pane
->hwnd
, dx
, 0, &rt_scr
, &rt_clip
, 0, 0, SW_INVALIDATE
);
3659 rt_clip
.right
= pane
->positions
[idx
+1];
3660 RedrawWindow(pane
->hwnd
, &rt_clip
, 0, RDW_INVALIDATE
|RDW_UPDATENOW
);
3662 if (pnmh
->code
== HDN_ENDTRACK
) {
3663 SendMessage(pane
->hwnd
, LB_SETHORIZONTALEXTENT
, pane
->positions
[COLUMNS
], 0);
3665 if (GetScrollPos(pane
->hwnd
, SB_HORZ
) != scroll_pos
)
3673 case HDN_DIVIDERDBLCLICK
: {
3674 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
3677 calc_single_width(pane
, phdn
->iItem
);
3678 item
.mask
= HDI_WIDTH
;
3679 item
.cxy
= pane
->widths
[phdn
->iItem
];
3681 SendMessage(pane
->hwndHeader
, HDM_SETITEM
, phdn
->iItem
, (LPARAM
) &item
);
3682 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3689 #endif /* _NO_EXTENSIONS */
3692 static void scan_entry(ChildWnd
* child
, Entry
* entry
, int idx
, HWND hwnd
)
3694 TCHAR path
[MAX_PATH
];
3695 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
3697 /* delete sub entries in left pane */
3699 LRESULT res
= SendMessage(child
->left
.hwnd
, LB_GETITEMDATA
, idx
+1, 0);
3700 Entry
* sub
= (Entry
*) res
;
3702 if (res
==LB_ERR
|| !sub
|| sub
->level
<=entry
->level
)
3705 SendMessage(child
->left
.hwnd
, LB_DELETESTRING
, idx
+1, 0);
3708 /* empty right pane */
3709 SendMessage(child
->right
.hwnd
, LB_RESETCONTENT
, 0, 0);
3711 /* release memory */
3712 free_entries(entry
);
3714 /* read contents from disk */
3715 #ifdef _SHELL_FOLDERS
3716 if (entry
->etype
== ET_SHELL
)
3718 read_directory(entry
, NULL
, child
->sortOrder
, hwnd
);
3723 get_path(entry
, path
);
3724 read_directory(entry
, path
, child
->sortOrder
, hwnd
);
3727 /* insert found entries in right pane */
3728 insert_entries(&child
->right
, entry
->down
, child
->filter_pattern
, child
->filter_flags
, -1);
3729 calc_widths(&child
->right
, FALSE
);
3730 #ifndef _NO_EXTENSIONS
3731 set_header(&child
->right
);
3734 child
->header_wdths_ok
= FALSE
;
3736 SetCursor(old_cursor
);
3740 /* expand a directory entry */
3742 static BOOL
expand_entry(ChildWnd
* child
, Entry
* dir
)
3747 if (!dir
|| dir
->expanded
|| !dir
->down
)
3752 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='\0' && p
->next
) {
3755 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='.' &&
3756 p
->data
.cFileName
[2]=='\0' && p
->next
)
3760 /* no subdirectories ? */
3761 if (!(p
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
3764 idx
= SendMessage(child
->left
.hwnd
, LB_FINDSTRING
, 0, (LPARAM
)dir
);
3766 dir
->expanded
= TRUE
;
3768 /* insert entries in left pane */
3769 insert_entries(&child
->left
, p
, NULL
, TF_ALL
, idx
);
3771 if (!child
->header_wdths_ok
) {
3772 if (calc_widths(&child
->left
, FALSE
)) {
3773 #ifndef _NO_EXTENSIONS
3774 set_header(&child
->left
);
3777 child
->header_wdths_ok
= TRUE
;
3785 static void collapse_entry(Pane
* pane
, Entry
* dir
)
3787 int idx
= SendMessage(pane
->hwnd
, LB_FINDSTRING
, 0, (LPARAM
)dir
);
3789 ShowWindow(pane
->hwnd
, SW_HIDE
);
3791 /* hide sub entries */
3793 LRESULT res
= SendMessage(pane
->hwnd
, LB_GETITEMDATA
, idx
+1, 0);
3794 Entry
* sub
= (Entry
*) res
;
3796 if (res
==LB_ERR
|| !sub
|| sub
->level
<=dir
->level
)
3799 SendMessage(pane
->hwnd
, LB_DELETESTRING
, idx
+1, 0);
3802 dir
->expanded
= FALSE
;
3804 ShowWindow(pane
->hwnd
, SW_SHOW
);
3808 static void refresh_right_pane(ChildWnd
* child
)
3810 SendMessage(child
->right
.hwnd
, LB_RESETCONTENT
, 0, 0);
3811 insert_entries(&child
->right
, child
->right
.root
, child
->filter_pattern
, child
->filter_flags
, -1);
3812 calc_widths(&child
->right
, FALSE
);
3814 #ifndef _NO_EXTENSIONS
3815 set_header(&child
->right
);
3819 static void set_curdir(ChildWnd
* child
, Entry
* entry
, int idx
, HWND hwnd
)
3821 TCHAR path
[MAX_PATH
];
3828 child
->left
.cur
= entry
;
3830 child
->right
.root
= entry
->down
? entry
->down
: entry
;
3831 child
->right
.cur
= entry
;
3833 if (!entry
->scanned
)
3834 scan_entry(child
, entry
, idx
, hwnd
);
3836 refresh_right_pane(child
);
3838 get_path(entry
, path
);
3839 lstrcpy(child
->path
, path
);
3841 if (child
->hwnd
) /* only change window title, if the window already exists */
3842 SetWindowText(child
->hwnd
, path
);
3845 if (SetCurrentDirectory(path
))
3850 static void refresh_child(ChildWnd
* child
)
3852 TCHAR path
[MAX_PATH
], drv
[_MAX_DRIVE
+1];
3856 get_path(child
->left
.cur
, path
);
3857 _tsplitpath(path
, drv
, NULL
, NULL
, NULL
);
3859 child
->right
.root
= NULL
;
3861 scan_entry(child
, &child
->root
.entry
, 0, child
->hwnd
);
3863 #ifdef _SHELL_FOLDERS
3864 if (child
->root
.entry
.etype
== ET_SHELL
)
3865 entry
= read_tree(&child
->root
, NULL
, get_path_pidl(path
,child
->hwnd
), drv
, child
->sortOrder
, child
->hwnd
);
3868 entry
= read_tree(&child
->root
, path
, NULL
, drv
, child
->sortOrder
, child
->hwnd
);
3871 entry
= &child
->root
.entry
;
3873 insert_entries(&child
->left
, child
->root
.entry
.down
, NULL
, TF_ALL
, 0);
3875 set_curdir(child
, entry
, 0, child
->hwnd
);
3877 idx
= SendMessage(child
->left
.hwnd
, LB_FINDSTRING
, 0, (LPARAM
)child
->left
.cur
);
3878 SendMessage(child
->left
.hwnd
, LB_SETCURSEL
, idx
, 0);
3882 static void create_drive_bar(void)
3884 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0};
3885 #ifndef _NO_EXTENSIONS
3886 TCHAR b1
[BUFFER_LEN
];
3891 GetLogicalDriveStrings(BUFFER_LEN
, Globals
.drives
);
3893 Globals
.hdrivebar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
3894 IDW_DRIVEBAR
, 2, Globals
.hInstance
, IDB_DRIVEBAR
, &drivebarBtn
,
3895 0, 16, 13, 16, 13, sizeof(TBBUTTON
));
3897 #ifndef _NO_EXTENSIONS
3899 /* insert unix file system button */
3903 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b1
);
3905 drivebarBtn
.idCommand
= ID_DRIVE_UNIX_FS
;
3906 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3907 drivebarBtn
.iString
++;
3909 #ifdef _SHELL_FOLDERS
3910 /* insert shell namespace button */
3911 load_string(b1
, IDS_SHELL
);
3912 b1
[lstrlen(b1
)+1] = '\0';
3913 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b1
);
3915 drivebarBtn
.idCommand
= ID_DRIVE_SHELL_NS
;
3916 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3917 drivebarBtn
.iString
++;
3920 /* register windows drive root strings */
3921 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)Globals
.drives
);
3924 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
3926 for(p
=Globals
.drives
; *p
; ) {
3927 #ifdef _NO_EXTENSIONS
3928 /* insert drive letter */
3929 TCHAR b
[3] = {tolower(*p
)};
3930 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b
);
3932 switch(GetDriveType(p
)) {
3933 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
3934 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
3935 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
3936 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
3937 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
3940 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3941 drivebarBtn
.idCommand
++;
3942 drivebarBtn
.iString
++;
3948 static void refresh_drives(void)
3952 /* destroy drive bar */
3953 DestroyWindow(Globals
.hdrivebar
);
3954 Globals
.hdrivebar
= 0;
3956 /* re-create drive bar */
3959 /* update window layout */
3960 GetClientRect(Globals
.hMainWnd
, &rect
);
3961 SendMessage(Globals
.hMainWnd
, WM_SIZE
, 0, MAKELONG(rect
.right
, rect
.bottom
));
3965 static BOOL
launch_file(HWND hwnd
, LPCTSTR cmd
, UINT nCmdShow
)
3967 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, cmd
, NULL
/*parameters*/, NULL
/*dir*/, nCmdShow
);
3969 if ((int)hinst
<= 32) {
3970 display_error(hwnd
, GetLastError());
3978 static BOOL
launch_entry(Entry
* entry
, HWND hwnd
, UINT nCmdShow
)
3980 TCHAR cmd
[MAX_PATH
];
3982 #ifdef _SHELL_FOLDERS
3983 if (entry
->etype
== ET_SHELL
) {
3986 SHELLEXECUTEINFO shexinfo
;
3988 shexinfo
.cbSize
= sizeof(SHELLEXECUTEINFO
);
3989 shexinfo
.fMask
= SEE_MASK_IDLIST
;
3990 shexinfo
.hwnd
= hwnd
;
3991 shexinfo
.lpVerb
= NULL
;
3992 shexinfo
.lpFile
= NULL
;
3993 shexinfo
.lpParameters
= NULL
;
3994 shexinfo
.lpDirectory
= NULL
;
3995 shexinfo
.nShow
= nCmdShow
;
3996 shexinfo
.lpIDList
= get_to_absolute_pidl(entry
, hwnd
);
3998 if (!ShellExecuteEx(&shexinfo
)) {
3999 display_error(hwnd
, GetLastError());
4003 if (shexinfo
.lpIDList
!= entry
->pidl
)
4004 IMalloc_Free(Globals
.iMalloc
, shexinfo
.lpIDList
);
4010 get_path(entry
, cmd
);
4012 /* start program, open document... */
4013 return launch_file(hwnd
, cmd
, nCmdShow
);
4017 static void activate_entry(ChildWnd
* child
, Pane
* pane
, HWND hwnd
)
4019 Entry
* entry
= pane
->cur
;
4024 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
4025 int scanned_old
= entry
->scanned
;
4029 int idx
= SendMessage(child
->left
.hwnd
, LB_GETCURSEL
, 0, 0);
4030 scan_entry(child
, entry
, idx
, hwnd
);
4033 #ifndef _NO_EXTENSIONS
4034 if (entry
->data
.cFileName
[0]=='.' && entry
->data
.cFileName
[1]=='\0')
4038 if (entry
->data
.cFileName
[0]=='.' && entry
->data
.cFileName
[1]=='.' && entry
->data
.cFileName
[2]=='\0') {
4039 entry
= child
->left
.cur
->up
;
4040 collapse_entry(&child
->left
, entry
);
4042 } else if (entry
->expanded
)
4043 collapse_entry(pane
, child
->left
.cur
);
4045 expand_entry(child
, child
->left
.cur
);
4047 if (!pane
->treePane
) focus_entry
: {
4048 int idxstart
= SendMessage(child
->left
.hwnd
, LB_GETCURSEL
, 0, 0);
4049 int idx
= SendMessage(child
->left
.hwnd
, LB_FINDSTRING
, idxstart
, (LPARAM
)entry
);
4050 SendMessage(child
->left
.hwnd
, LB_SETCURSEL
, idx
, 0);
4051 set_curdir(child
, entry
, idx
, hwnd
);
4056 calc_widths(pane
, FALSE
);
4058 #ifndef _NO_EXTENSIONS
4063 if (GetKeyState(VK_MENU
) < 0)
4064 show_properties_dlg(entry
, child
->hwnd
);
4066 launch_entry(entry
, child
->hwnd
, SW_SHOWNORMAL
);
4071 static BOOL
pane_command(Pane
* pane
, UINT cmd
)
4075 if (pane
->visible_cols
) {
4076 pane
->visible_cols
= 0;
4077 calc_widths(pane
, TRUE
);
4078 #ifndef _NO_EXTENSIONS
4081 InvalidateRect(pane
->hwnd
, 0, TRUE
);
4082 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
|MF_CHECKED
);
4083 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_ALL_ATTRIBUTES
, MF_BYCOMMAND
);
4084 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SELECTED_ATTRIBUTES
, MF_BYCOMMAND
);
4088 case ID_VIEW_ALL_ATTRIBUTES
:
4089 if (pane
->visible_cols
!= COL_ALL
) {
4090 pane
->visible_cols
= COL_ALL
;
4091 calc_widths(pane
, TRUE
);
4092 #ifndef _NO_EXTENSIONS
4095 InvalidateRect(pane
->hwnd
, 0, TRUE
);
4096 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
);
4097 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_ALL_ATTRIBUTES
, MF_BYCOMMAND
|MF_CHECKED
);
4098 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SELECTED_ATTRIBUTES
, MF_BYCOMMAND
);
4102 #ifndef _NO_EXTENSIONS
4103 case ID_PREFERRED_SIZES
: {
4104 calc_widths(pane
, TRUE
);
4106 InvalidateRect(pane
->hwnd
, 0, TRUE
);
4110 /* TODO: more command ids... */
4120 static void set_sort_order(ChildWnd
* child
, SORT_ORDER sortOrder
)
4122 if (child
->sortOrder
!= sortOrder
) {
4123 child
->sortOrder
= sortOrder
;
4124 refresh_child(child
);
4128 static void update_view_menu(ChildWnd
* child
)
4130 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SORT_NAME
, child
->sortOrder
==SORT_NAME
? MF_CHECKED
: MF_UNCHECKED
);
4131 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SORT_TYPE
, child
->sortOrder
==SORT_EXT
? MF_CHECKED
: MF_UNCHECKED
);
4132 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SORT_SIZE
, child
->sortOrder
==SORT_SIZE
? MF_CHECKED
: MF_UNCHECKED
);
4133 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SORT_DATE
, child
->sortOrder
==SORT_DATE
? MF_CHECKED
: MF_UNCHECKED
);
4137 static BOOL
is_directory(LPCTSTR target
)
4139 /*TODO correctly handle UNIX paths */
4140 DWORD target_attr
= GetFileAttributes(target
);
4142 if (target_attr
== INVALID_FILE_ATTRIBUTES
)
4145 return target_attr
&FILE_ATTRIBUTE_DIRECTORY
? TRUE
: FALSE
;
4148 static BOOL
prompt_target(Pane
* pane
, LPTSTR source
, LPTSTR target
)
4150 TCHAR path
[MAX_PATH
];
4153 get_path(pane
->cur
, path
);
4155 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_SELECT_DESTINATION
), pane
->hwnd
, DestinationDlgProc
, (LPARAM
)path
) != IDOK
)
4158 get_path(pane
->cur
, source
);
4160 /* convert relative targets to absolute paths */
4161 if (path
[0]!='/' && path
[1]!=':') {
4162 get_path(pane
->cur
->up
, target
);
4163 len
= lstrlen(target
);
4165 if (target
[len
-1]!='\\' && target
[len
-1]!='/')
4166 target
[len
++] = '/';
4168 lstrcpy(target
+len
, path
);
4170 lstrcpy(target
, path
);
4172 /* If the target already exists as directory, create a new target below this. */
4173 if (is_directory(path
)) {
4174 TCHAR fname
[_MAX_FNAME
], ext
[_MAX_EXT
];
4175 static const TCHAR sAppend
[] = {'%','s','/','%','s','%','s','\0'};
4177 _tsplitpath(source
, NULL
, NULL
, fname
, ext
);
4179 wsprintf(target
, sAppend
, path
, fname
, ext
);
4186 static IContextMenu2
* s_pctxmenu2
= NULL
;
4187 static IContextMenu3
* s_pctxmenu3
= NULL
;
4189 static void CtxMenu_reset(void)
4195 static IContextMenu
* CtxMenu_query_interfaces(IContextMenu
* pcm1
)
4197 IContextMenu
* pcm
= NULL
;
4201 if (IContextMenu_QueryInterface(pcm1
, &IID_IContextMenu3
, (void**)&pcm
) == NOERROR
)
4202 s_pctxmenu3
= (LPCONTEXTMENU3
)pcm
;
4203 else if (IContextMenu_QueryInterface(pcm1
, &IID_IContextMenu2
, (void**)&pcm
) == NOERROR
)
4204 s_pctxmenu2
= (LPCONTEXTMENU2
)pcm
;
4207 IContextMenu_Release(pcm1
);
4213 static BOOL
CtxMenu_HandleMenuMsg(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
4216 if (SUCCEEDED(IContextMenu3_HandleMenuMsg(s_pctxmenu3
, nmsg
, wparam
, lparam
)))
4221 if (SUCCEEDED(IContextMenu2_HandleMenuMsg(s_pctxmenu2
, nmsg
, wparam
, lparam
)))
4228 static HRESULT
ShellFolderContextMenu(IShellFolder
* shell_folder
, HWND hwndParent
, int cidl
, LPCITEMIDLIST
* apidl
, int x
, int y
)
4231 BOOL executed
= FALSE
;
4233 HRESULT hr
= IShellFolder_GetUIObjectOf(shell_folder
, hwndParent
, cidl
, apidl
, &IID_IContextMenu
, NULL
, (LPVOID
*)&pcm
);
4234 /* HRESULT hr = CDefFolderMenu_Create2(dir?dir->_pidl:DesktopFolder(), hwndParent, 1, &pidl, shell_folder, NULL, 0, NULL, &pcm); */
4236 if (SUCCEEDED(hr
)) {
4237 HMENU hmenu
= CreatePopupMenu();
4239 pcm
= CtxMenu_query_interfaces(pcm
);
4242 hr
= IContextMenu_QueryContextMenu(pcm
, hmenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, CMF_NORMAL
);
4244 if (SUCCEEDED(hr
)) {
4245 UINT idCmd
= TrackPopupMenu(hmenu
, TPM_LEFTALIGN
|TPM_RETURNCMD
|TPM_RIGHTBUTTON
, x
, y
, 0, hwndParent
, NULL
);
4250 CMINVOKECOMMANDINFO cmi
;
4252 cmi
.cbSize
= sizeof(CMINVOKECOMMANDINFO
);
4254 cmi
.hwnd
= hwndParent
;
4255 cmi
.lpVerb
= (LPCSTR
)(INT_PTR
)(idCmd
- FCIDM_SHVIEWFIRST
);
4256 cmi
.lpParameters
= NULL
;
4257 cmi
.lpDirectory
= NULL
;
4258 cmi
.nShow
= SW_SHOWNORMAL
;
4262 hr
= IContextMenu_InvokeCommand(pcm
, &cmi
);
4269 IContextMenu_Release(pcm
);
4272 return FAILED(hr
)? hr
: executed
? S_OK
: S_FALSE
;
4276 static LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
4278 ChildWnd
* child
= (ChildWnd
*) GetWindowLongPtr(hwnd
, GWLP_USERDATA
);
4283 LPDRAWITEMSTRUCT dis
= (LPDRAWITEMSTRUCT
)lparam
;
4284 Entry
* entry
= (Entry
*) dis
->itemData
;
4286 if (dis
->CtlID
== IDW_TREE_LEFT
)
4287 draw_item(&child
->left
, dis
, entry
, -1);
4288 else if (dis
->CtlID
== IDW_TREE_RIGHT
)
4289 draw_item(&child
->right
, dis
, entry
, -1);
4291 goto draw_menu_item
;
4296 InitChildWindow(child
);
4300 free_child_window(child
);
4301 SetWindowLongPtr(hwnd
, GWLP_USERDATA
, 0);
4308 GetClientRect(hwnd
, &rt
);
4309 BeginPaint(hwnd
, &ps
);
4310 rt
.left
= child
->split_pos
-SPLIT_WIDTH
/2;
4311 rt
.right
= child
->split_pos
+SPLIT_WIDTH
/2+1;
4312 lastBrush
= SelectObject(ps
.hdc
, GetStockObject(COLOR_SPLITBAR
));
4313 Rectangle(ps
.hdc
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
4314 SelectObject(ps
.hdc
, lastBrush
);
4315 #ifdef _NO_EXTENSIONS
4316 rt
.top
= rt
.bottom
- GetSystemMetrics(SM_CYHSCROLL
);
4317 FillRect(ps
.hdc
, &rt
, GetStockObject(BLACK_BRUSH
));
4319 EndPaint(hwnd
, &ps
);
4323 if (LOWORD(lparam
) == HTCLIENT
) {
4326 ScreenToClient(hwnd
, &pt
);
4328 if (pt
.x
>=child
->split_pos
-SPLIT_WIDTH
/2 && pt
.x
<child
->split_pos
+SPLIT_WIDTH
/2+1) {
4329 SetCursor(LoadCursor(0, IDC_SIZEWE
));
4335 case WM_LBUTTONDOWN
: {
4337 int x
= (short)LOWORD(lparam
);
4339 GetClientRect(hwnd
, &rt
);
4341 if (x
>=child
->split_pos
-SPLIT_WIDTH
/2 && x
<child
->split_pos
+SPLIT_WIDTH
/2+1) {
4342 last_split
= child
->split_pos
;
4343 #ifdef _NO_EXTENSIONS
4344 draw_splitbar(hwnd
, last_split
);
4352 if (GetCapture() == hwnd
) {
4353 #ifdef _NO_EXTENSIONS
4355 int x
= (short)LOWORD(lparam
);
4356 draw_splitbar(hwnd
, last_split
);
4358 GetClientRect(hwnd
, &rt
);
4359 child
->split_pos
= x
;
4360 resize_tree(child
, rt
.right
, rt
.bottom
);
4366 #ifdef _NO_EXTENSIONS
4367 case WM_CAPTURECHANGED
:
4368 if (GetCapture()==hwnd
&& last_split
>=0)
4369 draw_splitbar(hwnd
, last_split
);
4374 if (wparam
== VK_ESCAPE
)
4375 if (GetCapture() == hwnd
) {
4377 #ifdef _NO_EXTENSIONS
4378 draw_splitbar(hwnd
, last_split
);
4380 child
->split_pos
= last_split
;
4382 GetClientRect(hwnd
, &rt
);
4383 resize_tree(child
, rt
.right
, rt
.bottom
);
4386 SetCursor(LoadCursor(0, IDC_ARROW
));
4391 if (GetCapture() == hwnd
) {
4393 int x
= (short)LOWORD(lparam
);
4395 #ifdef _NO_EXTENSIONS
4396 HDC hdc
= GetDC(hwnd
);
4397 GetClientRect(hwnd
, &rt
);
4399 rt
.left
= last_split
-SPLIT_WIDTH
/2;
4400 rt
.right
= last_split
+SPLIT_WIDTH
/2+1;
4401 InvertRect(hdc
, &rt
);
4404 rt
.left
= x
-SPLIT_WIDTH
/2;
4405 rt
.right
= x
+SPLIT_WIDTH
/2+1;
4406 InvertRect(hdc
, &rt
);
4408 ReleaseDC(hwnd
, hdc
);
4410 GetClientRect(hwnd
, &rt
);
4412 if (x
>=0 && x
<rt
.right
) {
4413 child
->split_pos
= x
;
4414 resize_tree(child
, rt
.right
, rt
.bottom
);
4415 rt
.left
= x
-SPLIT_WIDTH
/2;
4416 rt
.right
= x
+SPLIT_WIDTH
/2+1;
4417 InvalidateRect(hwnd
, &rt
, FALSE
);
4418 UpdateWindow(child
->left
.hwnd
);
4420 UpdateWindow(child
->right
.hwnd
);
4426 #ifndef _NO_EXTENSIONS
4427 case WM_GETMINMAXINFO
:
4428 DefMDIChildProc(hwnd
, nmsg
, wparam
, lparam
);
4430 {LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
4432 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
4433 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
4435 #endif /* _NO_EXTENSIONS */
4438 if (SetCurrentDirectory(child
->path
))
4440 SetFocus(child
->focus_pane
? child
->right
.hwnd
: child
->left
.hwnd
);
4443 case WM_DISPATCH_COMMAND
: {
4444 Pane
* pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
4446 switch(LOWORD(wparam
)) {
4447 case ID_WINDOW_NEW
: {
4448 ChildWnd
* new_child
= alloc_child_window(child
->path
, NULL
, hwnd
);
4450 if (!create_child_window(new_child
))
4451 HeapFree(GetProcessHeap(), 0, new_child
);
4457 refresh_child(child
);
4461 activate_entry(child
, pane
, hwnd
);
4464 case ID_FILE_MOVE
: {
4465 TCHAR source
[BUFFER_LEN
], target
[BUFFER_LEN
];
4467 if (prompt_target(pane
, source
, target
)) {
4468 SHFILEOPSTRUCT shfo
= {hwnd
, FO_MOVE
, source
, target
};
4470 source
[lstrlen(source
)+1] = '\0';
4471 target
[lstrlen(target
)+1] = '\0';
4473 if (!SHFileOperation(&shfo
))
4474 refresh_child(child
);
4478 case ID_FILE_COPY
: {
4479 TCHAR source
[BUFFER_LEN
], target
[BUFFER_LEN
];
4481 if (prompt_target(pane
, source
, target
)) {
4482 SHFILEOPSTRUCT shfo
= {hwnd
, FO_COPY
, source
, target
};
4484 source
[lstrlen(source
)+1] = '\0';
4485 target
[lstrlen(target
)+1] = '\0';
4487 if (!SHFileOperation(&shfo
))
4488 refresh_child(child
);
4492 case ID_FILE_DELETE
: {
4493 TCHAR path
[BUFFER_LEN
];
4494 SHFILEOPSTRUCT shfo
= {hwnd
, FO_DELETE
, path
};
4496 get_path(pane
->cur
, path
);
4498 path
[lstrlen(path
)+1] = '\0';
4500 if (!SHFileOperation(&shfo
))
4501 refresh_child(child
);
4504 case ID_VIEW_SORT_NAME
:
4505 set_sort_order(child
, SORT_NAME
);
4508 case ID_VIEW_SORT_TYPE
:
4509 set_sort_order(child
, SORT_EXT
);
4512 case ID_VIEW_SORT_SIZE
:
4513 set_sort_order(child
, SORT_SIZE
);
4516 case ID_VIEW_SORT_DATE
:
4517 set_sort_order(child
, SORT_DATE
);
4520 case ID_VIEW_FILTER
: {
4521 struct FilterDialog dlg
;
4523 memset(&dlg
, 0, sizeof(struct FilterDialog
));
4524 lstrcpy(dlg
.pattern
, child
->filter_pattern
);
4525 dlg
.flags
= child
->filter_flags
;
4527 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_DIALOG_VIEW_TYPE
), hwnd
, FilterDialogDlgProc
, (LPARAM
)&dlg
) == IDOK
) {
4528 lstrcpy(child
->filter_pattern
, dlg
.pattern
);
4529 child
->filter_flags
= dlg
.flags
;
4530 refresh_right_pane(child
);
4534 case ID_VIEW_SPLIT
: {
4535 last_split
= child
->split_pos
;
4536 #ifdef _NO_EXTENSIONS
4537 draw_splitbar(hwnd
, last_split
);
4542 case ID_EDIT_PROPERTIES
:
4543 show_properties_dlg(pane
->cur
, child
->hwnd
);
4547 return pane_command(pane
, LOWORD(wparam
));
4553 Pane
* pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
4555 switch(HIWORD(wparam
)) {
4556 case LBN_SELCHANGE
: {
4557 int idx
= SendMessage(pane
->hwnd
, LB_GETCURSEL
, 0, 0);
4558 Entry
* entry
= (Entry
*) SendMessage(pane
->hwnd
, LB_GETITEMDATA
, idx
, 0);
4560 if (pane
== &child
->left
)
4561 set_curdir(child
, entry
, idx
, hwnd
);
4567 activate_entry(child
, pane
, hwnd
);
4572 #ifndef _NO_EXTENSIONS
4574 NMHDR
* pnmh
= (NMHDR
*) lparam
;
4575 return pane_notify(pnmh
->idFrom
==IDW_HEADER_LEFT
? &child
->left
: &child
->right
, pnmh
);}
4578 #ifdef _SHELL_FOLDERS
4579 case WM_CONTEXTMENU
: {
4584 /* first select the current item in the listbox */
4585 HWND hpanel
= (HWND
) wparam
;
4586 pt_clnt
.x
= pt
.x
= (short)LOWORD(lparam
);
4587 pt_clnt
.y
= pt
.y
= (short)HIWORD(lparam
);
4588 ScreenToClient(hpanel
, &pt_clnt
);
4589 SendMessage(hpanel
, WM_LBUTTONDOWN
, 0, MAKELONG(pt_clnt
.x
, pt_clnt
.y
));
4590 SendMessage(hpanel
, WM_LBUTTONUP
, 0, MAKELONG(pt_clnt
.x
, pt_clnt
.y
));
4592 /* now create the popup menu using shell namespace and IContextMenu */
4593 pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
4594 idx
= SendMessage(pane
->hwnd
, LB_GETCURSEL
, 0, 0);
4597 Entry
* entry
= (Entry
*) SendMessage(pane
->hwnd
, LB_GETITEMDATA
, idx
, 0);
4599 LPITEMIDLIST pidl_abs
= get_to_absolute_pidl(entry
, hwnd
);
4602 IShellFolder
* parentFolder
;
4603 LPCITEMIDLIST pidlLast
;
4605 /* get and use the parent folder to display correct context menu in all cases */
4606 if (SUCCEEDED(SHBindToParent(pidl_abs
, &IID_IShellFolder
, (LPVOID
*)&parentFolder
, &pidlLast
))) {
4607 if (ShellFolderContextMenu(parentFolder
, hwnd
, 1, &pidlLast
, pt
.x
, pt
.y
) == S_OK
)
4608 refresh_child(child
);
4610 IShellFolder_Release(parentFolder
);
4613 IMalloc_Free(Globals
.iMalloc
, pidl_abs
);
4619 case WM_MEASUREITEM
:
4621 if (!wparam
) /* Is the message menu-related? */
4622 if (CtxMenu_HandleMenuMsg(nmsg
, wparam
, lparam
))
4627 case WM_INITMENUPOPUP
:
4628 if (CtxMenu_HandleMenuMsg(nmsg
, wparam
, lparam
))
4631 update_view_menu(child
);
4634 case WM_MENUCHAR
: /* only supported by IContextMenu3 */
4636 LRESULT lResult
= 0;
4638 IContextMenu3_HandleMenuMsg2(s_pctxmenu3
, nmsg
, wparam
, lparam
, &lResult
);
4646 if (wparam
!= SIZE_MINIMIZED
)
4647 resize_tree(child
, LOWORD(lparam
), HIWORD(lparam
));
4651 return DefMDIChildProc(hwnd
, nmsg
, wparam
, lparam
);
4658 static LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
4660 ChildWnd
* child
= (ChildWnd
*) GetWindowLongPtr(GetParent(hwnd
), GWLP_USERDATA
);
4661 Pane
* pane
= (Pane
*) GetWindowLongPtr(hwnd
, GWLP_USERDATA
);
4665 #ifndef _NO_EXTENSIONS
4672 child
->focus_pane
= pane
==&child
->right
? 1: 0;
4673 SendMessage(hwnd
, LB_SETSEL
, TRUE
, 1);
4674 /*TODO: check menu items */
4678 if (wparam
== VK_TAB
) {
4679 /*TODO: SetFocus(Globals.hdrivebar) */
4680 SetFocus(child
->focus_pane
? child
->left
.hwnd
: child
->right
.hwnd
);
4684 return CallWindowProc(g_orgTreeWndProc
, hwnd
, nmsg
, wparam
, lparam
);
4688 static void InitInstance(HINSTANCE hinstance
)
4690 static const TCHAR sFont
[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
4697 INITCOMMONCONTROLSEX icc
= {
4698 sizeof(INITCOMMONCONTROLSEX
),
4704 setlocale(LC_COLLATE
, ""); /* set collating rules to local settings for compareName */
4706 InitCommonControlsEx(&icc
);
4709 /* register frame window class */
4711 wcFrame
.cbSize
= sizeof(WNDCLASSEX
);
4713 wcFrame
.lpfnWndProc
= FrameWndProc
;
4714 wcFrame
.cbClsExtra
= 0;
4715 wcFrame
.cbWndExtra
= 0;
4716 wcFrame
.hInstance
= hinstance
;
4717 wcFrame
.hIcon
= LoadIcon(hinstance
, MAKEINTRESOURCE(IDI_WINEFILE
));
4718 wcFrame
.hCursor
= LoadCursor(0, IDC_ARROW
);
4719 wcFrame
.hbrBackground
= 0;
4720 wcFrame
.lpszMenuName
= 0;
4721 wcFrame
.lpszClassName
= sWINEFILEFRAME
;
4722 wcFrame
.hIconSm
= (HICON
)LoadImage(hinstance
,
4723 MAKEINTRESOURCE(IDI_WINEFILE
),
4725 GetSystemMetrics(SM_CXSMICON
),
4726 GetSystemMetrics(SM_CYSMICON
),
4729 Globals
.hframeClass
= RegisterClassEx(&wcFrame
);
4732 /* register tree windows class */
4734 wcChild
.style
= CS_CLASSDC
|CS_DBLCLKS
|CS_VREDRAW
;
4735 wcChild
.lpfnWndProc
= ChildWndProc
;
4736 wcChild
.cbClsExtra
= 0;
4737 wcChild
.cbWndExtra
= 0;
4738 wcChild
.hInstance
= hinstance
;
4740 wcChild
.hCursor
= LoadCursor(0, IDC_ARROW
);
4741 wcChild
.hbrBackground
= 0;
4742 wcChild
.lpszMenuName
= 0;
4743 wcChild
.lpszClassName
= sWINEFILETREE
;
4745 hChildClass
= RegisterClass(&wcChild
);
4748 Globals
.haccel
= LoadAccelerators(hinstance
, MAKEINTRESOURCE(IDA_WINEFILE
));
4750 Globals
.hfont
= CreateFont(-MulDiv(8,GetDeviceCaps(hdc
,LOGPIXELSY
),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, sFont
);
4754 Globals
.hInstance
= hinstance
;
4756 #ifdef _SHELL_FOLDERS
4758 CoGetMalloc(MEMCTX_TASK
, &Globals
.iMalloc
);
4759 SHGetDesktopFolder(&Globals
.iDesktop
);
4761 Globals
.cfStrFName
= RegisterClipboardFormatA(CFSTR_FILENAME
);
4763 Globals
.cfStrFName
= RegisterClipboardFormat(CFSTR_FILENAME
);
4767 /* load column strings */
4770 load_string(g_pos_names
[col
++], IDS_COL_NAME
);
4771 load_string(g_pos_names
[col
++], IDS_COL_SIZE
);
4772 load_string(g_pos_names
[col
++], IDS_COL_CDATE
);
4773 #ifndef _NO_EXTENSIONS
4774 load_string(g_pos_names
[col
++], IDS_COL_ADATE
);
4775 load_string(g_pos_names
[col
++], IDS_COL_MDATE
);
4776 load_string(g_pos_names
[col
++], IDS_COL_IDX
);
4777 load_string(g_pos_names
[col
++], IDS_COL_LINKS
);
4779 load_string(g_pos_names
[col
++], IDS_COL_ATTR
);
4780 #ifndef _NO_EXTENSIONS
4781 load_string(g_pos_names
[col
++], IDS_COL_SEC
);
4786 static void show_frame(HWND hwndParent
, int cmdshow
, LPCTSTR path
)
4788 static const TCHAR sMDICLIENT
[] = {'M','D','I','C','L','I','E','N','T','\0'};
4790 TCHAR buffer
[MAX_PATH
], b1
[BUFFER_LEN
];
4792 HMENU hMenuFrame
, hMenuWindow
;
4795 CLIENTCREATESTRUCT ccs
;
4797 if (Globals
.hMainWnd
)
4800 opts
= load_registry_settings();
4801 hMenuFrame
= LoadMenu(Globals
.hInstance
, MAKEINTRESOURCE(IDM_WINEFILE
));
4802 hMenuWindow
= GetSubMenu(hMenuFrame
, GetMenuItemCount(hMenuFrame
)-2);
4804 Globals
.hMenuFrame
= hMenuFrame
;
4805 Globals
.hMenuView
= GetSubMenu(hMenuFrame
, 3);
4806 Globals
.hMenuOptions
= GetSubMenu(hMenuFrame
, 4);
4808 ccs
.hWindowMenu
= hMenuWindow
;
4809 ccs
.idFirstChild
= IDW_FIRST_CHILD
;
4812 /* create main window */
4813 Globals
.hMainWnd
= CreateWindowEx(0, (LPCTSTR
)(int)Globals
.hframeClass
, RS(b1
,IDS_WINE_FILE
), WS_OVERLAPPEDWINDOW
,
4814 opts
.start_x
, opts
.start_y
, opts
.width
, opts
.height
,
4815 hwndParent
, Globals
.hMenuFrame
, Globals
.hInstance
, 0/*lpParam*/);
4818 Globals
.hmdiclient
= CreateWindowEx(0, sMDICLIENT
, NULL
,
4819 WS_CHILD
|WS_CLIPCHILDREN
|WS_VSCROLL
|WS_HSCROLL
|WS_VISIBLE
|WS_BORDER
,
4821 Globals
.hMainWnd
, 0, Globals
.hInstance
, &ccs
);
4823 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_DRIVE_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
4824 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_SAVESETTINGS
, MF_BYCOMMAND
);
4829 TBBUTTON toolbarBtns
[] = {
4830 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
4831 {0, ID_WINDOW_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
4832 {1, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
4833 {2, ID_WINDOW_TILE_HORZ
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
4834 {3, ID_WINDOW_TILE_VERT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
4836 {4, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
4837 {5, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
4840 Globals
.htoolbar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
,
4841 IDW_TOOLBAR
, 2, Globals
.hInstance
, IDB_TOOLBAR
, toolbarBtns
,
4842 sizeof(toolbarBtns
)/sizeof(TBBUTTON
), 16, 15, 16, 15, sizeof(TBBUTTON
));
4843 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_TOOL_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
4846 Globals
.hstatusbar
= CreateStatusWindow(WS_CHILD
|WS_VISIBLE
, 0, Globals
.hMainWnd
, IDW_STATUSBAR
);
4847 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
4849 /* CreateStatusWindow does not accept WS_BORDER
4850 Globals.hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
4851 WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
4852 Globals.hMainWnd, (HMENU)IDW_STATUSBAR, hinstance, 0);*/
4854 /*TODO: read paths from registry */
4856 if (!path
|| !*path
) {
4857 GetCurrentDirectory(MAX_PATH
, buffer
);
4861 ShowWindow(Globals
.hMainWnd
, cmdshow
);
4863 #if defined(_SHELL_FOLDERS) && !defined(__WINE__)
4864 /* Shell Namespace as default: */
4865 child
= alloc_child_window(path
, get_path_pidl(path
,Globals
.hMainWnd
), Globals
.hMainWnd
);
4867 child
= alloc_child_window(path
, NULL
, Globals
.hMainWnd
);
4870 child
->pos
.showCmd
= SW_SHOWMAXIMIZED
;
4871 child
->pos
.rcNormalPosition
.left
= 0;
4872 child
->pos
.rcNormalPosition
.top
= 0;
4873 child
->pos
.rcNormalPosition
.right
= 320;
4874 child
->pos
.rcNormalPosition
.bottom
= 280;
4876 if (!create_child_window(child
))
4877 HeapFree(GetProcessHeap(), 0, child
);
4879 SetWindowPlacement(child
->hwnd
, &child
->pos
);
4881 Globals
.himl
= ImageList_LoadBitmap(Globals
.hInstance
, MAKEINTRESOURCE(IDB_IMAGES
), 16, 0, RGB(0,255,0));
4883 Globals
.prescan_node
= FALSE
;
4885 UpdateWindow(Globals
.hMainWnd
);
4887 if (path
&& path
[0])
4890 TCHAR drv
[_MAX_DRIVE
+1], dir
[_MAX_DIR
], name
[_MAX_FNAME
], ext
[_MAX_EXT
];
4891 TCHAR fullname
[_MAX_FNAME
+_MAX_EXT
+1];
4893 memset(name
,0,sizeof(name
));
4894 memset(name
,0,sizeof(ext
));
4895 _tsplitpath(path
, drv
, dir
, name
, ext
);
4898 count
= SendMessage(child
->right
.hwnd
, LB_GETCOUNT
, 0, 0);
4899 lstrcpy(fullname
,name
);
4900 lstrcat(fullname
,ext
);
4902 for (index
= 0; index
< count
; index
++)
4904 Entry
* entry
= (Entry
*) SendMessage(child
->right
.hwnd
, LB_GETITEMDATA
, index
, 0);
4905 if (lstrcmp(entry
->data
.cFileName
,fullname
)==0 ||
4906 lstrcmp(entry
->data
.cAlternateFileName
,fullname
)==0)
4908 SendMessage(child
->right
.hwnd
, LB_SETCURSEL
, index
, 0);
4909 SetFocus(child
->right
.hwnd
);
4917 static void ExitInstance(void)
4919 #ifdef _SHELL_FOLDERS
4920 IShellFolder_Release(Globals
.iDesktop
);
4921 IMalloc_Release(Globals
.iMalloc
);
4925 DeleteObject(Globals
.hfont
);
4926 ImageList_Destroy(Globals
.himl
);
4929 #ifdef _NO_EXTENSIONS
4931 /* search for already running win[e]files */
4933 static int g_foundPrevInstance
= 0;
4935 static BOOL CALLBACK
EnumWndProc(HWND hwnd
, LPARAM lparam
)
4939 GetClassName(hwnd
, cls
, 128);
4941 if (!lstrcmp(cls
, (LPCTSTR
)lparam
)) {
4942 g_foundPrevInstance
++;
4949 /* search for window of given class name to allow only one running instance */
4950 static int find_window_class(LPCTSTR classname
)
4952 EnumWindows(EnumWndProc
, (LPARAM
)classname
);
4954 if (g_foundPrevInstance
)
4962 static int winefile_main(HINSTANCE hinstance
, int cmdshow
, LPCTSTR path
)
4966 InitInstance(hinstance
);
4968 show_frame(0, cmdshow
, path
);
4970 while(GetMessage(&msg
, 0, 0, 0)) {
4971 if (Globals
.hmdiclient
&& TranslateMDISysAccel(Globals
.hmdiclient
, &msg
))
4974 if (Globals
.hMainWnd
&& TranslateAccelerator(Globals
.hMainWnd
, Globals
.haccel
, &msg
))
4977 TranslateMessage(&msg
);
4978 DispatchMessage(&msg
);
4987 #if defined(UNICODE) && defined(_MSC_VER)
4988 int APIENTRY
wWinMain(HINSTANCE hinstance
, HINSTANCE previnstance
, LPWSTR cmdline
, int cmdshow
)
4990 int APIENTRY
WinMain(HINSTANCE hinstance
, HINSTANCE previnstance
, LPSTR cmdline
, int cmdshow
)
4993 #ifdef _NO_EXTENSIONS
4994 if (find_window_class(sWINEFILEFRAME
))
4998 #if defined(UNICODE) && !defined(_MSC_VER)
4999 { /* convert ANSI cmdline into WCS path string */
5000 TCHAR buffer
[MAX_PATH
];
5001 MultiByteToWideChar(CP_ACP
, 0, cmdline
, -1, buffer
, MAX_PATH
);
5002 winefile_main(hinstance
, cmdshow
, buffer
);
5005 winefile_main(hinstance
, cmdshow
, cmdline
);