4 * Copyright 2000, 2003, 2004, 2005 Martin Fuchs
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
28 #define NONAMELESSUNION
32 /* for read_directory_unix() */
33 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
48 #define _MAX_FNAME 256
49 #define _MAX_DIR _MAX_FNAME
50 #define _MAX_EXT _MAX_FNAME
54 #ifdef NONAMELESSUNION
55 #define UNION_MEMBER(x) DUMMYUNIONNAME.x
57 #define UNION_MEMBER(x) x
62 #define DEFAULT_SPLIT_POS 300
64 #define DEFAULT_SPLIT_POS 200
76 typedef struct _Entry
{
87 #ifndef _NO_EXTENSIONS
88 BY_HANDLE_FILE_INFORMATION bhfi
;
90 enum ENTRY_TYPE etype
;
101 TCHAR path
[MAX_PATH
];
102 TCHAR volname
[_MAX_FNAME
];
112 COL_ATTRIBUTES
= 0x08,
114 #ifdef _NO_EXTENSIONS
115 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
119 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
|COL_INDEX
|COL_LINKS
132 #ifndef _NO_EXTENSIONS
136 #ifndef _NO_EXTENSIONS
142 int positions
[COLUMNS
+1];
154 int focus_pane
; /* 0: left 1: right */
157 BOOL header_wdths_ok
;
159 TCHAR path
[MAX_PATH
];
160 TCHAR filter_pattern
[MAX_PATH
];
164 SORT_ORDER sortOrder
;
168 extern void WineLicense(HWND hwnd
);
169 extern void WineWarranty(HWND hwnd
);
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();
176 static void get_path(Entry
* dir
, PTSTR path
);
178 LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
179 LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
180 LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
184 WINEFILE_GLOBALS Globals
;
186 static int last_split
;
188 /* some common string constants */
189 const static TCHAR sEmpty
[] = {'\0'};
190 const static TCHAR sSpace
[] = {' ', '\0'};
191 const static TCHAR sNumFmt
[] = {'%','d','\0'};
192 const static TCHAR sQMarks
[] = {'?','?','?','\0'};
194 /* window class names */
195 const static TCHAR sWINEFILEFRAME
[] = {'W','F','S','_','F','r','a','m','e','\0'};
196 const static TCHAR sWINEFILETREE
[] = {'W','F','S','_','T','r','e','e','\0'};
199 /* #define LONGLONGARG _T("I64") */
200 const static TCHAR sLongHexFmt
[] = {'%','I','6','4','X','\0'};
201 const static TCHAR sLongNumFmt
[] = {'%','I','6','4','d','\0'};
203 /* #define LONGLONGARG _T("L") */
204 const static TCHAR sLongHexFmt
[] = {'%','L','X','\0'};
205 const static TCHAR sLongNumFmt
[] = {'%','L','d','\0'};
209 /* load resource string */
210 static LPTSTR
load_string(LPTSTR buffer
, UINT id
)
212 LoadString(Globals
.hInstance
, id
, buffer
, BUFFER_LEN
);
217 #define RS(b, i) load_string(b, i)
220 /* display error message for the specified WIN32 error code */
221 static void display_error(HWND hwnd
, DWORD error
)
223 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
226 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_FROM_SYSTEM
,
227 0, error
, MAKELANGID(LANG_NEUTRAL
,SUBLANG_DEFAULT
), (PTSTR
)&msg
, 0, NULL
))
228 MessageBox(hwnd
, msg
, RS(b2
,IDS_WINEFILE
), MB_OK
);
230 MessageBox(hwnd
, RS(b1
,IDS_ERROR
), RS(b2
,IDS_WINEFILE
), MB_OK
);
236 /* display network error message using WNetGetLastError() */
237 static void display_network_error(HWND hwnd
)
239 TCHAR msg
[BUFFER_LEN
], provider
[BUFFER_LEN
], b2
[BUFFER_LEN
];
242 if (WNetGetLastError(&error
, msg
, BUFFER_LEN
, provider
, BUFFER_LEN
) == NO_ERROR
)
243 MessageBox(hwnd
, msg
, RS(b2
,IDS_WINEFILE
), MB_OK
);
247 /* allocate and initialise a directory entry */
248 static Entry
* alloc_entry()
250 Entry
* entry
= (Entry
*) malloc(sizeof(Entry
));
252 #ifdef _SHELL_FOLDERS
254 entry
->folder
= NULL
;
261 /* free a directory entry */
262 static void free_entry(Entry
* entry
)
264 #ifdef _SHELL_FOLDERS
265 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
266 DestroyIcon(entry
->hicon
);
268 if (entry
->folder
&& entry
->folder
!=Globals
.iDesktop
)
269 (*entry
->folder
->lpVtbl
->Release
)(entry
->folder
);
272 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, entry
->pidl
);
278 /* recursively free all child entries */
279 static void free_entries(Entry
* dir
)
281 Entry
*entry
, *next
=dir
->down
;
297 static void read_directory_win(Entry
* dir
, LPCTSTR path
)
299 Entry
* first_entry
= NULL
;
303 int level
= dir
->level
+ 1;
304 WIN32_FIND_DATA w32fd
;
306 #ifndef _NO_EXTENSIONS
310 TCHAR buffer
[MAX_PATH
], *p
;
311 for(p
=buffer
; *path
; )
318 hFind
= FindFirstFile(buffer
, &w32fd
);
320 if (hFind
!= INVALID_HANDLE_VALUE
) {
322 #ifdef _NO_EXTENSIONS
323 /* hide directory entry "." */
324 if (w32fd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
325 LPCTSTR name
= w32fd
.cFileName
;
327 if (name
[0]=='.' && name
[1]=='\0')
331 entry
= alloc_entry();
339 memcpy(&entry
->data
, &w32fd
, sizeof(WIN32_FIND_DATA
));
342 entry
->expanded
= FALSE
;
343 entry
->scanned
= FALSE
;
344 entry
->level
= level
;
346 #ifndef _NO_EXTENSIONS
347 entry
->etype
= ET_WINDOWS
;
348 entry
->bhfi_valid
= FALSE
;
350 lstrcpy(p
, entry
->data
.cFileName
);
352 hFile
= CreateFile(buffer
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
,
353 0, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0);
355 if (hFile
!= INVALID_HANDLE_VALUE
) {
356 if (GetFileInformationByHandle(hFile
, &entry
->bhfi
))
357 entry
->bhfi_valid
= TRUE
;
364 } while(FindNextFile(hFind
, &w32fd
));
372 dir
->down
= first_entry
;
377 static Entry
* find_entry_win(Entry
* dir
, LPCTSTR name
)
381 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
383 LPCTSTR q
= entry
->data
.cFileName
;
386 if (!*p
|| *p
==TEXT('\\') || *p
==TEXT('/'))
388 } while(tolower(*p
++) == tolower(*q
++));
391 q
= entry
->data
.cAlternateFileName
;
394 if (!*p
|| *p
==TEXT('\\') || *p
==TEXT('/'))
396 } while(tolower(*p
++) == tolower(*q
++));
403 static Entry
* read_tree_win(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
405 TCHAR buffer
[MAX_PATH
];
406 Entry
* entry
= &root
->entry
;
410 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
412 #ifndef _NO_EXTENSIONS
413 entry
->etype
= ET_WINDOWS
;
417 while(*s
&& *s
!=TEXT('\\') && *s
!=TEXT('/'))
420 while(*s
==TEXT('\\') || *s
==TEXT('/'))
426 read_directory(entry
, buffer
, sortOrder
, hwnd
);
429 entry
->expanded
= TRUE
;
434 entry
= find_entry_win(entry
, s
);
437 SetCursor(old_cursor
);
443 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
445 static BOOL
time_to_filetime(const time_t* t
, FILETIME
* ftime
)
447 struct tm
* tm
= gmtime(t
);
453 stime
.wYear
= tm
->tm_year
+1900;
454 stime
.wMonth
= tm
->tm_mon
+1;
455 /* stime.wDayOfWeek */
456 stime
.wDay
= tm
->tm_mday
;
457 stime
.wHour
= tm
->tm_hour
;
458 stime
.wMinute
= tm
->tm_min
;
459 stime
.wSecond
= tm
->tm_sec
;
461 return SystemTimeToFileTime(&stime
, ftime
);
464 static void read_directory_unix(Entry
* dir
, LPCTSTR path
)
466 Entry
* first_entry
= NULL
;
470 int level
= dir
->level
+ 1;
472 DIR* pdir
= opendir(path
);
477 TCHAR buffer
[MAX_PATH
], *p
;
479 for(p
=buffer
; *path
; )
482 if (p
==buffer
|| p
[-1]!='/')
485 while((ent
=readdir(pdir
))) {
486 entry
= alloc_entry();
494 entry
->etype
= ET_UNIX
;
496 lstrcpy(entry
->data
.cFileName
, ent
->d_name
);
497 entry
->data
.dwFileAttributes
= ent
->d_name
[0]=='.'? FILE_ATTRIBUTE_HIDDEN
: 0;
499 strcpy(p
, ent
->d_name
);
501 if (!stat(buffer
, &st
)) {
502 if (S_ISDIR(st
.st_mode
))
503 entry
->data
.dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
505 entry
->data
.nFileSizeLow
= st
.st_size
& 0xFFFFFFFF;
506 entry
->data
.nFileSizeHigh
= st
.st_size
>> 32;
508 memset(&entry
->data
.ftCreationTime
, 0, sizeof(FILETIME
));
509 time_to_filetime(&st
.st_atime
, &entry
->data
.ftLastAccessTime
);
510 time_to_filetime(&st
.st_mtime
, &entry
->data
.ftLastWriteTime
);
512 entry
->bhfi
.nFileIndexLow
= ent
->d_ino
;
513 entry
->bhfi
.nFileIndexHigh
= 0;
515 entry
->bhfi
.nNumberOfLinks
= st
.st_nlink
;
517 entry
->bhfi_valid
= TRUE
;
519 entry
->data
.nFileSizeLow
= 0;
520 entry
->data
.nFileSizeHigh
= 0;
521 entry
->bhfi_valid
= FALSE
;
526 entry
->expanded
= FALSE
;
527 entry
->scanned
= FALSE
;
528 entry
->level
= level
;
539 dir
->down
= first_entry
;
543 static Entry
* find_entry_unix(Entry
* dir
, LPCTSTR name
)
547 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
549 LPCTSTR q
= entry
->data
.cFileName
;
552 if (!*p
|| *p
==TEXT('/'))
554 } while(*p
++ == *q
++);
560 static Entry
* read_tree_unix(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
562 TCHAR buffer
[MAX_PATH
];
563 Entry
* entry
= &root
->entry
;
567 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
569 entry
->etype
= ET_UNIX
;
572 while(*s
&& *s
!=TEXT('/'))
575 while(*s
== TEXT('/'))
581 read_directory(entry
, buffer
, sortOrder
, hwnd
);
584 entry
->expanded
= TRUE
;
589 entry
= find_entry_unix(entry
, s
);
592 SetCursor(old_cursor
);
597 #endif /* !defined(_NO_EXTENSIONS) && defined(__WINE__) */
600 #ifdef _SHELL_FOLDERS
603 #define tcscpyn strcpyn
604 #define get_strret get_strretW
605 #define path_from_pidl path_from_pidlW
607 #define tcscpyn wcscpyn
608 #define get_strret get_strretA
609 #define path_from_pidl path_from_pidlA
613 static LPSTR
strcpyn(LPSTR dest
, LPCSTR source
, size_t count
)
618 for(s
=source
; count
&&(*d
++=*s
++); )
624 static LPWSTR
wcscpyn(LPWSTR dest
, LPCWSTR source
, size_t count
)
629 for(s
=source
; count
&&(*d
++=*s
++); )
636 static void get_strretA(STRRET
* str
, const SHITEMID
* shiid
, LPSTR buffer
, int len
)
640 WideCharToMultiByte(CP_ACP
, 0, str
->UNION_MEMBER(pOleStr
), -1, buffer
, len
, NULL
, NULL
);
644 strcpyn(buffer
, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), len
);
648 strcpyn(buffer
, str
->UNION_MEMBER(cStr
), len
);
652 static void get_strretW(STRRET
* str
, const SHITEMID
* shiid
, LPWSTR buffer
, int len
)
656 wcscpyn(buffer
, str
->UNION_MEMBER(pOleStr
), len
);
660 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), -1, buffer
, len
);
664 MultiByteToWideChar(CP_ACP
, 0, str
->UNION_MEMBER(cStr
), -1, buffer
, len
);
669 static void free_strret(STRRET
* str
)
671 if (str
->uType
== STRRET_WSTR
)
672 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, str
->UNION_MEMBER(pOleStr
));
676 HRESULT
name_from_pidl(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPTSTR buffer
, int len
, SHGDNF flags
)
680 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, flags
, &str
);
683 get_strret(&str
, &pidl
->mkid
, buffer
, len
);
692 HRESULT
path_from_pidlA(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPSTR buffer
, int len
)
696 /* SHGDN_FORPARSING: get full path of id list */
697 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, SHGDN_FORPARSING
, &str
);
700 get_strretA(&str
, &pidl
->mkid
, buffer
, len
);
708 HRESULT
path_from_pidlW(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPWSTR buffer
, int len
)
712 /* SHGDN_FORPARSING: get full path of id list */
713 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, SHGDN_FORPARSING
, &str
);
716 get_strretW(&str
, &pidl
->mkid
, buffer
, len
);
725 /* create an item id list from a file system path */
727 static LPITEMIDLIST
get_path_pidl(LPTSTR path
, HWND hwnd
)
734 LPWSTR buffer
= path
;
736 WCHAR buffer
[MAX_PATH
];
737 MultiByteToWideChar(CP_ACP
, 0, path
, -1, buffer
, MAX_PATH
);
740 hr
= (*Globals
.iDesktop
->lpVtbl
->ParseDisplayName
)(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
748 /* convert an item id list from relative to absolute (=relative to the desktop) format */
750 static LPITEMIDLIST
get_to_absolute_pidl(Entry
* entry
, HWND hwnd
)
752 if (entry
->up
&& entry
->up
->etype
==ET_SHELL
) {
753 IShellFolder
* folder
= entry
->up
->folder
;
754 WCHAR buffer
[MAX_PATH
];
756 HRESULT hr
= path_from_pidlW(folder
, entry
->pidl
, buffer
, MAX_PATH
);
762 hr
= (*Globals
.iDesktop
->lpVtbl
->ParseDisplayName
)(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
767 } else if (entry
->etype
== ET_WINDOWS
) {
768 TCHAR path
[MAX_PATH
];
770 get_path(entry
, path
);
772 return get_path_pidl(path
, hwnd
);
773 } else if (entry
->pidl
)
774 return ILClone(entry
->pidl
);
780 HICON
extract_icon(IShellFolder
* folder
, LPCITEMIDLIST pidl
)
782 IExtractIcon
* pExtract
;
784 if (SUCCEEDED((*folder
->lpVtbl
->GetUIObjectOf
)(folder
, 0, 1, (LPCITEMIDLIST
*)&pidl
, &IID_IExtractIcon
, 0, (LPVOID
*)&pExtract
))) {
785 TCHAR path
[_MAX_PATH
];
790 if (SUCCEEDED((*pExtract
->lpVtbl
->GetIconLocation
)(pExtract
, GIL_FORSHELL
, path
, _MAX_PATH
, &idx
, &flags
))) {
791 if (!(flags
& GIL_NOTFILENAME
)) {
793 idx
= 0; /* special case for some control panel applications */
795 if ((int)ExtractIconEx(path
, idx
, 0, &hicon
, 1) > 0)
796 flags
&= ~GIL_DONTCACHE
;
798 HICON hIconLarge
= 0;
800 HRESULT hr
= (*pExtract
->lpVtbl
->Extract
)(pExtract
, path
, idx
, &hIconLarge
, &hicon
, MAKELONG(0/*GetSystemMetrics(SM_CXICON)*/,GetSystemMetrics(SM_CXSMICON
)));
803 DestroyIcon(hIconLarge
);
814 static Entry
* find_entry_shell(Entry
* dir
, LPITEMIDLIST pidl
)
818 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
819 if (entry
->pidl
->mkid
.cb
== pidl
->mkid
.cb
&&
820 !memcmp(entry
->pidl
, pidl
, entry
->pidl
->mkid
.cb
))
827 static Entry
* read_tree_shell(Root
* root
, LPITEMIDLIST pidl
, SORT_ORDER sortOrder
, HWND hwnd
)
829 Entry
* entry
= &root
->entry
;
831 LPITEMIDLIST next_pidl
= pidl
;
832 IShellFolder
* folder
;
833 IShellFolder
* child
= NULL
;
836 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
838 #ifndef _NO_EXTENSIONS
839 entry
->etype
= ET_SHELL
;
842 folder
= Globals
.iDesktop
;
845 entry
->pidl
= next_pidl
;
846 entry
->folder
= folder
;
851 /* copy first element of item idlist */
852 next_pidl
= (*Globals
.iMalloc
->lpVtbl
->Alloc
)(Globals
.iMalloc
, pidl
->mkid
.cb
+sizeof(USHORT
));
853 memcpy(next_pidl
, pidl
, pidl
->mkid
.cb
);
854 ((LPITEMIDLIST
)((LPBYTE
)next_pidl
+pidl
->mkid
.cb
))->mkid
.cb
= 0;
856 hr
= (*folder
->lpVtbl
->BindToObject
)(folder
, next_pidl
, 0, &IID_IShellFolder
, (void**)&child
);
860 read_directory(entry
, NULL
, sortOrder
, hwnd
);
863 entry
->expanded
= TRUE
;
865 next
= find_entry_shell(entry
, next_pidl
);
872 /* go to next element */
873 pidl
= (LPITEMIDLIST
) ((LPBYTE
)pidl
+pidl
->mkid
.cb
);
876 SetCursor(old_cursor
);
882 static void fill_w32fdata_shell(IShellFolder
* folder
, LPCITEMIDLIST pidl
, SFGAOF attribs
, WIN32_FIND_DATA
* w32fdata
)
884 if (!(attribs
& SFGAO_FILESYSTEM
) ||
885 FAILED(SHGetDataFromIDList(folder
, pidl
, SHGDFIL_FINDDATA
, w32fdata
, sizeof(WIN32_FIND_DATA
)))) {
886 WIN32_FILE_ATTRIBUTE_DATA fad
;
887 IDataObject
* pDataObj
;
889 STGMEDIUM medium
= {0, {0}, 0};
890 FORMATETC fmt
= {Globals
.cfStrFName
, 0, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
892 HRESULT hr
= (*folder
->lpVtbl
->GetUIObjectOf
)(folder
, 0, 1, &pidl
, &IID_IDataObject
, 0, (LPVOID
*)&pDataObj
);
895 hr
= (*pDataObj
->lpVtbl
->GetData
)(pDataObj
, &fmt
, &medium
);
897 (*pDataObj
->lpVtbl
->Release
)(pDataObj
);
900 LPCTSTR path
= (LPCTSTR
)GlobalLock(medium
.UNION_MEMBER(hGlobal
));
901 UINT sem_org
= SetErrorMode(SEM_FAILCRITICALERRORS
);
903 if (GetFileAttributesEx(path
, GetFileExInfoStandard
, &fad
)) {
904 w32fdata
->dwFileAttributes
= fad
.dwFileAttributes
;
905 w32fdata
->ftCreationTime
= fad
.ftCreationTime
;
906 w32fdata
->ftLastAccessTime
= fad
.ftLastAccessTime
;
907 w32fdata
->ftLastWriteTime
= fad
.ftLastWriteTime
;
909 if (!(fad
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
910 w32fdata
->nFileSizeLow
= fad
.nFileSizeLow
;
911 w32fdata
->nFileSizeHigh
= fad
.nFileSizeHigh
;
915 SetErrorMode(sem_org
);
917 GlobalUnlock(medium
.UNION_MEMBER(hGlobal
));
918 GlobalFree(medium
.UNION_MEMBER(hGlobal
));
923 if (attribs
& (SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
))
924 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
926 if (attribs
& SFGAO_READONLY
)
927 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_READONLY
;
929 if (attribs
& SFGAO_COMPRESSED
)
930 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_COMPRESSED
;
934 static void read_directory_shell(Entry
* dir
, HWND hwnd
)
936 IShellFolder
* folder
= dir
->folder
;
937 int level
= dir
->level
+ 1;
943 Entry
* first_entry
= NULL
;
950 hr
= (*folder
->lpVtbl
->EnumObjects
)(folder
, hwnd
, SHCONTF_FOLDERS
|SHCONTF_NONFOLDERS
|SHCONTF_INCLUDEHIDDEN
|SHCONTF_SHAREABLE
|SHCONTF_STORAGE
, &idlist
);
954 #define FETCH_ITEM_COUNT 32
955 LPITEMIDLIST pidls
[FETCH_ITEM_COUNT
];
960 memset(pidls
, 0, sizeof(pidls
));
962 hr
= (*idlist
->lpVtbl
->Next
)(idlist
, FETCH_ITEM_COUNT
, pidls
, &cnt
);
969 for(n
=0; n
<cnt
; ++n
) {
970 entry
= alloc_entry();
978 memset(&entry
->data
, 0, sizeof(WIN32_FIND_DATA
));
979 entry
->bhfi_valid
= FALSE
;
981 attribs
= ~SFGAO_FILESYSTEM
; /*SFGAO_HASSUBFOLDER|SFGAO_FOLDER; SFGAO_FILESYSTEM sorgt dafür, daß "My Documents" anstatt von "Martin's Documents" angezeigt wird */
983 hr
= (*folder
->lpVtbl
->GetAttributesOf
)(folder
, 1, (LPCITEMIDLIST
*)&pidls
[n
], &attribs
);
986 if (attribs
!= (SFGAOF
)~SFGAO_FILESYSTEM
) {
987 fill_w32fdata_shell(folder
, pidls
[n
], attribs
, &entry
->data
);
989 entry
->bhfi_valid
= TRUE
;
995 entry
->pidl
= pidls
[n
];
997 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
998 hr
= (*folder
->lpVtbl
->BindToObject
)(folder
, pidls
[n
], 0, &IID_IShellFolder
, (void**)&child
);
1001 entry
->folder
= child
;
1003 entry
->folder
= NULL
;
1006 entry
->folder
= NULL
;
1008 if (!entry
->data
.cFileName
[0])
1009 /*hr = */name_from_pidl(folder
, pidls
[n
], entry
->data
.cFileName
, MAX_PATH
, /*SHGDN_INFOLDER*/0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/);
1011 /* get display icons for files and virtual objects */
1012 if (!(entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1013 !(attribs
& SFGAO_FILESYSTEM
)) {
1014 entry
->hicon
= extract_icon(folder
, pidls
[n
]);
1017 entry
->hicon
= (HICON
)-1; /* don't try again later */
1022 entry
->expanded
= FALSE
;
1023 entry
->scanned
= FALSE
;
1024 entry
->level
= level
;
1026 #ifndef _NO_EXTENSIONS
1027 entry
->etype
= ET_SHELL
;
1028 entry
->bhfi_valid
= FALSE
;
1035 (*idlist
->lpVtbl
->Release
)(idlist
);
1041 dir
->down
= first_entry
;
1042 dir
->scanned
= TRUE
;
1045 #endif /* _SHELL_FOLDERS */
1048 /* sort order for different directory/file types */
1057 /* distinguish between ".", ".." and any other directory names */
1058 static int TypeOrderFromDirname(LPCTSTR name
)
1060 if (name
[0] == '.') {
1061 if (name
[1] == '\0')
1062 return TO_DOT
; /* "." */
1064 if (name
[1]=='.' && name
[2]=='\0')
1065 return TO_DOTDOT
; /* ".." */
1068 return TO_OTHER_DIR
; /* anything else */
1071 /* directories first... */
1072 static int compareType(const WIN32_FIND_DATA
* fd1
, const WIN32_FIND_DATA
* fd2
)
1074 int order1
= fd1
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1075 int order2
= fd2
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1077 /* Handle "." and ".." as special case and move them at the very first beginning. */
1078 if (order1
==TO_DIR
&& order2
==TO_DIR
) {
1079 order1
= TypeOrderFromDirname(fd1
->cFileName
);
1080 order2
= TypeOrderFromDirname(fd2
->cFileName
);
1083 return order2
==order1
? 0: order1
<order2
? -1: 1;
1087 static int compareName(const void* arg1
, const void* arg2
)
1089 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1090 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1092 int cmp
= compareType(fd1
, fd2
);
1096 return lstrcmpi(fd1
->cFileName
, fd2
->cFileName
);
1099 static int compareExt(const void* arg1
, const void* arg2
)
1101 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1102 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1103 const TCHAR
*name1
, *name2
, *ext1
, *ext2
;
1105 int cmp
= compareType(fd1
, fd2
);
1109 name1
= fd1
->cFileName
;
1110 name2
= fd2
->cFileName
;
1112 ext1
= _tcsrchr(name1
, TEXT('.'));
1113 ext2
= _tcsrchr(name2
, TEXT('.'));
1125 cmp
= lstrcmpi(ext1
, ext2
);
1129 return lstrcmpi(name1
, name2
);
1132 static int compareSize(const void* arg1
, const void* arg2
)
1134 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1135 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1137 int cmp
= compareType(fd1
, fd2
);
1141 cmp
= fd2
->nFileSizeHigh
- fd1
->nFileSizeHigh
;
1148 cmp
= fd2
->nFileSizeLow
- fd1
->nFileSizeLow
;
1150 return cmp
<0? -1: cmp
>0? 1: 0;
1153 static int compareDate(const void* arg1
, const void* arg2
)
1155 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1156 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1158 int cmp
= compareType(fd1
, fd2
);
1162 return CompareFileTime(&fd2
->ftLastWriteTime
, &fd1
->ftLastWriteTime
);
1166 static int (*sortFunctions
[])(const void* arg1
, const void* arg2
) = {
1167 compareName
, /* SORT_NAME */
1168 compareExt
, /* SORT_EXT */
1169 compareSize
, /* SORT_SIZE */
1170 compareDate
/* SORT_DATE */
1174 static void SortDirectory(Entry
* dir
, SORT_ORDER sortOrder
)
1176 Entry
* entry
= dir
->down
;
1181 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1185 array
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(Entry
*));
1188 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1191 /* call qsort with the appropriate compare function */
1192 qsort(array
, len
, sizeof(array
[0]), sortFunctions
[sortOrder
]);
1194 dir
->down
= array
[0];
1196 for(p
=array
; --len
; p
++)
1200 HeapFree( GetProcessHeap(), 0, array
);
1205 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
1207 TCHAR buffer
[MAX_PATH
];
1212 #ifdef _SHELL_FOLDERS
1213 if (dir
->etype
== ET_SHELL
)
1215 read_directory_shell(dir
, hwnd
);
1217 if (Globals
.prescan_node
) {
1226 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1227 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1228 read_directory_shell(entry
, hwnd
);
1229 SortDirectory(entry
, sortOrder
);
1235 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1236 if (dir
->etype
== ET_UNIX
)
1238 read_directory_unix(dir
, path
);
1240 if (Globals
.prescan_node
) {
1249 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1250 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1251 lstrcpy(d
, entry
->data
.cFileName
);
1252 read_directory_unix(entry
, buffer
);
1253 SortDirectory(entry
, sortOrder
);
1260 read_directory_win(dir
, path
);
1262 if (Globals
.prescan_node
) {
1271 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1272 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1273 lstrcpy(d
, entry
->data
.cFileName
);
1274 read_directory_win(entry
, buffer
);
1275 SortDirectory(entry
, sortOrder
);
1280 SortDirectory(dir
, sortOrder
);
1284 static Entry
* read_tree(Root
* root
, LPCTSTR path
, LPITEMIDLIST pidl
, LPTSTR drv
, SORT_ORDER sortOrder
, HWND hwnd
)
1286 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1287 const static TCHAR sSlash
[] = {'/', '\0'};
1289 const static TCHAR sBackslash
[] = {'\\', '\0'};
1291 #ifdef _SHELL_FOLDERS
1294 /* read shell namespace tree */
1295 root
->drive_type
= DRIVE_UNKNOWN
;
1298 load_string(root
->volname
, IDS_DESKTOP
);
1300 load_string(root
->fs
, IDS_SHELL
);
1302 return read_tree_shell(root
, pidl
, sortOrder
, hwnd
);
1306 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1309 /* read unix file system tree */
1310 root
->drive_type
= GetDriveType(path
);
1312 lstrcat(drv
, sSlash
);
1313 load_string(root
->volname
, IDS_ROOT_FS
);
1315 load_string(root
->fs
, IDS_UNIXFS
);
1317 lstrcpy(root
->path
, sSlash
);
1319 return read_tree_unix(root
, path
, sortOrder
, hwnd
);
1323 /* read WIN32 file system tree */
1324 root
->drive_type
= GetDriveType(path
);
1326 lstrcat(drv
, sBackslash
);
1327 GetVolumeInformation(drv
, root
->volname
, _MAX_FNAME
, 0, 0, &root
->fs_flags
, root
->fs
, _MAX_DIR
);
1329 lstrcpy(root
->path
, drv
);
1331 return read_tree_win(root
, path
, sortOrder
, hwnd
);
1335 /* flags to filter different file types */
1337 TF_DIRECTORIES
= 0x01,
1339 TF_DOCUMENTS
= 0x04,
1346 static ChildWnd
* alloc_child_window(LPCTSTR path
, LPITEMIDLIST pidl
, HWND hwnd
)
1348 TCHAR drv
[_MAX_DRIVE
+1], dir
[_MAX_DIR
], name
[_MAX_FNAME
], ext
[_MAX_EXT
];
1349 TCHAR b1
[BUFFER_LEN
];
1350 const static TCHAR sAsterics
[] = {'*', '\0'};
1352 ChildWnd
* child
= (ChildWnd
*) malloc(sizeof(ChildWnd
));
1353 Root
* root
= &child
->root
;
1356 memset(child
, 0, sizeof(ChildWnd
));
1358 child
->left
.treePane
= TRUE
;
1359 child
->left
.visible_cols
= 0;
1361 child
->right
.treePane
= FALSE
;
1362 #ifndef _NO_EXTENSIONS
1363 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_INDEX
|COL_LINKS
;
1365 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
;
1368 child
->pos
.length
= sizeof(WINDOWPLACEMENT
);
1369 child
->pos
.flags
= 0;
1370 child
->pos
.showCmd
= SW_SHOWNORMAL
;
1371 child
->pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
1372 child
->pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
1373 child
->pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
1374 child
->pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
1376 child
->focus_pane
= 0;
1377 child
->split_pos
= DEFAULT_SPLIT_POS
;
1378 child
->sortOrder
= SORT_NAME
;
1379 child
->header_wdths_ok
= FALSE
;
1383 lstrcpy(child
->path
, path
);
1385 _tsplitpath(path
, drv
, dir
, name
, ext
);
1388 _tcscpy(child
->filter_pattern
, sAsterics
);
1389 child
->filter_flags
= TF_ALL
;
1391 root
->entry
.level
= 0;
1393 entry
= read_tree(root
, path
, pidl
, drv
, child
->sortOrder
, hwnd
);
1395 #ifdef _SHELL_FOLDERS
1396 if (root
->entry
.etype
== ET_SHELL
)
1397 load_string(root
->entry
.data
.cFileName
, IDS_DESKTOP
);
1400 wsprintf(root
->entry
.data
.cFileName
, RS(b1
,IDS_TITLEFMT
), drv
, root
->fs
);
1402 root
->entry
.data
.dwFileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
1404 child
->left
.root
= &root
->entry
;
1405 child
->right
.root
= NULL
;
1407 set_curdir(child
, entry
, 0, hwnd
);
1413 /* free all memory associated with a child window */
1414 static void free_child_window(ChildWnd
* child
)
1416 free_entries(&child
->root
.entry
);
1421 /* get full path of specified directory entry */
1422 static void get_path(Entry
* dir
, PTSTR path
)
1428 #ifdef _SHELL_FOLDERS
1429 if (dir
->etype
== ET_SHELL
)
1434 path
[0] = TEXT('\0');
1439 hr
= (*dir
->folder
->lpVtbl
->GetAttributesOf
)(dir
->folder
, 1, (LPCITEMIDLIST
*)&dir
->pidl
, &attribs
);
1441 if (SUCCEEDED(hr
) && (attribs
&SFGAO_FILESYSTEM
)) {
1442 IShellFolder
* parent
= dir
->up
? dir
->up
->folder
: Globals
.iDesktop
;
1444 hr
= path_from_pidl(parent
, dir
->pidl
, path
, MAX_PATH
);
1450 for(entry
=dir
; entry
; level
++) {
1456 name
= entry
->data
.cFileName
;
1459 for(l
=0; *s
&& *s
!=TEXT('/') && *s
!=TEXT('\\'); s
++)
1465 memmove(path
+l
+1, path
, len
*sizeof(TCHAR
));
1466 memcpy(path
+1, name
, l
*sizeof(TCHAR
));
1469 #ifndef _NO_EXTENSIONS
1470 if (entry
->etype
== ET_UNIX
)
1471 path
[0] = TEXT('/');
1474 path
[0] = TEXT('\\');
1479 memmove(path
+l
, path
, len
*sizeof(TCHAR
));
1480 memcpy(path
, name
, l
*sizeof(TCHAR
));
1487 #ifndef _NO_EXTENSIONS
1488 if (entry
->etype
== ET_UNIX
)
1489 path
[len
++] = TEXT('/');
1492 path
[len
++] = TEXT('\\');
1495 path
[len
] = TEXT('\0');
1500 static void resize_frame_rect(HWND hwnd
, PRECT prect
)
1505 if (IsWindowVisible(Globals
.htoolbar
)) {
1506 SendMessage(Globals
.htoolbar
, WM_SIZE
, 0, 0);
1507 GetClientRect(Globals
.htoolbar
, &rt
);
1508 prect
->top
= rt
.bottom
+3;
1509 prect
->bottom
-= rt
.bottom
+3;
1512 if (IsWindowVisible(Globals
.hdrivebar
)) {
1513 SendMessage(Globals
.hdrivebar
, WM_SIZE
, 0, 0);
1514 GetClientRect(Globals
.hdrivebar
, &rt
);
1515 new_top
= --prect
->top
+ rt
.bottom
+3;
1516 MoveWindow(Globals
.hdrivebar
, 0, prect
->top
, rt
.right
, new_top
, TRUE
);
1517 prect
->top
= new_top
;
1518 prect
->bottom
-= rt
.bottom
+2;
1521 if (IsWindowVisible(Globals
.hstatusbar
)) {
1522 int parts
[] = {300, 500};
1524 SendMessage(Globals
.hstatusbar
, WM_SIZE
, 0, 0);
1525 SendMessage(Globals
.hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1526 GetClientRect(Globals
.hstatusbar
, &rt
);
1527 prect
->bottom
-= rt
.bottom
;
1530 MoveWindow(Globals
.hmdiclient
, prect
->left
-1,prect
->top
-1,prect
->right
+2,prect
->bottom
+1, TRUE
);
1533 static void resize_frame(HWND hwnd
, int cx
, int cy
)
1542 resize_frame_rect(hwnd
, &rect
);
1545 static void resize_frame_client(HWND hwnd
)
1549 GetClientRect(hwnd
, &rect
);
1551 resize_frame_rect(hwnd
, &rect
);
1555 static HHOOK hcbthook
;
1556 static ChildWnd
* newchild
= NULL
;
1558 LRESULT CALLBACK
CBTProc(int code
, WPARAM wparam
, LPARAM lparam
)
1560 if (code
==HCBT_CREATEWND
&& newchild
) {
1561 ChildWnd
* child
= newchild
;
1564 child
->hwnd
= (HWND
) wparam
;
1565 SetWindowLong(child
->hwnd
, GWL_USERDATA
, (LPARAM
)child
);
1568 return CallNextHookEx(hcbthook
, code
, wparam
, lparam
);
1571 static HWND
create_child_window(ChildWnd
* child
)
1573 MDICREATESTRUCT mcs
;
1576 mcs
.szClass
= sWINEFILETREE
;
1577 mcs
.szTitle
= (LPTSTR
)child
->path
;
1578 mcs
.hOwner
= Globals
.hInstance
;
1579 mcs
.x
= child
->pos
.rcNormalPosition
.left
;
1580 mcs
.y
= child
->pos
.rcNormalPosition
.top
;
1581 mcs
.cx
= child
->pos
.rcNormalPosition
.right
-child
->pos
.rcNormalPosition
.left
;
1582 mcs
.cy
= child
->pos
.rcNormalPosition
.bottom
-child
->pos
.rcNormalPosition
.top
;
1586 hcbthook
= SetWindowsHookEx(WH_CBT
, CBTProc
, 0, GetCurrentThreadId());
1589 child
->hwnd
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDICREATE
, 0, (LPARAM
)&mcs
);
1591 UnhookWindowsHookEx(hcbthook
);
1595 UnhookWindowsHookEx(hcbthook
);
1597 ListBox_SetItemHeight(child
->left
.hwnd
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
1598 ListBox_SetItemHeight(child
->right
.hwnd
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
1600 idx
= ListBox_FindItemData(child
->left
.hwnd
, 0, child
->left
.cur
);
1601 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
1607 struct ExecuteDialog
{
1608 TCHAR cmd
[MAX_PATH
];
1612 static INT_PTR CALLBACK
ExecuteDialogWndProg(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1614 static struct ExecuteDialog
* dlg
;
1618 dlg
= (struct ExecuteDialog
*) lparam
;
1622 int id
= (int)wparam
;
1625 GetWindowText(GetDlgItem(hwnd
, 201), dlg
->cmd
, MAX_PATH
);
1626 dlg
->cmdshow
= Button_GetState(GetDlgItem(hwnd
,214))&BST_CHECKED
?
1627 SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
1628 EndDialog(hwnd
, id
);
1629 } else if (id
== IDCANCEL
)
1630 EndDialog(hwnd
, id
);
1639 static INT_PTR CALLBACK
DestinationDlgProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1641 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
1645 SetWindowLong(hwnd
, GWL_USERDATA
, lparam
);
1646 SetWindowText(GetDlgItem(hwnd
, 201), (LPCTSTR
)lparam
);
1650 int id
= (int)wparam
;
1654 LPTSTR dest
= (LPTSTR
) GetWindowLong(hwnd
, GWL_USERDATA
);
1655 GetWindowText(GetDlgItem(hwnd
, 201), dest
, MAX_PATH
);
1656 EndDialog(hwnd
, id
);
1660 EndDialog(hwnd
, id
);
1664 MessageBox(hwnd
, RS(b1
,IDS_NO_IMPL
), RS(b2
,IDS_WINEFILE
), MB_OK
);
1676 struct FilterDialog
{
1677 TCHAR pattern
[MAX_PATH
];
1681 static INT_PTR CALLBACK
FilterDialogDlgProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1683 static struct FilterDialog
* dlg
;
1687 dlg
= (struct FilterDialog
*) lparam
;
1688 SetWindowText(GetDlgItem(hwnd
, IDC_VIEW_PATTERN
), dlg
->pattern
);
1689 Button_SetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_DIRECTORIES
), (dlg
->flags
&TF_DIRECTORIES
? BST_CHECKED
: BST_UNCHECKED
));
1690 Button_SetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_PROGRAMS
), dlg
->flags
&TF_PROGRAMS
? BST_CHECKED
: BST_UNCHECKED
);
1691 Button_SetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_DOCUMENTS
), dlg
->flags
&TF_DOCUMENTS
? BST_CHECKED
: BST_UNCHECKED
);
1692 Button_SetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_OTHERS
), dlg
->flags
&TF_OTHERS
? BST_CHECKED
: BST_UNCHECKED
);
1693 Button_SetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_HIDDEN
), dlg
->flags
&TF_HIDDEN
? BST_CHECKED
: BST_UNCHECKED
);
1697 int id
= (int)wparam
;
1702 GetWindowText(GetDlgItem(hwnd
, IDC_VIEW_PATTERN
), dlg
->pattern
, MAX_PATH
);
1704 flags
|= Button_GetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_DIRECTORIES
))&BST_CHECKED
? TF_DIRECTORIES
: 0;
1705 flags
|= Button_GetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_PROGRAMS
))&BST_CHECKED
? TF_PROGRAMS
: 0;
1706 flags
|= Button_GetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_DOCUMENTS
))&BST_CHECKED
? TF_DOCUMENTS
: 0;
1707 flags
|= Button_GetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_OTHERS
))&BST_CHECKED
? TF_OTHERS
: 0;
1708 flags
|= Button_GetCheck(GetDlgItem(hwnd
,IDC_VIEW_TYPE_HIDDEN
))&BST_CHECKED
? TF_HIDDEN
: 0;
1712 EndDialog(hwnd
, id
);
1713 } else if (id
== IDCANCEL
)
1714 EndDialog(hwnd
, id
);
1723 #ifndef _NO_EXTENSIONS
1725 static struct FullScreenParameters
{
1735 void frame_get_clientspace(HWND hwnd
, PRECT prect
)
1739 if (!IsIconic(hwnd
))
1740 GetClientRect(hwnd
, prect
);
1744 GetWindowPlacement(hwnd
, &wp
);
1746 prect
->left
= prect
->top
= 0;
1747 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
1748 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
1749 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
1750 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
1751 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
1754 if (IsWindowVisible(Globals
.htoolbar
)) {
1755 GetClientRect(Globals
.htoolbar
, &rt
);
1756 prect
->top
+= rt
.bottom
+2;
1759 if (IsWindowVisible(Globals
.hdrivebar
)) {
1760 GetClientRect(Globals
.hdrivebar
, &rt
);
1761 prect
->top
+= rt
.bottom
+2;
1764 if (IsWindowVisible(Globals
.hstatusbar
)) {
1765 GetClientRect(Globals
.hstatusbar
, &rt
);
1766 prect
->bottom
-= rt
.bottom
;
1770 static BOOL
toggle_fullscreen(HWND hwnd
)
1774 if ((g_fullscreen
.mode
=!g_fullscreen
.mode
)) {
1775 GetWindowRect(hwnd
, &g_fullscreen
.orgPos
);
1776 g_fullscreen
.wasZoomed
= IsZoomed(hwnd
);
1778 Frame_CalcFrameClient(hwnd
, &rt
);
1779 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
1780 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
1782 rt
.left
= g_fullscreen
.orgPos
.left
-rt
.left
;
1783 rt
.top
= g_fullscreen
.orgPos
.top
-rt
.top
;
1784 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+g_fullscreen
.orgPos
.right
-rt
.right
;
1785 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+g_fullscreen
.orgPos
.bottom
-rt
.bottom
;
1787 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
1789 MoveWindow(hwnd
, g_fullscreen
.orgPos
.left
, g_fullscreen
.orgPos
.top
,
1790 g_fullscreen
.orgPos
.right
-g_fullscreen
.orgPos
.left
,
1791 g_fullscreen
.orgPos
.bottom
-g_fullscreen
.orgPos
.top
, TRUE
);
1793 if (g_fullscreen
.wasZoomed
)
1794 ShowWindow(hwnd
, WS_MAXIMIZE
);
1797 return g_fullscreen
.mode
;
1800 static void fullscreen_move(HWND hwnd
)
1803 GetWindowRect(hwnd
, &pos
);
1805 Frame_CalcFrameClient(hwnd
, &rt
);
1806 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
1807 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
1809 rt
.left
= pos
.left
-rt
.left
;
1810 rt
.top
= pos
.top
-rt
.top
;
1811 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
1812 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
1814 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
1820 static void toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
)
1822 BOOL vis
= IsWindowVisible(hchild
);
1824 CheckMenuItem(Globals
.hMenuOptions
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
1826 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
1828 #ifndef _NO_EXTENSIONS
1829 if (g_fullscreen
.mode
)
1830 fullscreen_move(hwnd
);
1833 resize_frame_client(hwnd
);
1836 BOOL
activate_drive_window(LPCTSTR path
)
1838 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
1841 _tsplitpath(path
, drv1
, 0, 0, 0);
1843 /* search for a already open window for the same drive */
1844 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1845 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
1848 _tsplitpath(child
->root
.path
, drv2
, 0, 0, 0);
1850 if (!lstrcmpi(drv2
, drv1
)) {
1851 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1853 if (IsMinimized(child_wnd
))
1854 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1864 BOOL
activate_fs_window(LPCTSTR filesys
)
1868 /* search for a already open window of the given file system name */
1869 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1870 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
1873 if (!lstrcmpi(child
->root
.fs
, filesys
)) {
1874 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1876 if (IsMinimized(child_wnd
))
1877 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1887 LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1889 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
1893 DestroyWindow(hwnd
);
1895 /* clear handle variables */
1896 Globals
.hMenuFrame
= 0;
1897 Globals
.hMenuView
= 0;
1898 Globals
.hMenuOptions
= 0;
1899 Globals
.hMainWnd
= 0;
1900 Globals
.hmdiclient
= 0;
1901 Globals
.hdrivebar
= 0;
1905 /* don't exit desktop when closing file manager window */
1906 if (!Globals
.hwndParent
)
1910 case WM_INITMENUPOPUP
: {
1911 HWND hwndClient
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1913 if (!SendMessage(hwndClient
, WM_INITMENUPOPUP
, wparam
, lparam
))
1918 UINT cmd
= LOWORD(wparam
);
1919 HWND hwndClient
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1921 if (SendMessage(hwndClient
, WM_DISPATCH_COMMAND
, wparam
, lparam
))
1924 if (cmd
>=ID_DRIVE_FIRST
&& cmd
<=ID_DRIVE_FIRST
+0xFF) {
1925 TCHAR drv
[_MAX_DRIVE
], path
[MAX_PATH
];
1927 LPCTSTR root
= Globals
.drives
;
1930 for(i
=cmd
-ID_DRIVE_FIRST
; i
--; root
++)
1934 if (activate_drive_window(root
))
1937 _tsplitpath(root
, drv
, 0, 0, 0);
1939 if (!SetCurrentDirectory(drv
)) {
1940 display_error(hwnd
, GetLastError());
1944 GetCurrentDirectory(MAX_PATH
, path
); /*TODO: store last directory per drive */
1945 child
= alloc_child_window(path
, NULL
, hwnd
);
1947 if (!create_child_window(child
))
1949 } else switch(cmd
) {
1951 SendMessage(hwnd
, WM_CLOSE
, 0, 0);
1954 case ID_WINDOW_NEW
: {
1955 TCHAR path
[MAX_PATH
];
1958 GetCurrentDirectory(MAX_PATH
, path
);
1959 child
= alloc_child_window(path
, NULL
, hwnd
);
1961 if (!create_child_window(child
))
1969 case ID_WINDOW_CASCADE
:
1970 SendMessage(Globals
.hmdiclient
, WM_MDICASCADE
, 0, 0);
1973 case ID_WINDOW_TILE_HORZ
:
1974 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
1977 case ID_WINDOW_TILE_VERT
:
1978 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
1981 case ID_WINDOW_ARRANGE
:
1982 SendMessage(Globals
.hmdiclient
, WM_MDIICONARRANGE
, 0, 0);
1985 case ID_SELECT_FONT
: {
1986 TCHAR dlg_name
[BUFFER_LEN
], dlg_info
[BUFFER_LEN
];
1990 HDC hdc
= GetDC(hwnd
);
1991 chFont
.lStructSize
= sizeof(CHOOSEFONT
);
1992 chFont
.hwndOwner
= hwnd
;
1994 chFont
.lpLogFont
= &lFont
;
1995 chFont
.Flags
= CF_SCREENFONTS
| CF_FORCEFONTEXIST
| CF_LIMITSIZE
| CF_NOSCRIPTSEL
;
1996 chFont
.rgbColors
= RGB(0,0,0);
1997 chFont
.lCustData
= 0;
1998 chFont
.lpfnHook
= NULL
;
1999 chFont
.lpTemplateName
= NULL
;
2000 chFont
.hInstance
= Globals
.hInstance
;
2001 chFont
.lpszStyle
= NULL
;
2002 chFont
.nFontType
= SIMULATED_FONTTYPE
;
2003 chFont
.nSizeMin
= 0;
2004 chFont
.nSizeMax
= 24;
2006 if (ChooseFont(&chFont
)) {
2009 Globals
.hfont
= CreateFontIndirect(&lFont
);
2010 SelectFont(hdc
, Globals
.hfont
);
2011 GetTextExtentPoint32(hdc
, sSpace
, 1, &Globals
.spaceSize
);
2013 /* change font in all open child windows */
2014 for(childWnd
=GetWindow(Globals
.hmdiclient
,GW_CHILD
); childWnd
; childWnd
=GetNextWindow(childWnd
,GW_HWNDNEXT
)) {
2015 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(childWnd
, GWL_USERDATA
);
2016 SetWindowFont(child
->left
.hwnd
, Globals
.hfont
, TRUE
);
2017 SetWindowFont(child
->right
.hwnd
, Globals
.hfont
, TRUE
);
2018 ListBox_SetItemHeight(child
->left
.hwnd
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
2019 ListBox_SetItemHeight(child
->right
.hwnd
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
2020 InvalidateRect(child
->left
.hwnd
, NULL
, TRUE
);
2021 InvalidateRect(child
->right
.hwnd
, NULL
, TRUE
);
2024 else if (CommDlgExtendedError()) {
2025 LoadString(Globals
.hInstance
, IDS_FONT_SEL_DLG_NAME
, dlg_name
, BUFFER_LEN
);
2026 LoadString(Globals
.hInstance
, IDS_FONT_SEL_ERROR
, dlg_info
, BUFFER_LEN
);
2027 MessageBox(hwnd
, dlg_info
, dlg_name
, MB_OK
);
2030 ReleaseDC(hwnd
, hdc
);
2034 case ID_VIEW_TOOL_BAR
:
2035 toggle_child(hwnd
, cmd
, Globals
.htoolbar
);
2038 case ID_VIEW_DRIVE_BAR
:
2039 toggle_child(hwnd
, cmd
, Globals
.hdrivebar
);
2042 case ID_VIEW_STATUSBAR
:
2043 toggle_child(hwnd
, cmd
, Globals
.hstatusbar
);
2047 struct ExecuteDialog dlg
;
2049 memset(&dlg
, 0, sizeof(struct ExecuteDialog
));
2051 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), hwnd
, ExecuteDialogWndProg
, (LPARAM
)&dlg
) == IDOK
) {
2052 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
2054 if ((int)hinst
<= 32)
2055 display_error(hwnd
, GetLastError());
2059 case ID_CONNECT_NETWORK_DRIVE
: {
2060 DWORD ret
= WNetConnectionDialog(hwnd
, RESOURCETYPE_DISK
);
2061 if (ret
== NO_ERROR
)
2063 else if (ret
!= (DWORD
)-1) {
2064 if (ret
== ERROR_EXTENDED_ERROR
)
2065 display_network_error(hwnd
);
2067 display_error(hwnd
, ret
);
2071 case ID_DISCONNECT_NETWORK_DRIVE
: {
2072 DWORD ret
= WNetDisconnectDialog(hwnd
, RESOURCETYPE_DISK
);
2073 if (ret
== NO_ERROR
)
2075 else if (ret
!= (DWORD
)-1) {
2076 if (ret
== ERROR_EXTENDED_ERROR
)
2077 display_network_error(hwnd
);
2079 display_error(hwnd
, ret
);
2083 case ID_FORMAT_DISK
: {
2084 UINT sem_org
= SetErrorMode(0); /* Get the current Error Mode settings. */
2085 SetErrorMode(sem_org
& ~SEM_FAILCRITICALERRORS
); /* Force O/S to handle */
2086 SHFormatDrive(hwnd
, 0 /* A: */, SHFMT_ID_DEFAULT
, 0);
2087 SetErrorMode(sem_org
); /* Put it back the way it was. */
2091 WinHelp(hwnd
, RS(b1
,IDS_WINEFILE
), HELP_INDEX
, 0);
2094 #ifndef _NO_EXTENSIONS
2095 case ID_VIEW_FULLSCREEN
:
2096 CheckMenuItem(Globals
.hMenuOptions
, cmd
, toggle_fullscreen(hwnd
)?MF_CHECKED
:0);
2100 case ID_DRIVE_UNIX_FS
: {
2101 TCHAR path
[MAX_PATH
];
2104 if (activate_fs_window(RS(b1
,IDS_UNIXFS
)))
2107 getcwd(path
, MAX_PATH
);
2108 child
= alloc_child_window(path
, NULL
, hwnd
);
2110 if (!create_child_window(child
))
2114 #ifdef _SHELL_FOLDERS
2115 case ID_DRIVE_SHELL_NS
: {
2116 TCHAR path
[MAX_PATH
];
2119 if (activate_fs_window(RS(b1
,IDS_SHELL
)))
2122 GetCurrentDirectory(MAX_PATH
, path
);
2123 child
= alloc_child_window(path
, get_path_pidl(path
,hwnd
), hwnd
);
2125 if (!create_child_window(child
))
2131 /*TODO: There are even more menu items! */
2133 #ifndef _NO_EXTENSIONS
2136 WineLicense(Globals
.hMainWnd
);
2139 case ID_NO_WARRANTY
:
2140 WineWarranty(Globals
.hMainWnd
);
2145 ShellAbout(hwnd
, RS(b2
,IDS_WINE
), RS(b1
,IDS_WINEFILE
), 0);
2148 case ID_ABOUT
: /*ID_ABOUT_WINE: */
2149 ShellAbout(hwnd
, RS(b1
,IDS_WINEFILE
), NULL
, 0);
2151 #endif /* _NO_EXTENSIONS */
2154 /*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE)
2155 STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE);
2156 else */if ((cmd
<IDW_FIRST_CHILD
|| cmd
>=IDW_FIRST_CHILD
+0x100) &&
2157 (cmd
<SC_SIZE
|| cmd
>SC_RESTORE
))
2158 MessageBox(hwnd
, RS(b2
,IDS_NO_IMPL
), RS(b1
,IDS_WINEFILE
), MB_OK
);
2160 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
2165 resize_frame(hwnd
, LOWORD(lparam
), HIWORD(lparam
));
2166 break; /* do not pass message to DefFrameProc */
2168 #ifndef _NO_EXTENSIONS
2169 case WM_GETMINMAXINFO
: {
2170 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
2172 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
2173 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
2176 case FRM_CALC_CLIENT
:
2177 frame_get_clientspace(hwnd
, (PRECT
)lparam
);
2179 #endif /* _NO_EXTENSIONS */
2182 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
2189 static TCHAR g_pos_names
[COLUMNS
][20] = {
2193 static const int g_pos_align
[] = {
2195 HDF_LEFT
, /* Name */
2196 HDF_RIGHT
, /* Size */
2197 HDF_LEFT
, /* CDate */
2198 #ifndef _NO_EXTENSIONS
2199 HDF_LEFT
, /* ADate */
2200 HDF_LEFT
, /* MDate */
2201 HDF_LEFT
, /* Index */
2202 HDF_CENTER
, /* Links */
2204 HDF_CENTER
, /* Attributes */
2205 #ifndef _NO_EXTENSIONS
2206 HDF_LEFT
/* Security */
2210 static void resize_tree(ChildWnd
* child
, int cx
, int cy
)
2212 HDWP hdwp
= BeginDeferWindowPos(4);
2220 cx
= child
->split_pos
+ SPLIT_WIDTH
/2;
2222 #ifndef _NO_EXTENSIONS
2230 Header_Layout(child
->left
.hwndHeader
, &hdl
);
2232 DeferWindowPos(hdwp
, child
->left
.hwndHeader
, wp
.hwndInsertAfter
,
2233 wp
.x
-1, wp
.y
, child
->split_pos
-SPLIT_WIDTH
/2+1, wp
.cy
, wp
.flags
);
2234 DeferWindowPos(hdwp
, child
->right
.hwndHeader
, wp
.hwndInsertAfter
,
2235 rt
.left
+cx
+1, wp
.y
, wp
.cx
-cx
+2, wp
.cy
, wp
.flags
);
2237 #endif /* _NO_EXTENSIONS */
2239 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
);
2240 DeferWindowPos(hdwp
, child
->right
.hwnd
, 0, rt
.left
+cx
+1, rt
.top
, rt
.right
-cx
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
2242 EndDeferWindowPos(hdwp
);
2246 #ifndef _NO_EXTENSIONS
2248 static HWND
create_header(HWND parent
, Pane
* pane
, int id
)
2253 HWND hwnd
= CreateWindow(WC_HEADER
, 0, WS_CHILD
|WS_VISIBLE
|HDS_HORZ
/*TODO: |HDS_BUTTONS + sort orders*/,
2254 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2258 SetWindowFont(hwnd
, GetStockObject(DEFAULT_GUI_FONT
), FALSE
);
2260 hdi
.mask
= HDI_TEXT
|HDI_WIDTH
|HDI_FORMAT
;
2262 for(idx
=0; idx
<COLUMNS
; idx
++) {
2263 hdi
.pszText
= g_pos_names
[idx
];
2264 hdi
.fmt
= HDF_STRING
| g_pos_align
[idx
];
2265 hdi
.cxy
= pane
->widths
[idx
];
2266 Header_InsertItem(hwnd
, idx
, &hdi
);
2272 #endif /* _NO_EXTENSIONS */
2275 static void init_output(HWND hwnd
)
2277 const static TCHAR s1000
[] = {'1','0','0','0','\0'};
2281 HDC hdc
= GetDC(hwnd
);
2283 if (GetNumberFormat(LOCALE_USER_DEFAULT
, 0, s1000
, 0, b
, 16) > 4)
2284 Globals
.num_sep
= b
[1];
2286 Globals
.num_sep
= TEXT('.');
2288 old_font
= SelectFont(hdc
, Globals
.hfont
);
2289 GetTextExtentPoint32(hdc
, sSpace
, 1, &Globals
.spaceSize
);
2290 SelectFont(hdc
, old_font
);
2291 ReleaseDC(hwnd
, hdc
);
2294 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
);
2297 /* calculate preferred width for all visible columns */
2299 static BOOL
calc_widths(Pane
* pane
, BOOL anyway
)
2301 int col
, x
, cx
, spc
=3*Globals
.spaceSize
.cx
;
2302 int entries
= ListBox_GetCount(pane
->hwnd
);
2303 int orgWidths
[COLUMNS
];
2304 int orgPositions
[COLUMNS
+1];
2310 memcpy(orgWidths
, pane
->widths
, sizeof(orgWidths
));
2311 memcpy(orgPositions
, pane
->positions
, sizeof(orgPositions
));
2314 for(col
=0; col
<COLUMNS
; col
++)
2315 pane
->widths
[col
] = 0;
2317 hdc
= GetDC(pane
->hwnd
);
2318 hfontOld
= SelectFont(hdc
, Globals
.hfont
);
2320 for(cnt
=0; cnt
<entries
; cnt
++) {
2321 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, cnt
);
2330 dis
.hwndItem
= pane
->hwnd
;
2332 dis
.rcItem
.left
= 0;
2334 dis
.rcItem
.right
= 0;
2335 dis
.rcItem
.bottom
= 0;
2336 /*dis.itemData = 0; */
2338 draw_item(pane
, &dis
, entry
, COLUMNS
);
2341 SelectObject(hdc
, hfontOld
);
2342 ReleaseDC(pane
->hwnd
, hdc
);
2345 for(col
=0; col
<COLUMNS
; col
++) {
2346 pane
->positions
[col
] = x
;
2347 cx
= pane
->widths
[col
];
2352 if (cx
< IMAGE_WIDTH
)
2355 pane
->widths
[col
] = cx
;
2361 pane
->positions
[COLUMNS
] = x
;
2363 ListBox_SetHorizontalExtent(pane
->hwnd
, x
);
2366 if (!memcmp(orgWidths
, pane
->widths
, sizeof(orgWidths
)))
2369 /* don't move, if only collapsing an entry */
2370 if (!anyway
&& pane
->widths
[0]<orgWidths
[0] &&
2371 !memcmp(orgWidths
+1, pane
->widths
+1, sizeof(orgWidths
)-sizeof(int))) {
2372 pane
->widths
[0] = orgWidths
[0];
2373 memcpy(pane
->positions
, orgPositions
, sizeof(orgPositions
));
2378 InvalidateRect(pane
->hwnd
, 0, TRUE
);
2384 /* calculate one preferred column width */
2386 static void calc_single_width(Pane
* pane
, int col
)
2390 int entries
= ListBox_GetCount(pane
->hwnd
);
2394 pane
->widths
[col
] = 0;
2396 hdc
= GetDC(pane
->hwnd
);
2397 hfontOld
= SelectFont(hdc
, Globals
.hfont
);
2399 for(cnt
=0; cnt
<entries
; cnt
++) {
2400 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, cnt
);
2408 dis
.hwndItem
= pane
->hwnd
;
2410 dis
.rcItem
.left
= 0;
2412 dis
.rcItem
.right
= 0;
2413 dis
.rcItem
.bottom
= 0;
2414 /*dis.itemData = 0; */
2416 draw_item(pane
, &dis
, entry
, col
);
2419 SelectObject(hdc
, hfontOld
);
2420 ReleaseDC(pane
->hwnd
, hdc
);
2422 cx
= pane
->widths
[col
];
2425 cx
+= 3*Globals
.spaceSize
.cx
;
2427 if (cx
< IMAGE_WIDTH
)
2431 pane
->widths
[col
] = cx
;
2433 x
= pane
->positions
[col
] + cx
;
2435 for(; col
<COLUMNS
; ) {
2436 pane
->positions
[++col
] = x
;
2437 x
+= pane
->widths
[col
];
2440 ListBox_SetHorizontalExtent(pane
->hwnd
, x
);
2444 static BOOL
pattern_match(LPCTSTR str
, LPCTSTR pattern
)
2446 for( ; *str
&&*pattern
; str
++,pattern
++) {
2447 if (*pattern
== '*') {
2449 while(*pattern
== '*');
2455 if (_totupper(*str
)==_totupper(*pattern
) && pattern_match(str
, pattern
))
2460 else if (_totupper(*str
)!=_totupper(*pattern
) && *pattern
!='?')
2464 if (*str
|| *pattern
)
2465 if (*pattern
!='*' || pattern
[1]!='\0')
2478 static enum FILE_TYPE
get_file_type(LPCTSTR filename
);
2481 /* insert listbox entries after index idx */
2483 static int insert_entries(Pane
* pane
, Entry
* dir
, LPCTSTR pattern
, int filter_flags
, int idx
)
2490 ShowWindow(pane
->hwnd
, SW_HIDE
);
2492 for(; entry
; entry
=entry
->next
) {
2494 if (pane
->treePane
&& !(entry
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
2498 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
2499 /* don't display entries "." and ".." in the left pane */
2500 if (pane
->treePane
&& entry
->data
.cFileName
[0]==TEXT('.'))
2502 #ifndef _NO_EXTENSIONS
2503 entry
->data
.cFileName
[1]==TEXT('\0') ||
2505 (entry
->data
.cFileName
[1]==TEXT('.') && entry
->data
.cFileName
[2]==TEXT('\0')))
2508 /* filter directories in right pane */
2509 if (!pane
->treePane
&& !(filter_flags
&TF_DIRECTORIES
))
2513 /* filter using the file name pattern */
2515 if (!pattern_match(entry
->data
.cFileName
, pattern
))
2518 /* filter system and hidden files */
2519 if (!(filter_flags
&TF_HIDDEN
) && (entry
->data
.dwFileAttributes
&(FILE_ATTRIBUTE_HIDDEN
|FILE_ATTRIBUTE_SYSTEM
)))
2522 /* filter looking at the file type */
2523 if ((filter_flags
&(TF_PROGRAMS
|TF_DOCUMENTS
|TF_OTHERS
)) != (TF_PROGRAMS
|TF_DOCUMENTS
|TF_OTHERS
))
2524 switch(get_file_type(entry
->data
.cFileName
)) {
2526 if (!(filter_flags
& TF_PROGRAMS
))
2531 if (!(filter_flags
& TF_DOCUMENTS
))
2535 default: /* TF_OTHERS */
2536 if (!(filter_flags
& TF_OTHERS
))
2543 ListBox_InsertItemData(pane
->hwnd
, idx
, entry
);
2545 if (pane
->treePane
&& entry
->expanded
)
2546 idx
= insert_entries(pane
, entry
->down
, pattern
, filter_flags
, idx
);
2549 ShowWindow(pane
->hwnd
, SW_SHOW
);
2555 static void format_bytes(LPTSTR buffer
, LONGLONG bytes
)
2557 const static TCHAR sFmtGB
[] = {'%', '.', '1', 'f', ' ', 'G', 'B', '\0'};
2558 const static TCHAR sFmtMB
[] = {'%', '.', '1', 'f', ' ', 'M', 'B', '\0'};
2559 const static TCHAR sFmtkB
[] = {'%', '.', '1', 'f', ' ', 'k', 'B', '\0'};
2561 float fBytes
= (float)bytes
;
2563 if (bytes
>= 1073741824) /* 1 GB */
2564 _stprintf(buffer
, sFmtGB
, fBytes
/1073741824.f
+.5f
);
2565 else if (bytes
>= 1048576) /* 1 MB */
2566 _stprintf(buffer
, sFmtMB
, fBytes
/1048576.f
+.5f
);
2567 else if (bytes
>= 1024) /* 1 kB */
2568 _stprintf(buffer
, sFmtkB
, fBytes
/1024.f
+.5f
);
2570 _stprintf(buffer
, sLongNumFmt
, bytes
);
2573 static void set_space_status()
2575 ULARGE_INTEGER ulFreeBytesToCaller
, ulTotalBytes
, ulFreeBytes
;
2576 TCHAR fmt
[64], b1
[64], b2
[64], buffer
[BUFFER_LEN
];
2578 if (GetDiskFreeSpaceEx(NULL
, &ulFreeBytesToCaller
, &ulTotalBytes
, &ulFreeBytes
)) {
2579 format_bytes(b1
, ulFreeBytesToCaller
.QuadPart
);
2580 format_bytes(b2
, ulTotalBytes
.QuadPart
);
2581 _stprintf(buffer
, RS(fmt
,IDS_FREE_SPACE_FMT
), b1
, b2
);
2583 _tcscpy(buffer
, sQMarks
);
2585 SendMessage(Globals
.hstatusbar
, SB_SETTEXT
, 0, (LPARAM
)buffer
);
2589 static WNDPROC g_orgTreeWndProc
;
2591 static void create_tree_window(HWND parent
, Pane
* pane
, int id
, int id_header
, LPCTSTR pattern
, int filter_flags
)
2593 const static TCHAR sListBox
[] = {'L','i','s','t','B','o','x','\0'};
2595 static int s_init
= 0;
2596 Entry
* entry
= pane
->root
;
2598 pane
->hwnd
= CreateWindow(sListBox
, sEmpty
, WS_CHILD
|WS_VISIBLE
|WS_HSCROLL
|WS_VSCROLL
|
2599 LBS_DISABLENOSCROLL
|LBS_NOINTEGRALHEIGHT
|LBS_OWNERDRAWFIXED
|LBS_NOTIFY
,
2600 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2602 SetWindowLong(pane
->hwnd
, GWL_USERDATA
, (LPARAM
)pane
);
2603 g_orgTreeWndProc
= SubclassWindow(pane
->hwnd
, TreeWndProc
);
2605 SetWindowFont(pane
->hwnd
, Globals
.hfont
, FALSE
);
2607 /* insert entries into listbox */
2609 insert_entries(pane
, entry
, pattern
, filter_flags
, -1);
2611 /* calculate column widths */
2614 init_output(pane
->hwnd
);
2617 calc_widths(pane
, TRUE
);
2619 #ifndef _NO_EXTENSIONS
2620 pane
->hwndHeader
= create_header(parent
, pane
, id_header
);
2625 static void InitChildWindow(ChildWnd
* child
)
2627 create_tree_window(child
->hwnd
, &child
->left
, IDW_TREE_LEFT
, IDW_HEADER_LEFT
, NULL
, TF_ALL
);
2628 create_tree_window(child
->hwnd
, &child
->right
, IDW_TREE_RIGHT
, IDW_HEADER_RIGHT
, child
->filter_pattern
, child
->filter_flags
);
2632 static void format_date(const FILETIME
* ft
, TCHAR
* buffer
, int visible_cols
)
2638 *buffer
= TEXT('\0');
2640 if (!ft
->dwLowDateTime
&& !ft
->dwHighDateTime
)
2643 if (!FileTimeToLocalFileTime(ft
, &lft
))
2644 {err
: _tcscpy(buffer
,sQMarks
); return;}
2646 if (!FileTimeToSystemTime(&lft
, &systime
))
2649 if (visible_cols
& COL_DATE
) {
2650 len
= GetDateFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
, BUFFER_LEN
);
2655 if (visible_cols
& COL_TIME
) {
2657 buffer
[len
-1] = ' ';
2659 buffer
[len
++] = ' ';
2661 if (!GetTimeFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
+len
, BUFFER_LEN
-len
))
2662 buffer
[len
] = TEXT('\0');
2667 static void calc_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2669 RECT rt
= {0, 0, 0, 0};
2671 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
2673 if (rt
.right
> pane
->widths
[col
])
2674 pane
->widths
[col
] = rt
.right
;
2677 static void calc_tabbed_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2679 RECT rt
= {0, 0, 0, 0};
2681 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
2682 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
2684 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
2685 /*FIXME rt (0,0) ??? */
2687 if (rt
.right
> pane
->widths
[col
])
2688 pane
->widths
[col
] = rt
.right
;
2692 static void output_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
, DWORD flags
)
2694 int x
= dis
->rcItem
.left
;
2697 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2698 rt
.top
= dis
->rcItem
.top
;
2699 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2700 rt
.bottom
= dis
->rcItem
.bottom
;
2702 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_SINGLELINE
|DT_NOPREFIX
|flags
);
2705 static void output_tabbed_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2707 int x
= dis
->rcItem
.left
;
2710 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2711 rt
.top
= dis
->rcItem
.top
;
2712 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2713 rt
.bottom
= dis
->rcItem
.bottom
;
2715 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
2716 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
2718 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
2721 static void output_number(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2723 int x
= dis
->rcItem
.left
;
2730 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2731 rt
.top
= dis
->rcItem
.top
;
2732 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2733 rt
.bottom
= dis
->rcItem
.bottom
;
2738 /* insert number separator characters */
2739 pos
= lstrlen(s
) % 3;
2745 *d
++ = Globals
.num_sep
;
2749 DrawText(dis
->hDC
, b
, d
-b
, &rt
, DT_RIGHT
|DT_SINGLELINE
|DT_NOPREFIX
|DT_END_ELLIPSIS
);
2753 static BOOL
is_exe_file(LPCTSTR ext
)
2755 static const TCHAR executable_extensions
[][4] = {
2760 #ifndef _NO_EXTENSIONS
2764 #endif /* _NO_EXTENSIONS */
2768 TCHAR ext_buffer
[_MAX_EXT
];
2769 const TCHAR (*p
)[4];
2773 for(s
=ext
+1,d
=ext_buffer
; (*d
=tolower(*s
)); s
++)
2776 for(p
=executable_extensions
; (*p
)[0]; p
++)
2777 if (!_tcsicmp(ext_buffer
, *p
))
2783 static BOOL
is_registered_type(LPCTSTR ext
)
2785 /* check if there exists a classname for this file extension in the registry */
2786 if (!RegQueryValue(HKEY_CLASSES_ROOT
, ext
, NULL
, NULL
))
2792 static enum FILE_TYPE
get_file_type(LPCTSTR filename
)
2794 LPCTSTR ext
= _tcsrchr(filename
, '.');
2798 if (is_exe_file(ext
))
2799 return FT_EXECUTABLE
;
2800 else if (is_registered_type(ext
))
2807 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
)
2809 TCHAR buffer
[BUFFER_LEN
];
2811 int visible_cols
= pane
->visible_cols
;
2812 COLORREF bkcolor
, textcolor
;
2813 RECT focusRect
= dis
->rcItem
;
2820 attrs
= entry
->data
.dwFileAttributes
;
2822 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) {
2823 if (entry
->data
.cFileName
[0]==TEXT('.') && entry
->data
.cFileName
[1]==TEXT('.')
2824 && entry
->data
.cFileName
[2]==TEXT('\0'))
2825 img
= IMG_FOLDER_UP
;
2826 #ifndef _NO_EXTENSIONS
2827 else if (entry
->data
.cFileName
[0]==TEXT('.') && entry
->data
.cFileName
[1]==TEXT('\0'))
2828 img
= IMG_FOLDER_CUR
;
2831 #ifdef _NO_EXTENSIONS
2834 (pane
->treePane
&& (dis
->itemState
&ODS_FOCUS
)))
2835 img
= IMG_OPEN_FOLDER
;
2839 switch(get_file_type(entry
->data
.cFileName
)) {
2840 case FT_EXECUTABLE
: img
= IMG_EXECUTABLE
; break;
2841 case FT_DOCUMENT
: img
= IMG_DOCUMENT
; break;
2842 default: img
= IMG_FILE
;
2850 if (pane
->treePane
) {
2852 img_pos
= dis
->rcItem
.left
+ entry
->level
*(IMAGE_WIDTH
+TREE_LINE_DX
);
2854 if (calcWidthCol
== -1) {
2856 int y
= dis
->rcItem
.top
+ IMAGE_HEIGHT
/2;
2859 HRGN hrgn_org
= CreateRectRgn(0, 0, 0, 0);
2862 rt_clip
.left
= dis
->rcItem
.left
;
2863 rt_clip
.top
= dis
->rcItem
.top
;
2864 rt_clip
.right
= dis
->rcItem
.left
+pane
->widths
[col
];
2865 rt_clip
.bottom
= dis
->rcItem
.bottom
;
2867 hrgn
= CreateRectRgnIndirect(&rt_clip
);
2869 if (!GetClipRgn(dis
->hDC
, hrgn_org
)) {
2870 DeleteObject(hrgn_org
);
2874 /* HGDIOBJ holdPen = SelectObject(dis->hDC, GetStockObject(BLACK_PEN)); */
2875 ExtSelectClipRgn(dis
->hDC
, hrgn
, RGN_AND
);
2878 if ((up
=entry
->up
) != NULL
) {
2879 MoveToEx(dis
->hDC
, img_pos
-IMAGE_WIDTH
/2, y
, 0);
2880 LineTo(dis
->hDC
, img_pos
-2, y
);
2882 x
= img_pos
- IMAGE_WIDTH
/2;
2885 x
-= IMAGE_WIDTH
+TREE_LINE_DX
;
2889 && (up
->next
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
2892 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
2893 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2895 } while((up
=up
->up
) != NULL
);
2898 x
= img_pos
- IMAGE_WIDTH
/2;
2900 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
2901 LineTo(dis
->hDC
, x
, y
);
2905 && (entry
->next
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
)
2908 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2910 if (entry
->down
&& entry
->expanded
) {
2911 x
+= IMAGE_WIDTH
+TREE_LINE_DX
;
2912 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
+IMAGE_HEIGHT
+2, 0);
2913 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2916 SelectClipRgn(dis
->hDC
, hrgn_org
);
2917 if (hrgn_org
) DeleteObject(hrgn_org
);
2918 /* SelectObject(dis->hDC, holdPen); */
2919 } else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
) {
2920 int right
= img_pos
+ IMAGE_WIDTH
- TREE_LINE_DX
;
2922 if (right
> pane
->widths
[col
])
2923 pane
->widths
[col
] = right
;
2926 img_pos
= dis
->rcItem
.left
;
2929 img_pos
= dis
->rcItem
.left
;
2931 if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2932 pane
->widths
[col
] = IMAGE_WIDTH
;
2935 if (calcWidthCol
== -1) {
2936 focusRect
.left
= img_pos
-2;
2938 #ifdef _NO_EXTENSIONS
2939 if (pane
->treePane
&& entry
) {
2942 DrawText(dis
->hDC
, entry
->data
.cFileName
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
2944 focusRect
.right
= dis
->rcItem
.left
+pane
->positions
[col
+1]+TREE_LINE_DX
+ rt
.right
+2;
2948 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
)
2949 textcolor
= COLOR_COMPRESSED
;
2951 #endif /* _NO_EXTENSIONS */
2952 textcolor
= RGB(0,0,0);
2954 if (dis
->itemState
& ODS_FOCUS
) {
2955 textcolor
= RGB(255,255,255);
2956 bkcolor
= COLOR_SELECTION
;
2958 bkcolor
= RGB(255,255,255);
2961 hbrush
= CreateSolidBrush(bkcolor
);
2962 FillRect(dis
->hDC
, &focusRect
, hbrush
);
2963 DeleteObject(hbrush
);
2965 SetBkMode(dis
->hDC
, TRANSPARENT
);
2966 SetTextColor(dis
->hDC
, textcolor
);
2968 cx
= pane
->widths
[col
];
2970 if (cx
&& img
!=IMG_NONE
) {
2972 if (cx
> IMAGE_WIDTH
)
2975 #ifdef _SHELL_FOLDERS
2976 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
2977 DrawIconEx(dis
->hDC
, img_pos
, dis
->rcItem
.top
, entry
->hicon
, cx
, GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
2980 ImageList_DrawEx(Globals
.himl
, img
, dis
->hDC
,
2981 img_pos
, dis
->rcItem
.top
, cx
,
2982 IMAGE_HEIGHT
, bkcolor
, CLR_DEFAULT
, ILD_NORMAL
);
2989 #ifdef _NO_EXTENSIONS
2990 if (img
>= IMG_FOLDER_UP
)
2996 /* ouput file name */
2997 if (calcWidthCol
== -1)
2998 output_text(pane
, dis
, col
, entry
->data
.cFileName
, 0);
2999 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3000 calc_width(pane
, dis
, col
, entry
->data
.cFileName
);
3004 #ifdef _NO_EXTENSIONS
3005 if (!pane
->treePane
) {
3008 /* display file size */
3009 if (visible_cols
& COL_SIZE
) {
3010 #ifdef _NO_EXTENSIONS
3011 if (!(attrs
&FILE_ATTRIBUTE_DIRECTORY
))
3016 size
= ((ULONGLONG
)entry
->data
.nFileSizeHigh
<< 32) | entry
->data
.nFileSizeLow
;
3018 _stprintf(buffer
, sLongNumFmt
, size
);
3020 if (calcWidthCol
== -1)
3021 output_number(pane
, dis
, col
, buffer
);
3022 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3023 calc_width(pane
, dis
, col
, buffer
);/*TODO: not ever time enough */
3029 /* display file date */
3030 if (visible_cols
& (COL_DATE
|COL_TIME
)) {
3031 #ifndef _NO_EXTENSIONS
3032 format_date(&entry
->data
.ftCreationTime
, buffer
, visible_cols
);
3033 if (calcWidthCol
== -1)
3034 output_text(pane
, dis
, col
, buffer
, 0);
3035 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3036 calc_width(pane
, dis
, col
, buffer
);
3039 format_date(&entry
->data
.ftLastAccessTime
, buffer
, visible_cols
);
3040 if (calcWidthCol
== -1)
3041 output_text(pane
, dis
, col
, buffer
, 0);
3042 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3043 calc_width(pane
, dis
, col
, buffer
);
3045 #endif /* _NO_EXTENSIONS */
3047 format_date(&entry
->data
.ftLastWriteTime
, buffer
, visible_cols
);
3048 if (calcWidthCol
== -1)
3049 output_text(pane
, dis
, col
, buffer
, 0);
3050 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3051 calc_width(pane
, dis
, col
, buffer
);
3055 #ifndef _NO_EXTENSIONS
3056 if (entry
->bhfi_valid
) {
3057 ULONGLONG index
= ((ULONGLONG
)entry
->bhfi
.nFileIndexHigh
<< 32) | entry
->bhfi
.nFileIndexLow
;
3059 if (visible_cols
& COL_INDEX
) {
3060 _stprintf(buffer
, sLongHexFmt
, index
);
3062 if (calcWidthCol
== -1)
3063 output_text(pane
, dis
, col
, buffer
, DT_RIGHT
);
3064 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3065 calc_width(pane
, dis
, col
, buffer
);
3070 if (visible_cols
& COL_LINKS
) {
3071 wsprintf(buffer
, sNumFmt
, entry
->bhfi
.nNumberOfLinks
);
3073 if (calcWidthCol
== -1)
3074 output_text(pane
, dis
, col
, buffer
, DT_CENTER
);
3075 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3076 calc_width(pane
, dis
, col
, buffer
);
3082 #endif /* _NO_EXTENSIONS */
3084 /* show file attributes */
3085 if (visible_cols
& COL_ATTRIBUTES
) {
3086 #ifdef _NO_EXTENSIONS
3087 const static TCHAR s4Tabs
[] = {' ','\t',' ','\t',' ','\t',' ','\t',' ','\0'};
3088 _tcscpy(buffer
, s4Tabs
);
3090 const static TCHAR s11Tabs
[] = {' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\0'};
3091 _tcscpy(buffer
, s11Tabs
);
3094 if (attrs
& FILE_ATTRIBUTE_NORMAL
) buffer
[ 0] = 'N';
3096 if (attrs
& FILE_ATTRIBUTE_READONLY
) buffer
[ 2] = 'R';
3097 if (attrs
& FILE_ATTRIBUTE_HIDDEN
) buffer
[ 4] = 'H';
3098 if (attrs
& FILE_ATTRIBUTE_SYSTEM
) buffer
[ 6] = 'S';
3099 if (attrs
& FILE_ATTRIBUTE_ARCHIVE
) buffer
[ 8] = 'A';
3100 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
) buffer
[10] = 'C';
3101 #ifndef _NO_EXTENSIONS
3102 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) buffer
[12] = 'D';
3103 if (attrs
& FILE_ATTRIBUTE_ENCRYPTED
) buffer
[14] = 'E';
3104 if (attrs
& FILE_ATTRIBUTE_TEMPORARY
) buffer
[16] = 'T';
3105 if (attrs
& FILE_ATTRIBUTE_SPARSE_FILE
) buffer
[18] = 'P';
3106 if (attrs
& FILE_ATTRIBUTE_REPARSE_POINT
) buffer
[20] = 'Q';
3107 if (attrs
& FILE_ATTRIBUTE_OFFLINE
) buffer
[22] = 'O';
3108 if (attrs
& FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
) buffer
[24] = 'X';
3109 #endif /* _NO_EXTENSIONS */
3112 if (calcWidthCol
== -1)
3113 output_tabbed_text(pane
, dis
, col
, buffer
);
3114 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3115 calc_tabbed_width(pane
, dis
, col
, buffer
);
3121 if (flags.security) {
3122 const static TCHAR sSecTabs[] = {
3123 ' ','\t',' ','\t',' ','\t',' ',
3125 ' ','\t',' ','\t',' ','\t',' ',
3127 ' ','\t',' ','\t',' ','\t',' ',
3131 DWORD rights = get_access_mask();
3133 tcscpy(buffer, sSecTabs);
3135 if (rights & FILE_READ_DATA) buffer[ 0] = 'R';
3136 if (rights & FILE_WRITE_DATA) buffer[ 2] = 'W';
3137 if (rights & FILE_APPEND_DATA) buffer[ 4] = 'A';
3138 if (rights & FILE_READ_EA) {buffer[6] = 'entry'; buffer[ 7] = 'R';}
3139 if (rights & FILE_WRITE_EA) {buffer[9] = 'entry'; buffer[10] = 'W';}
3140 if (rights & FILE_EXECUTE) buffer[12] = 'X';
3141 if (rights & FILE_DELETE_CHILD) buffer[14] = 'D';
3142 if (rights & FILE_READ_ATTRIBUTES) {buffer[16] = 'a'; buffer[17] = 'R';}
3143 if (rights & FILE_WRITE_ATTRIBUTES) {buffer[19] = 'a'; buffer[20] = 'W';}
3144 if (rights & WRITE_DAC) buffer[22] = 'C';
3145 if (rights & WRITE_OWNER) buffer[24] = 'O';
3146 if (rights & SYNCHRONIZE) buffer[26] = 'S';
3148 output_text(dis, col++, buffer, DT_LEFT, 3, psize);
3151 if (flags.description) {
3152 get_description(buffer);
3153 output_text(dis, col++, buffer, 0, psize);
3157 #ifdef _NO_EXTENSIONS
3160 /* draw focus frame */
3161 if ((dis
->itemState
&ODS_FOCUS
) && calcWidthCol
==-1) {
3162 /* Currently [04/2000] Wine neither behaves exactly the same */
3163 /* way as WIN 95 nor like Windows NT... */
3168 if (!(GetVersion() & 0x80000000)) { /* Windows NT? */
3169 LOGBRUSH lb
= {PS_SOLID
, RGB(255,255,255)};
3170 hpen
= ExtCreatePen(PS_COSMETIC
|PS_ALTERNATE
, 1, &lb
, 0, 0);
3172 hpen
= CreatePen(PS_DOT
, 0, RGB(255,255,255));
3174 lastPen
= SelectPen(dis
->hDC
, hpen
);
3175 lastBrush
= SelectObject(dis
->hDC
, GetStockObject(HOLLOW_BRUSH
));
3176 SetROP2(dis
->hDC
, R2_XORPEN
);
3177 Rectangle(dis
->hDC
, focusRect
.left
, focusRect
.top
, focusRect
.right
, focusRect
.bottom
);
3178 SelectObject(dis
->hDC
, lastBrush
);
3179 SelectObject(dis
->hDC
, lastPen
);
3182 #endif /* _NO_EXTENSIONS */
3186 #ifdef _NO_EXTENSIONS
3188 static void draw_splitbar(HWND hwnd
, int x
)
3191 HDC hdc
= GetDC(hwnd
);
3193 GetClientRect(hwnd
, &rt
);
3195 rt
.left
= x
- SPLIT_WIDTH
/2;
3196 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
3198 InvertRect(hdc
, &rt
);
3200 ReleaseDC(hwnd
, hdc
);
3203 #endif /* _NO_EXTENSIONS */
3206 #ifndef _NO_EXTENSIONS
3208 static void set_header(Pane
* pane
)
3211 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
3214 item
.mask
= HDI_WIDTH
;
3217 for(; x
+pane
->widths
[i
]<scroll_pos
&& i
<COLUMNS
; i
++) {
3218 x
+= pane
->widths
[i
];
3219 Header_SetItem(pane
->hwndHeader
, i
, &item
);
3223 x
+= pane
->widths
[i
];
3224 item
.cxy
= x
- scroll_pos
;
3225 Header_SetItem(pane
->hwndHeader
, i
++, &item
);
3227 for(; i
<COLUMNS
; i
++) {
3228 item
.cxy
= pane
->widths
[i
];
3229 x
+= pane
->widths
[i
];
3230 Header_SetItem(pane
->hwndHeader
, i
, &item
);
3235 static LRESULT
pane_notify(Pane
* pane
, NMHDR
* pnmh
)
3237 switch(pnmh
->code
) {
3239 case HDN_ENDTRACK
: {
3240 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
3241 int idx
= phdn
->iItem
;
3242 int dx
= phdn
->pitem
->cxy
- pane
->widths
[idx
];
3246 GetClientRect(pane
->hwnd
, &clnt
);
3248 /* move immediate to simulate HDS_FULLDRAG (for now [04/2000] not really needed with WINELIB) */
3249 Header_SetItem(pane
->hwndHeader
, idx
, phdn
->pitem
);
3251 pane
->widths
[idx
] += dx
;
3253 for(i
=idx
; ++i
<=COLUMNS
; )
3254 pane
->positions
[i
] += dx
;
3257 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
3261 rt_scr
.left
= pane
->positions
[idx
+1]-scroll_pos
;
3263 rt_scr
.right
= clnt
.right
;
3264 rt_scr
.bottom
= clnt
.bottom
;
3266 rt_clip
.left
= pane
->positions
[idx
]-scroll_pos
;
3268 rt_clip
.right
= clnt
.right
;
3269 rt_clip
.bottom
= clnt
.bottom
;
3271 if (rt_scr
.left
< 0) rt_scr
.left
= 0;
3272 if (rt_clip
.left
< 0) rt_clip
.left
= 0;
3274 ScrollWindowEx(pane
->hwnd
, dx
, 0, &rt_scr
, &rt_clip
, 0, 0, SW_INVALIDATE
);
3276 rt_clip
.right
= pane
->positions
[idx
+1];
3277 RedrawWindow(pane
->hwnd
, &rt_clip
, 0, RDW_INVALIDATE
|RDW_UPDATENOW
);
3279 if (pnmh
->code
== HDN_ENDTRACK
) {
3280 ListBox_SetHorizontalExtent(pane
->hwnd
, pane
->positions
[COLUMNS
]);
3282 if (GetScrollPos(pane
->hwnd
, SB_HORZ
) != scroll_pos
)
3290 case HDN_DIVIDERDBLCLICK
: {
3291 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
3294 calc_single_width(pane
, phdn
->iItem
);
3295 item
.mask
= HDI_WIDTH
;
3296 item
.cxy
= pane
->widths
[phdn
->iItem
];
3298 Header_SetItem(pane
->hwndHeader
, phdn
->iItem
, &item
);
3299 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3306 #endif /* _NO_EXTENSIONS */
3309 static void scan_entry(ChildWnd
* child
, Entry
* entry
, int idx
, HWND hwnd
)
3311 TCHAR path
[MAX_PATH
];
3312 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
3314 /* delete sub entries in left pane */
3316 LRESULT res
= ListBox_GetItemData(child
->left
.hwnd
, idx
+1);
3317 Entry
* sub
= (Entry
*) res
;
3319 if (res
==LB_ERR
|| !sub
|| sub
->level
<=entry
->level
)
3322 ListBox_DeleteString(child
->left
.hwnd
, idx
+1);
3325 /* empty right pane */
3326 ListBox_ResetContent(child
->right
.hwnd
);
3328 /* release memory */
3329 free_entries(entry
);
3331 /* read contents from disk */
3332 #ifdef _SHELL_FOLDERS
3333 if (entry
->etype
== ET_SHELL
)
3335 read_directory(entry
, NULL
, child
->sortOrder
, hwnd
);
3340 get_path(entry
, path
);
3341 read_directory(entry
, path
, child
->sortOrder
, hwnd
);
3344 /* insert found entries in right pane */
3345 insert_entries(&child
->right
, entry
->down
, child
->filter_pattern
, child
->filter_flags
, -1);
3346 calc_widths(&child
->right
, FALSE
);
3347 #ifndef _NO_EXTENSIONS
3348 set_header(&child
->right
);
3351 child
->header_wdths_ok
= FALSE
;
3353 SetCursor(old_cursor
);
3357 /* expand a directory entry */
3359 static BOOL
expand_entry(ChildWnd
* child
, Entry
* dir
)
3364 if (!dir
|| dir
->expanded
|| !dir
->down
)
3369 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='\0' && p
->next
) {
3372 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='.' &&
3373 p
->data
.cFileName
[2]=='\0' && p
->next
)
3377 /* no subdirectories ? */
3378 if (!(p
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
3381 idx
= ListBox_FindItemData(child
->left
.hwnd
, 0, dir
);
3383 dir
->expanded
= TRUE
;
3385 /* insert entries in left pane */
3386 insert_entries(&child
->left
, p
, NULL
, TF_ALL
, idx
);
3388 if (!child
->header_wdths_ok
) {
3389 if (calc_widths(&child
->left
, FALSE
)) {
3390 #ifndef _NO_EXTENSIONS
3391 set_header(&child
->left
);
3394 child
->header_wdths_ok
= TRUE
;
3402 static void collapse_entry(Pane
* pane
, Entry
* dir
)
3404 int idx
= ListBox_FindItemData(pane
->hwnd
, 0, dir
);
3406 ShowWindow(pane
->hwnd
, SW_HIDE
);
3408 /* hide sub entries */
3410 LRESULT res
= ListBox_GetItemData(pane
->hwnd
, idx
+1);
3411 Entry
* sub
= (Entry
*) res
;
3413 if (res
==LB_ERR
|| !sub
|| sub
->level
<=dir
->level
)
3416 ListBox_DeleteString(pane
->hwnd
, idx
+1);
3419 dir
->expanded
= FALSE
;
3421 ShowWindow(pane
->hwnd
, SW_SHOW
);
3425 static void refresh_right_pane(ChildWnd
* child
)
3427 ListBox_ResetContent(child
->right
.hwnd
);
3428 insert_entries(&child
->right
, child
->right
.root
, child
->filter_pattern
, child
->filter_flags
, -1);
3429 calc_widths(&child
->right
, FALSE
);
3431 #ifndef _NO_EXTENSIONS
3432 set_header(&child
->right
);
3436 static void set_curdir(ChildWnd
* child
, Entry
* entry
, int idx
, HWND hwnd
)
3438 TCHAR path
[MAX_PATH
];
3442 child
->left
.cur
= entry
;
3444 child
->right
.root
= entry
->down
? entry
->down
: entry
;
3445 child
->right
.cur
= entry
;
3447 if (!entry
->scanned
)
3448 scan_entry(child
, entry
, idx
, hwnd
);
3450 refresh_right_pane(child
);
3452 get_path(entry
, path
);
3453 lstrcpy(child
->path
, path
);
3455 if (child
->hwnd
) /* only change window title, if the window already exists */
3456 SetWindowText(child
->hwnd
, path
);
3459 if (SetCurrentDirectory(path
))
3464 static void refresh_child(ChildWnd
* child
)
3466 TCHAR path
[MAX_PATH
], drv
[_MAX_DRIVE
+1];
3470 get_path(child
->left
.cur
, path
);
3471 _tsplitpath(path
, drv
, NULL
, NULL
, NULL
);
3473 child
->right
.root
= NULL
;
3475 scan_entry(child
, &child
->root
.entry
, 0, child
->hwnd
);
3477 entry
= read_tree(&child
->root
, path
, NULL
, drv
, child
->sortOrder
, child
->hwnd
);
3479 insert_entries(&child
->left
, child
->root
.entry
.down
, NULL
, TF_ALL
, 0);
3481 set_curdir(child
, entry
, 0, child
->hwnd
);
3483 idx
= ListBox_FindItemData(child
->left
.hwnd
, 0, child
->left
.cur
);
3484 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
3488 static void create_drive_bar()
3490 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0};
3491 #ifndef _NO_EXTENSIONS
3492 TCHAR b1
[BUFFER_LEN
];
3497 GetLogicalDriveStrings(BUFFER_LEN
, Globals
.drives
);
3499 Globals
.hdrivebar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
3500 IDW_DRIVEBAR
, 2, Globals
.hInstance
, IDB_DRIVEBAR
, &drivebarBtn
,
3501 1, 16, 13, 16, 13, sizeof(TBBUTTON
));
3503 #ifndef _NO_EXTENSIONS
3505 /* insert unix file system button */
3509 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b1
);
3511 drivebarBtn
.idCommand
= ID_DRIVE_UNIX_FS
;
3512 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3513 drivebarBtn
.iString
++;
3515 #ifdef _SHELL_FOLDERS
3516 /* insert shell namespace button */
3517 load_string(b1
, IDS_SHELL
);
3518 b1
[lstrlen(b1
)+1] = '\0';
3519 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b1
);
3521 drivebarBtn
.idCommand
= ID_DRIVE_SHELL_NS
;
3522 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3523 drivebarBtn
.iString
++;
3526 /* register windows drive root strings */
3527 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)Globals
.drives
);
3530 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
3532 for(p
=Globals
.drives
; *p
; ) {
3533 #ifdef _NO_EXTENSIONS
3534 /* insert drive letter */
3535 TCHAR b
[3] = {tolower(*p
)};
3536 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b
);
3538 switch(GetDriveType(p
)) {
3539 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
3540 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
3541 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
3542 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
3543 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
3546 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3547 drivebarBtn
.idCommand
++;
3548 drivebarBtn
.iString
++;
3554 static void refresh_drives()
3558 /* destroy drive bar */
3559 DestroyWindow(Globals
.hdrivebar
);
3560 Globals
.hdrivebar
= 0;
3562 /* re-create drive bar */
3565 /* update window layout */
3566 GetClientRect(Globals
.hMainWnd
, &rect
);
3567 SendMessage(Globals
.hMainWnd
, WM_SIZE
, 0, MAKELONG(rect
.right
, rect
.bottom
));
3571 BOOL
launch_file(HWND hwnd
, LPCTSTR cmd
, UINT nCmdShow
)
3573 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, cmd
, NULL
/*parameters*/, NULL
/*dir*/, nCmdShow
);
3575 if ((int)hinst
<= 32) {
3576 display_error(hwnd
, GetLastError());
3584 BOOL
launch_fileA(HWND hwnd
, LPSTR cmd
, UINT nCmdShow
)
3586 HINSTANCE hinst
= ShellExecuteA(hwnd
, NULL
/*operation*/, cmd
, NULL
/*parameters*/, NULL
/*dir*/, nCmdShow
);
3588 if ((int)hinst
<= 32) {
3589 display_error(hwnd
, GetLastError());
3598 BOOL
launch_entry(Entry
* entry
, HWND hwnd
, UINT nCmdShow
)
3600 TCHAR cmd
[MAX_PATH
];
3602 #ifdef _SHELL_FOLDERS
3603 if (entry
->etype
== ET_SHELL
) {
3606 SHELLEXECUTEINFO shexinfo
;
3608 shexinfo
.cbSize
= sizeof(SHELLEXECUTEINFO
);
3609 shexinfo
.fMask
= SEE_MASK_IDLIST
;
3610 shexinfo
.hwnd
= hwnd
;
3611 shexinfo
.lpVerb
= NULL
;
3612 shexinfo
.lpFile
= NULL
;
3613 shexinfo
.lpParameters
= NULL
;
3614 shexinfo
.lpDirectory
= NULL
;
3615 shexinfo
.nShow
= nCmdShow
;
3616 shexinfo
.lpIDList
= get_to_absolute_pidl(entry
, hwnd
);
3618 if (!ShellExecuteEx(&shexinfo
)) {
3619 display_error(hwnd
, GetLastError());
3623 if (shexinfo
.lpIDList
!= entry
->pidl
)
3624 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, shexinfo
.lpIDList
);
3630 get_path(entry
, cmd
);
3632 /* start program, open document... */
3633 return launch_file(hwnd
, cmd
, nCmdShow
);
3637 static void activate_entry(ChildWnd
* child
, Pane
* pane
, HWND hwnd
)
3639 Entry
* entry
= pane
->cur
;
3644 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
3645 int scanned_old
= entry
->scanned
;
3648 scan_entry(child
, entry
, ListBox_GetCurSel(child
->left
.hwnd
), hwnd
);
3650 #ifndef _NO_EXTENSIONS
3651 if (entry
->data
.cFileName
[0]=='.' && entry
->data
.cFileName
[1]=='\0')
3655 if (entry
->data
.cFileName
[0]=='.' && entry
->data
.cFileName
[1]=='.' && entry
->data
.cFileName
[2]=='\0') {
3656 entry
= child
->left
.cur
->up
;
3657 collapse_entry(&child
->left
, entry
);
3659 } else if (entry
->expanded
)
3660 collapse_entry(pane
, child
->left
.cur
);
3662 expand_entry(child
, child
->left
.cur
);
3664 if (!pane
->treePane
) focus_entry
: {
3665 int idx
= ListBox_FindItemData(child
->left
.hwnd
, ListBox_GetCurSel(child
->left
.hwnd
), entry
);
3666 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
3667 set_curdir(child
, entry
, idx
, hwnd
);
3672 calc_widths(pane
, FALSE
);
3674 #ifndef _NO_EXTENSIONS
3679 launch_entry(entry
, child
->hwnd
, SW_SHOWNORMAL
);
3684 static BOOL
pane_command(Pane
* pane
, UINT cmd
)
3688 if (pane
->visible_cols
) {
3689 pane
->visible_cols
= 0;
3690 calc_widths(pane
, TRUE
);
3691 #ifndef _NO_EXTENSIONS
3694 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3695 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
|MF_CHECKED
);
3696 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_ALL_ATTRIBUTES
, MF_BYCOMMAND
);
3697 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SELECTED_ATTRIBUTES
, MF_BYCOMMAND
);
3701 case ID_VIEW_ALL_ATTRIBUTES
:
3702 if (pane
->visible_cols
!= COL_ALL
) {
3703 pane
->visible_cols
= COL_ALL
;
3704 calc_widths(pane
, TRUE
);
3705 #ifndef _NO_EXTENSIONS
3708 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3709 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
);
3710 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_ALL_ATTRIBUTES
, MF_BYCOMMAND
|MF_CHECKED
);
3711 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SELECTED_ATTRIBUTES
, MF_BYCOMMAND
);
3715 #ifndef _NO_EXTENSIONS
3716 case ID_PREFERRED_SIZES
: {
3717 calc_widths(pane
, TRUE
);
3719 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3723 /* TODO: more command ids... */
3733 static void set_sort_order(ChildWnd
* child
, SORT_ORDER sortOrder
)
3735 if (child
->sortOrder
!= sortOrder
) {
3736 child
->sortOrder
= sortOrder
;
3737 refresh_child(child
);
3741 static void update_view_menu(ChildWnd
* child
)
3743 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SORT_NAME
, child
->sortOrder
==SORT_NAME
? MF_CHECKED
: MF_UNCHECKED
);
3744 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SORT_TYPE
, child
->sortOrder
==SORT_EXT
? MF_CHECKED
: MF_UNCHECKED
);
3745 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SORT_SIZE
, child
->sortOrder
==SORT_SIZE
? MF_CHECKED
: MF_UNCHECKED
);
3746 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SORT_DATE
, child
->sortOrder
==SORT_DATE
? MF_CHECKED
: MF_UNCHECKED
);
3750 static IContextMenu2
* s_pctxmenu2
= NULL
;
3751 static IContextMenu3
* s_pctxmenu3
= NULL
;
3753 static void CtxMenu_reset()
3759 IContextMenu
* CtxMenu_query_interfaces(IContextMenu
* pcm1
)
3761 IContextMenu
* pcm
= NULL
;
3765 if ((*pcm1
->lpVtbl
->QueryInterface
)(pcm1
, &IID_IContextMenu3
, (void**)&pcm
) == NOERROR
)
3766 s_pctxmenu3
= (LPCONTEXTMENU3
)pcm
;
3767 else if ((*pcm1
->lpVtbl
->QueryInterface
)(pcm1
, &IID_IContextMenu2
, (void**)&pcm
) == NOERROR
)
3768 s_pctxmenu2
= (LPCONTEXTMENU2
)pcm
;
3771 (*pcm1
->lpVtbl
->Release
)(pcm1
);
3777 static BOOL
CtxMenu_HandleMenuMsg(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
3780 if (SUCCEEDED((*s_pctxmenu3
->lpVtbl
->HandleMenuMsg
)(s_pctxmenu3
, nmsg
, wparam
, lparam
)))
3785 if (SUCCEEDED((*s_pctxmenu2
->lpVtbl
->HandleMenuMsg
)(s_pctxmenu2
, nmsg
, wparam
, lparam
)))
3792 static HRESULT
ShellFolderContextMenu(IShellFolder
* shell_folder
, HWND hwndParent
, int cidl
, LPCITEMIDLIST
* apidl
, int x
, int y
)
3796 HRESULT hr
= (*shell_folder
->lpVtbl
->GetUIObjectOf
)(shell_folder
, hwndParent
, cidl
, apidl
, &IID_IContextMenu
, NULL
, (LPVOID
*)&pcm
);
3797 /* HRESULT hr = CDefFolderMenu_Create2(dir?dir->_pidl:DesktopFolder(), hwndParent, 1, &pidl, shell_folder, NULL, 0, NULL, &pcm); */
3799 if (SUCCEEDED(hr
)) {
3800 HMENU hmenu
= CreatePopupMenu();
3802 pcm
= CtxMenu_query_interfaces(pcm
);
3805 hr
= (*pcm
->lpVtbl
->QueryContextMenu
)(pcm
, hmenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, CMF_NORMAL
);
3807 if (SUCCEEDED(hr
)) {
3808 UINT idCmd
= TrackPopupMenu(hmenu
, TPM_LEFTALIGN
|TPM_RETURNCMD
|TPM_RIGHTBUTTON
, x
, y
, 0, hwndParent
, NULL
);
3813 CMINVOKECOMMANDINFO cmi
;
3815 cmi
.cbSize
= sizeof(CMINVOKECOMMANDINFO
);
3817 cmi
.hwnd
= hwndParent
;
3818 cmi
.lpVerb
= (LPCSTR
)(INT_PTR
)(idCmd
- FCIDM_SHVIEWFIRST
);
3819 cmi
.lpParameters
= NULL
;
3820 cmi
.lpDirectory
= NULL
;
3821 cmi
.nShow
= SW_SHOWNORMAL
;
3825 hr
= (*pcm
->lpVtbl
->InvokeCommand
)(pcm
, &cmi
);
3830 (*pcm
->lpVtbl
->Release
)(pcm
);
3837 LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
3839 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(hwnd
, GWL_USERDATA
);
3844 LPDRAWITEMSTRUCT dis
= (LPDRAWITEMSTRUCT
)lparam
;
3845 Entry
* entry
= (Entry
*) dis
->itemData
;
3847 if (dis
->CtlID
== IDW_TREE_LEFT
)
3848 draw_item(&child
->left
, dis
, entry
, -1);
3849 else if (dis
->CtlID
== IDW_TREE_RIGHT
)
3850 draw_item(&child
->right
, dis
, entry
, -1);
3852 goto draw_menu_item
;
3857 InitChildWindow(child
);
3861 free_child_window(child
);
3862 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
3869 GetClientRect(hwnd
, &rt
);
3870 BeginPaint(hwnd
, &ps
);
3871 rt
.left
= child
->split_pos
-SPLIT_WIDTH
/2;
3872 rt
.right
= child
->split_pos
+SPLIT_WIDTH
/2+1;
3873 lastBrush
= SelectBrush(ps
.hdc
, (HBRUSH
)GetStockObject(COLOR_SPLITBAR
));
3874 Rectangle(ps
.hdc
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
3875 SelectObject(ps
.hdc
, lastBrush
);
3876 #ifdef _NO_EXTENSIONS
3877 rt
.top
= rt
.bottom
- GetSystemMetrics(SM_CYHSCROLL
);
3878 FillRect(ps
.hdc
, &rt
, GetStockObject(BLACK_BRUSH
));
3880 EndPaint(hwnd
, &ps
);
3884 if (LOWORD(lparam
) == HTCLIENT
) {
3887 ScreenToClient(hwnd
, &pt
);
3889 if (pt
.x
>=child
->split_pos
-SPLIT_WIDTH
/2 && pt
.x
<child
->split_pos
+SPLIT_WIDTH
/2+1) {
3890 SetCursor(LoadCursor(0, IDC_SIZEWE
));
3896 case WM_LBUTTONDOWN
: {
3898 int x
= GET_X_LPARAM(lparam
);
3900 GetClientRect(hwnd
, &rt
);
3902 if (x
>=child
->split_pos
-SPLIT_WIDTH
/2 && x
<child
->split_pos
+SPLIT_WIDTH
/2+1) {
3903 last_split
= child
->split_pos
;
3904 #ifdef _NO_EXTENSIONS
3905 draw_splitbar(hwnd
, last_split
);
3913 if (GetCapture() == hwnd
) {
3914 #ifdef _NO_EXTENSIONS
3916 int x
= LOWORD(lparam
);
3917 draw_splitbar(hwnd
, last_split
);
3919 GetClientRect(hwnd
, &rt
);
3920 child
->split_pos
= x
;
3921 resize_tree(child
, rt
.right
, rt
.bottom
);
3927 #ifdef _NO_EXTENSIONS
3928 case WM_CAPTURECHANGED
:
3929 if (GetCapture()==hwnd
&& last_split
>=0)
3930 draw_splitbar(hwnd
, last_split
);
3935 if (wparam
== VK_ESCAPE
)
3936 if (GetCapture() == hwnd
) {
3938 #ifdef _NO_EXTENSIONS
3939 draw_splitbar(hwnd
, last_split
);
3941 child
->split_pos
= last_split
;
3943 GetClientRect(hwnd
, &rt
);
3944 resize_tree(child
, rt
.right
, rt
.bottom
);
3947 SetCursor(LoadCursor(0, IDC_ARROW
));
3952 if (GetCapture() == hwnd
) {
3954 int x
= LOWORD(lparam
);
3956 #ifdef _NO_EXTENSIONS
3957 HDC hdc
= GetDC(hwnd
);
3958 GetClientRect(hwnd
, &rt
);
3960 rt
.left
= last_split
-SPLIT_WIDTH
/2;
3961 rt
.right
= last_split
+SPLIT_WIDTH
/2+1;
3962 InvertRect(hdc
, &rt
);
3965 rt
.left
= x
-SPLIT_WIDTH
/2;
3966 rt
.right
= x
+SPLIT_WIDTH
/2+1;
3967 InvertRect(hdc
, &rt
);
3969 ReleaseDC(hwnd
, hdc
);
3971 GetClientRect(hwnd
, &rt
);
3973 if (x
>=0 && x
<rt
.right
) {
3974 child
->split_pos
= x
;
3975 resize_tree(child
, rt
.right
, rt
.bottom
);
3976 rt
.left
= x
-SPLIT_WIDTH
/2;
3977 rt
.right
= x
+SPLIT_WIDTH
/2+1;
3978 InvalidateRect(hwnd
, &rt
, FALSE
);
3979 UpdateWindow(child
->left
.hwnd
);
3981 UpdateWindow(child
->right
.hwnd
);
3987 #ifndef _NO_EXTENSIONS
3988 case WM_GETMINMAXINFO
:
3989 DefMDIChildProc(hwnd
, nmsg
, wparam
, lparam
);
3991 {LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
3993 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
3994 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
3996 #endif /* _NO_EXTENSIONS */
3999 if (SetCurrentDirectory(child
->path
))
4001 SetFocus(child
->focus_pane
? child
->right
.hwnd
: child
->left
.hwnd
);
4004 case WM_DISPATCH_COMMAND
: {
4005 Pane
* pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
4007 switch(LOWORD(wparam
)) {
4008 case ID_WINDOW_NEW
: {
4009 ChildWnd
* new_child
= alloc_child_window(child
->path
, NULL
, hwnd
);
4011 if (!create_child_window(new_child
))
4018 refresh_child(child
);
4022 activate_entry(child
, pane
, hwnd
);
4025 case ID_FILE_MOVE
: {
4026 TCHAR new_name
[BUFFER_LEN
], old_name
[BUFFER_LEN
];
4029 get_path(pane
->cur
, new_name
);
4031 ret
= DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_SELECT_DESTINATION
), hwnd
, DestinationDlgProc
, (LPARAM
)new_name
);
4035 if (new_name
[0]!='/' && new_name
[1]!=':') {
4036 get_path(pane
->cur
->up
, old_name
);
4037 len
= lstrlen(old_name
);
4039 if (old_name
[len
-1]!='\\' && old_name
[len
-1]!='/')
4040 old_name
[len
++] = '/';
4042 lstrcpy(old_name
+len
, new_name
);
4043 lstrcpy(new_name
, old_name
);
4046 get_path(pane
->cur
, old_name
);
4048 if (MoveFileEx(old_name
, new_name
, MOVEFILE_COPY_ALLOWED
)) {
4049 if (pane
->treePane
) {
4050 pane
->root
->scanned
= FALSE
;
4051 pane
->cur
= pane
->root
;
4052 activate_entry(child
, pane
, hwnd
);
4055 refresh_child(child
);
4058 display_error(hwnd
, GetLastError());
4061 case ID_VIEW_SORT_NAME
:
4062 set_sort_order(child
, SORT_NAME
);
4065 case ID_VIEW_SORT_TYPE
:
4066 set_sort_order(child
, SORT_EXT
);
4069 case ID_VIEW_SORT_SIZE
:
4070 set_sort_order(child
, SORT_SIZE
);
4073 case ID_VIEW_SORT_DATE
:
4074 set_sort_order(child
, SORT_DATE
);
4077 case ID_VIEW_FILTER
: {
4078 struct FilterDialog dlg
;
4080 memset(&dlg
, 0, sizeof(struct FilterDialog
));
4081 _tcscpy(dlg
.pattern
, child
->filter_pattern
);
4082 dlg
.flags
= child
->filter_flags
;
4084 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_DIALOG_VIEW_TYPE
), hwnd
, FilterDialogDlgProc
, (LPARAM
)&dlg
) == IDOK
) {
4085 _tcscpy(child
->filter_pattern
, dlg
.pattern
);
4086 child
->filter_flags
= dlg
.flags
;
4087 refresh_right_pane(child
);
4091 case ID_VIEW_SPLIT
: {
4092 last_split
= child
->split_pos
;
4093 #ifdef _NO_EXTENSIONS
4094 draw_splitbar(hwnd
, last_split
);
4100 return pane_command(pane
, LOWORD(wparam
));
4106 Pane
* pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
4108 switch(HIWORD(wparam
)) {
4109 case LBN_SELCHANGE
: {
4110 int idx
= ListBox_GetCurSel(pane
->hwnd
);
4111 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, idx
);
4113 if (pane
== &child
->left
)
4114 set_curdir(child
, entry
, idx
, hwnd
);
4120 activate_entry(child
, pane
, hwnd
);
4125 #ifndef _NO_EXTENSIONS
4127 NMHDR
* pnmh
= (NMHDR
*) lparam
;
4128 return pane_notify(pnmh
->idFrom
==IDW_HEADER_LEFT
? &child
->left
: &child
->right
, pnmh
);}
4131 #ifdef _SHELL_FOLDERS
4132 case WM_CONTEXTMENU
: {
4137 /* first select the current item in the listbox */
4138 HWND hpanel
= (HWND
) wparam
;
4139 pt_clnt
.x
= pt
.x
= (short)LOWORD(lparam
);
4140 pt_clnt
.y
= pt
.y
= (short)HIWORD(lparam
);
4141 ScreenToClient(hpanel
, &pt_clnt
);
4142 SendMessage(hpanel
, WM_LBUTTONDOWN
, 0, MAKELONG(pt_clnt
.x
, pt_clnt
.y
));
4143 SendMessage(hpanel
, WM_LBUTTONUP
, 0, MAKELONG(pt_clnt
.x
, pt_clnt
.y
));
4145 /* now create the popup menu using shell namespace and IContextMenu */
4146 pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
4147 idx
= ListBox_GetCurSel(pane
->hwnd
);
4151 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, idx
);
4153 LPITEMIDLIST pidl_abs
= get_to_absolute_pidl(entry
, hwnd
);
4156 IShellFolder
* parentFolder
;
4157 LPCITEMIDLIST pidlLast
;
4159 /* get and use the parent folder to display correct context menu in all cases */
4160 if (SUCCEEDED(SHBindToParent(pidl_abs
, &IID_IShellFolder
, (LPVOID
*)&parentFolder
, &pidlLast
))) {
4161 hr
= ShellFolderContextMenu(parentFolder
, hwnd
, 1, &pidlLast
, pt
.x
, pt
.y
);
4163 (*parentFolder
->lpVtbl
->Release
)(parentFolder
);
4166 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, pidl_abs
);
4172 case WM_MEASUREITEM
:
4174 if (!wparam
) /* Is the message menu-related? */
4175 if (CtxMenu_HandleMenuMsg(nmsg
, wparam
, lparam
))
4180 case WM_INITMENUPOPUP
:
4181 if (CtxMenu_HandleMenuMsg(nmsg
, wparam
, lparam
))
4184 update_view_menu(child
);
4187 case WM_MENUCHAR
: /* only supported by IContextMenu3 */
4189 LRESULT lResult
= 0;
4191 (*s_pctxmenu3
->lpVtbl
->HandleMenuMsg2
)(s_pctxmenu3
, nmsg
, wparam
, lparam
, &lResult
);
4199 if (wparam
!= SIZE_MINIMIZED
)
4200 resize_tree(child
, LOWORD(lparam
), HIWORD(lparam
));
4204 return DefMDIChildProc(hwnd
, nmsg
, wparam
, lparam
);
4211 LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
4213 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(GetParent(hwnd
), GWL_USERDATA
);
4214 Pane
* pane
= (Pane
*) GetWindowLong(hwnd
, GWL_USERDATA
);
4218 #ifndef _NO_EXTENSIONS
4225 child
->focus_pane
= pane
==&child
->right
? 1: 0;
4226 ListBox_SetSel(hwnd
, TRUE
, 1);
4227 /*TODO: check menu items */
4231 if (wparam
== VK_TAB
) {
4232 /*TODO: SetFocus(Globals.hdrivebar) */
4233 SetFocus(child
->focus_pane
? child
->left
.hwnd
: child
->right
.hwnd
);
4237 return CallWindowProc(g_orgTreeWndProc
, hwnd
, nmsg
, wparam
, lparam
);
4241 static void InitInstance(HINSTANCE hinstance
)
4243 const static TCHAR sFont
[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
4250 INITCOMMONCONTROLSEX icc
= {
4251 sizeof(INITCOMMONCONTROLSEX
),
4257 setlocale(LC_COLLATE
, ""); /* set collating rules to local settings for compareName */
4259 InitCommonControlsEx(&icc
);
4262 /* register frame window class */
4264 wcFrame
.cbSize
= sizeof(WNDCLASSEX
);
4266 wcFrame
.lpfnWndProc
= FrameWndProc
;
4267 wcFrame
.cbClsExtra
= 0;
4268 wcFrame
.cbWndExtra
= 0;
4269 wcFrame
.hInstance
= hinstance
;
4270 wcFrame
.hIcon
= LoadIcon(hinstance
, MAKEINTRESOURCE(IDI_WINEFILE
));
4271 wcFrame
.hCursor
= LoadCursor(0, IDC_ARROW
);
4272 wcFrame
.hbrBackground
= 0;
4273 wcFrame
.lpszMenuName
= 0;
4274 wcFrame
.lpszClassName
= sWINEFILEFRAME
;
4275 wcFrame
.hIconSm
= (HICON
)LoadImage(hinstance
,
4276 MAKEINTRESOURCE(IDI_WINEFILE
),
4278 GetSystemMetrics(SM_CXSMICON
),
4279 GetSystemMetrics(SM_CYSMICON
),
4282 Globals
.hframeClass
= RegisterClassEx(&wcFrame
);
4285 /* register tree windows class */
4287 wcChild
.style
= CS_CLASSDC
|CS_DBLCLKS
|CS_VREDRAW
;
4288 wcChild
.lpfnWndProc
= ChildWndProc
;
4289 wcChild
.cbClsExtra
= 0;
4290 wcChild
.cbWndExtra
= 0;
4291 wcChild
.hInstance
= hinstance
;
4293 wcChild
.hCursor
= LoadCursor(0, IDC_ARROW
);
4294 wcChild
.hbrBackground
= 0;
4295 wcChild
.lpszMenuName
= 0;
4296 wcChild
.lpszClassName
= sWINEFILETREE
;
4298 hChildClass
= RegisterClass(&wcChild
);
4301 Globals
.haccel
= LoadAccelerators(hinstance
, MAKEINTRESOURCE(IDA_WINEFILE
));
4303 Globals
.hfont
= CreateFont(-MulDiv(8,GetDeviceCaps(hdc
,LOGPIXELSY
),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, sFont
);
4307 Globals
.hInstance
= hinstance
;
4309 #ifdef _SHELL_FOLDERS
4311 CoGetMalloc(MEMCTX_TASK
, &Globals
.iMalloc
);
4312 SHGetDesktopFolder(&Globals
.iDesktop
);
4314 Globals
.cfStrFName
= RegisterClipboardFormatA(CFSTR_FILENAME
);
4316 Globals
.cfStrFName
= RegisterClipboardFormat(CFSTR_FILENAME
);
4320 /* load column strings */
4323 load_string(g_pos_names
[col
++], IDS_COL_NAME
);
4324 load_string(g_pos_names
[col
++], IDS_COL_SIZE
);
4325 load_string(g_pos_names
[col
++], IDS_COL_CDATE
);
4326 #ifndef _NO_EXTENSIONS
4327 load_string(g_pos_names
[col
++], IDS_COL_ADATE
);
4328 load_string(g_pos_names
[col
++], IDS_COL_MDATE
);
4329 load_string(g_pos_names
[col
++], IDS_COL_IDX
);
4330 load_string(g_pos_names
[col
++], IDS_COL_LINKS
);
4332 load_string(g_pos_names
[col
++], IDS_COL_ATTR
);
4333 #ifndef _NO_EXTENSIONS
4334 load_string(g_pos_names
[col
++], IDS_COL_SEC
);
4339 void show_frame(HWND hwndParent
, int cmdshow
)
4341 const static TCHAR sMDICLIENT
[] = {'M','D','I','C','L','I','E','N','T','\0'};
4343 TCHAR path
[MAX_PATH
], b1
[BUFFER_LEN
];
4345 HMENU hMenuFrame
, hMenuWindow
;
4347 CLIENTCREATESTRUCT ccs
;
4349 if (Globals
.hMainWnd
)
4352 Globals
.hwndParent
= hwndParent
;
4354 hMenuFrame
= LoadMenu(Globals
.hInstance
, MAKEINTRESOURCE(IDM_WINEFILE
));
4355 hMenuWindow
= GetSubMenu(hMenuFrame
, GetMenuItemCount(hMenuFrame
)-2);
4357 Globals
.hMenuFrame
= hMenuFrame
;
4358 Globals
.hMenuView
= GetSubMenu(hMenuFrame
, 3);
4359 Globals
.hMenuOptions
= GetSubMenu(hMenuFrame
, 4);
4361 ccs
.hWindowMenu
= hMenuWindow
;
4362 ccs
.idFirstChild
= IDW_FIRST_CHILD
;
4365 /* create main window */
4366 Globals
.hMainWnd
= CreateWindowEx(0, (LPCTSTR
)(int)Globals
.hframeClass
, RS(b1
,IDS_WINE_FILE
), WS_OVERLAPPEDWINDOW
,
4367 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
4368 hwndParent
, Globals
.hMenuFrame
, Globals
.hInstance
, 0/*lpParam*/);
4371 Globals
.hmdiclient
= CreateWindowEx(0, sMDICLIENT
, NULL
,
4372 WS_CHILD
|WS_CLIPCHILDREN
|WS_VSCROLL
|WS_HSCROLL
|WS_VISIBLE
|WS_BORDER
,
4374 Globals
.hMainWnd
, 0, Globals
.hInstance
, &ccs
);
4377 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_DRIVE_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
4382 TBBUTTON toolbarBtns
[] = {
4383 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
4384 {0, ID_WINDOW_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
4385 {1, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
4386 {2, ID_WINDOW_TILE_HORZ
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
4387 {3, ID_WINDOW_TILE_VERT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
4389 {4, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
4390 {5, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
4393 Globals
.htoolbar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
,
4394 IDW_TOOLBAR
, 2, Globals
.hInstance
, IDB_TOOLBAR
, toolbarBtns
,
4395 sizeof(toolbarBtns
)/sizeof(TBBUTTON
), 16, 15, 16, 15, sizeof(TBBUTTON
));
4396 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_TOOL_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
4399 Globals
.hstatusbar
= CreateStatusWindow(WS_CHILD
|WS_VISIBLE
, 0, Globals
.hMainWnd
, IDW_STATUSBAR
);
4400 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
4402 /* CreateStatusWindow does not accept WS_BORDER
4403 Globals.hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
4404 WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
4405 Globals.hMainWnd, (HMENU)IDW_STATUSBAR, hinstance, 0);*/
4407 /*TODO: read paths and window placements from registry */
4408 GetCurrentDirectory(MAX_PATH
, path
);
4410 ShowWindow(Globals
.hMainWnd
, cmdshow
);
4412 #if defined(_SHELL_FOLDERS) && !defined(__WINE__)
4413 /* Shell Namespace as default: */
4414 child
= alloc_child_window(path
, get_path_pidl(path
,Globals
.hMainWnd
), Globals
.hMainWnd
);
4416 child
= alloc_child_window(path
, NULL
, Globals
.hMainWnd
);
4419 child
->pos
.showCmd
= SW_SHOWMAXIMIZED
;
4420 child
->pos
.rcNormalPosition
.left
= 0;
4421 child
->pos
.rcNormalPosition
.top
= 0;
4422 child
->pos
.rcNormalPosition
.right
= 320;
4423 child
->pos
.rcNormalPosition
.bottom
= 280;
4425 if (!create_child_window(child
))
4428 SetWindowPlacement(child
->hwnd
, &child
->pos
);
4430 Globals
.himl
= ImageList_LoadBitmap(Globals
.hInstance
, MAKEINTRESOURCE(IDB_IMAGES
), 16, 0, RGB(0,255,0));
4432 Globals
.prescan_node
= FALSE
;
4434 UpdateWindow(Globals
.hMainWnd
);
4439 #ifdef _SHELL_FOLDERS
4440 (*Globals
.iDesktop
->lpVtbl
->Release
)(Globals
.iDesktop
);
4441 (*Globals
.iMalloc
->lpVtbl
->Release
)(Globals
.iMalloc
);
4445 ImageList_Destroy(Globals
.himl
);
4449 /* search for already running win[e]files */
4451 static int g_foundPrevInstance
= 0;
4453 static BOOL CALLBACK
EnumWndProc(HWND hwnd
, LPARAM lparam
)
4457 GetClassName(hwnd
, cls
, 128);
4459 if (!lstrcmp(cls
, (LPCTSTR
)lparam
)) {
4460 g_foundPrevInstance
++;
4467 /* search for window of given class name to allow only one running instance */
4468 int find_window_class(LPCTSTR classname
)
4470 EnumWindows(EnumWndProc
, (LPARAM
)classname
);
4472 if (g_foundPrevInstance
)
4479 int winefile_main(HINSTANCE hinstance
, HWND hwndParent
, int cmdshow
)
4483 InitInstance(hinstance
);
4485 if (cmdshow
== SW_SHOWNORMAL
)
4486 /*TODO: read window placement from registry */
4487 cmdshow
= SW_MAXIMIZE
;
4489 show_frame(hwndParent
, cmdshow
);
4491 while(GetMessage(&msg
, 0, 0, 0)) {
4492 if (Globals
.hmdiclient
&& TranslateMDISysAccel(Globals
.hmdiclient
, &msg
))
4495 if (Globals
.hMainWnd
&& TranslateAccelerator(Globals
.hMainWnd
, Globals
.haccel
, &msg
))
4498 TranslateMessage(&msg
);
4499 DispatchMessage(&msg
);
4508 int APIENTRY
WinMain(HINSTANCE hinstance
,
4509 HINSTANCE previnstance
,
4513 #ifdef _NO_EXTENSIONS
4514 if (find_window_class(sWINEFILEFRAME
))
4518 winefile_main(hinstance
, 0, cmdshow
);