4 * Copyright 2000 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;
68 WINEFILE_GLOBALS Globals
;
70 extern void WineLicense(HWND hwnd
);
71 extern void WineWarranty(HWND hwnd
);
81 typedef struct _Entry
{
92 #ifndef _NO_EXTENSIONS
93 BY_HANDLE_FILE_INFORMATION bhfi
;
95 enum ENTRY_TYPE etype
;
106 TCHAR path
[MAX_PATH
];
107 TCHAR volname
[_MAX_FNAME
];
117 COL_ATTRIBUTES
= 0x08,
119 #ifdef _NO_EXTENSIONS
120 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
124 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
|COL_INDEX
|COL_LINKS
137 #ifndef _NO_EXTENSIONS
141 #ifndef _NO_EXTENSIONS
147 int positions
[COLUMNS
+1];
159 int focus_pane
; /* 0: left 1: right */
162 BOOL header_wdths_ok
;
164 TCHAR path
[MAX_PATH
];
167 SORT_ORDER sortOrder
;
171 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
);
172 static void set_curdir(ChildWnd
* child
, Entry
* entry
, HWND hwnd
);
173 static void get_path(Entry
* dir
, PTSTR path
);
175 LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
176 LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
177 LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
180 static void display_error(HWND hwnd
, DWORD error
)
184 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_FROM_SYSTEM
,
185 0, error
, MAKELANGID(LANG_NEUTRAL
,SUBLANG_DEFAULT
), (PTSTR
)&msg
, 0, NULL
))
186 MessageBox(hwnd
, msg
, TEXT("Winefile"), MB_OK
);
188 MessageBox(hwnd
, TEXT("Error"), TEXT("Winefile"), MB_OK
);
194 /* allocate and initialise a directory entry */
195 static Entry
* alloc_entry()
197 Entry
* entry
= (Entry
*) malloc(sizeof(Entry
));
199 #ifdef _SHELL_FOLDERS
201 entry
->folder
= NULL
;
208 /* free a directory entry */
209 static void free_entry(Entry
* entry
)
211 #ifdef _SHELL_FOLDERS
212 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
213 DestroyIcon(entry
->hicon
);
215 if (entry
->folder
&& entry
->folder
!=Globals
.iDesktop
)
216 (*entry
->folder
->lpVtbl
->Release
)(entry
->folder
);
219 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, entry
->pidl
);
225 /* recursively free all child entries */
226 static void free_entries(Entry
* dir
)
228 Entry
*entry
, *next
=dir
->down
;
244 static void read_directory_win(Entry
* dir
, LPCTSTR path
)
246 Entry
* first_entry
= NULL
;
250 int level
= dir
->level
+ 1;
251 WIN32_FIND_DATA w32fd
;
253 #ifndef _NO_EXTENSIONS
257 TCHAR buffer
[MAX_PATH
], *p
;
258 for(p
=buffer
; *path
; )
261 lstrcpy(p
, TEXT("\\*"));
263 hFind
= FindFirstFile(buffer
, &w32fd
);
265 if (hFind
!= INVALID_HANDLE_VALUE
) {
267 entry
= alloc_entry();
275 memcpy(&entry
->data
, &w32fd
, sizeof(WIN32_FIND_DATA
));
278 entry
->expanded
= FALSE
;
279 entry
->scanned
= FALSE
;
280 entry
->level
= level
;
282 #ifdef _NO_EXTENSIONS
283 /* hide directory entry "." */
284 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
285 LPCTSTR name
= entry
->data
.cFileName
;
287 if (name
[0]=='.' && name
[1]=='\0')
291 entry
->etype
= ET_WINDOWS
;
292 entry
->bhfi_valid
= FALSE
;
294 lstrcpy(p
+1, entry
->data
.cFileName
);
296 hFile
= CreateFile(buffer
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
,
297 0, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0);
299 if (hFile
!= INVALID_HANDLE_VALUE
) {
300 if (GetFileInformationByHandle(hFile
, &entry
->bhfi
))
301 entry
->bhfi_valid
= TRUE
;
308 } while(FindNextFile(hFind
, &entry
->data
));
315 dir
->down
= first_entry
;
320 static Entry
* find_entry_win(Entry
* dir
, LPCTSTR name
)
324 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
326 LPCTSTR q
= entry
->data
.cFileName
;
329 if (!*p
|| *p
==TEXT('\\') || *p
==TEXT('/'))
331 } while(tolower(*p
++) == tolower(*q
++));
334 q
= entry
->data
.cAlternateFileName
;
337 if (!*p
|| *p
==TEXT('\\') || *p
==TEXT('/'))
339 } while(tolower(*p
++) == tolower(*q
++));
346 static Entry
* read_tree_win(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
348 TCHAR buffer
[MAX_PATH
];
349 Entry
* entry
= &root
->entry
;
353 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
355 #ifndef _NO_EXTENSIONS
356 entry
->etype
= ET_WINDOWS
;
360 while(*s
&& *s
!=TEXT('\\') && *s
!=TEXT('/'))
363 while(*s
==TEXT('\\') || *s
==TEXT('/'))
369 read_directory(entry
, buffer
, sortOrder
, hwnd
);
372 entry
->expanded
= TRUE
;
377 entry
= find_entry_win(entry
, s
);
380 SetCursor(old_cursor
);
386 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
388 BOOL
time_to_filetime(const time_t* t
, FILETIME
* ftime
)
390 struct tm
* tm
= gmtime(t
);
396 stime
.wYear
= tm
->tm_year
+1900;
397 stime
.wMonth
= tm
->tm_mon
+1;
398 /* stime.wDayOfWeek */
399 stime
.wDay
= tm
->tm_mday
;
400 stime
.wHour
= tm
->tm_hour
;
401 stime
.wMinute
= tm
->tm_min
;
402 stime
.wSecond
= tm
->tm_sec
;
404 return SystemTimeToFileTime(&stime
, ftime
);
407 static void read_directory_unix(Entry
* dir
, LPCTSTR path
)
409 Entry
* first_entry
= NULL
;
413 int level
= dir
->level
+ 1;
415 DIR* pdir
= opendir(path
);
420 TCHAR buffer
[MAX_PATH
], *p
;
422 for(p
=buffer
; *path
; )
425 if (p
==buffer
|| p
[-1]!='/')
428 while((ent
=readdir(pdir
))) {
429 entry
= alloc_entry();
437 entry
->etype
= ET_UNIX
;
439 lstrcpy(entry
->data
.cFileName
, ent
->d_name
);
440 entry
->data
.dwFileAttributes
= ent
->d_name
[0]=='.'? FILE_ATTRIBUTE_HIDDEN
: 0;
442 strcpy(p
, ent
->d_name
);
444 if (!stat(buffer
, &st
)) {
445 if (S_ISDIR(st
.st_mode
))
446 entry
->data
.dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
448 entry
->data
.nFileSizeLow
= st
.st_size
& 0xFFFFFFFF;
449 entry
->data
.nFileSizeHigh
= st
.st_size
>> 32;
451 memset(&entry
->data
.ftCreationTime
, 0, sizeof(FILETIME
));
452 time_to_filetime(&st
.st_atime
, &entry
->data
.ftLastAccessTime
);
453 time_to_filetime(&st
.st_mtime
, &entry
->data
.ftLastWriteTime
);
455 entry
->bhfi
.nFileIndexLow
= ent
->d_ino
;
456 entry
->bhfi
.nFileIndexHigh
= 0;
458 entry
->bhfi
.nNumberOfLinks
= st
.st_nlink
;
460 entry
->bhfi_valid
= TRUE
;
462 entry
->data
.nFileSizeLow
= 0;
463 entry
->data
.nFileSizeHigh
= 0;
464 entry
->bhfi_valid
= FALSE
;
469 entry
->expanded
= FALSE
;
470 entry
->scanned
= FALSE
;
471 entry
->level
= level
;
481 dir
->down
= first_entry
;
485 static Entry
* find_entry_unix(Entry
* dir
, LPCTSTR name
)
489 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
491 LPCTSTR q
= entry
->data
.cFileName
;
494 if (!*p
|| *p
==TEXT('/'))
496 } while(*p
++ == *q
++);
502 static Entry
* read_tree_unix(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
504 TCHAR buffer
[MAX_PATH
];
505 Entry
* entry
= &root
->entry
;
509 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
511 entry
->etype
= ET_UNIX
;
514 while(*s
&& *s
!=TEXT('/'))
517 while(*s
== TEXT('/'))
523 read_directory(entry
, buffer
, sortOrder
, hwnd
);
526 entry
->expanded
= TRUE
;
531 entry
= find_entry_unix(entry
, s
);
534 SetCursor(old_cursor
);
539 #endif /* !defined(_NO_EXTENSIONS) && defined(__WINE__) */
542 #ifdef _SHELL_FOLDERS
545 #define tcscpyn strcpyn
546 #define get_strret get_strretW
547 #define path_from_pidl path_from_pidlW
549 #define tcscpyn wcscpyn
550 #define get_strret get_strretA
551 #define path_from_pidl path_from_pidlA
555 static LPSTR
strcpyn(LPSTR dest
, LPCSTR source
, size_t count
)
560 for(s
=source
; count
&&(*d
++=*s
++); )
566 static LPWSTR
wcscpyn(LPWSTR dest
, LPCWSTR source
, size_t count
)
571 for(s
=source
; count
&&(*d
++=*s
++); )
578 static void get_strretA(STRRET
* str
, const SHITEMID
* shiid
, LPSTR buffer
, int len
)
582 WideCharToMultiByte(CP_ACP
, 0, str
->UNION_MEMBER(pOleStr
), -1, buffer
, len
, NULL
, NULL
);
586 strcpyn(buffer
, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), len
);
590 strcpyn(buffer
, str
->UNION_MEMBER(cStr
), len
);
594 static void get_strretW(STRRET
* str
, const SHITEMID
* shiid
, LPWSTR buffer
, int len
)
598 wcscpyn(buffer
, str
->UNION_MEMBER(pOleStr
), len
);
602 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), -1, buffer
, len
);
606 MultiByteToWideChar(CP_ACP
, 0, str
->UNION_MEMBER(cStr
), -1, buffer
, len
);
611 static void free_strret(STRRET
* str
)
613 if (str
->uType
== STRRET_WSTR
)
614 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, str
->UNION_MEMBER(pOleStr
));
618 HRESULT
name_from_pidl(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPTSTR buffer
, int len
, SHGDNF flags
)
622 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, flags
, &str
);
625 get_strret(&str
, &pidl
->mkid
, buffer
, len
);
634 HRESULT
path_from_pidlA(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPSTR buffer
, int len
)
638 /* SHGDN_FORPARSING: get full path of id list */
639 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, SHGDN_FORPARSING
, &str
);
642 get_strretA(&str
, &pidl
->mkid
, buffer
, len
);
650 HRESULT
path_from_pidlW(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPWSTR buffer
, int len
)
654 /* SHGDN_FORPARSING: get full path of id list */
655 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, SHGDN_FORPARSING
, &str
);
658 get_strretW(&str
, &pidl
->mkid
, buffer
, len
);
667 /* create an item id list from a file system path */
669 static LPITEMIDLIST
get_path_pidl(LPTSTR path
, HWND hwnd
)
676 LPWSTR buffer
= path
;
678 WCHAR buffer
[MAX_PATH
];
679 MultiByteToWideChar(CP_ACP
, 0, path
, -1, buffer
, MAX_PATH
);
682 hr
= (*Globals
.iDesktop
->lpVtbl
->ParseDisplayName
)(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
690 /* convert an item id list from relative to absolute (=relative to the desktop) format */
692 static LPITEMIDLIST
get_to_absolute_pidl(Entry
* entry
, HWND hwnd
)
694 if (entry
->up
&& entry
->up
->etype
==ET_SHELL
) {
695 IShellFolder
* folder
= entry
->up
->folder
;
696 WCHAR buffer
[MAX_PATH
];
698 HRESULT hr
= path_from_pidlW(folder
, entry
->pidl
, buffer
, MAX_PATH
);
704 hr
= (*Globals
.iDesktop
->lpVtbl
->ParseDisplayName
)(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
709 } else if (entry
->etype
== ET_WINDOWS
) {
710 TCHAR path
[MAX_PATH
];
712 get_path(entry
, path
);
714 return get_path_pidl(path
, hwnd
);
715 } else if (entry
->pidl
)
716 return ILClone(entry
->pidl
);
722 HICON
extract_icon(IShellFolder
* folder
, LPCITEMIDLIST pidl
)
724 IExtractIcon
* pExtract
;
726 if (SUCCEEDED((*folder
->lpVtbl
->GetUIObjectOf
)(folder
, 0, 1, (LPCITEMIDLIST
*)&pidl
, &IID_IExtractIcon
, 0, (LPVOID
*)&pExtract
))) {
727 TCHAR path
[_MAX_PATH
];
732 if (SUCCEEDED((*pExtract
->lpVtbl
->GetIconLocation
)(pExtract
, GIL_FORSHELL
, path
, _MAX_PATH
, &idx
, &flags
))) {
733 if (!(flags
& GIL_NOTFILENAME
)) {
735 idx
= 0; /* special case for some control panel applications */
737 if ((int)ExtractIconEx(path
, idx
, 0, &hicon
, 1) > 0)
738 flags
&= ~GIL_DONTCACHE
;
740 HICON hIconLarge
= 0;
742 HRESULT hr
= (*pExtract
->lpVtbl
->Extract
)(pExtract
, path
, idx
, &hIconLarge
, &hicon
, MAKELONG(0/*GetSystemMetrics(SM_CXICON)*/,GetSystemMetrics(SM_CXSMICON
)));
745 DestroyIcon(hIconLarge
);
756 static Entry
* find_entry_shell(Entry
* dir
, LPITEMIDLIST pidl
)
760 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
761 if (entry
->pidl
->mkid
.cb
== pidl
->mkid
.cb
&&
762 !memcmp(entry
->pidl
, pidl
, entry
->pidl
->mkid
.cb
))
769 static Entry
* read_tree_shell(Root
* root
, LPITEMIDLIST pidl
, SORT_ORDER sortOrder
, HWND hwnd
)
771 Entry
* entry
= &root
->entry
;
773 LPITEMIDLIST next_pidl
= pidl
;
774 IShellFolder
* folder
;
775 IShellFolder
* child
= NULL
;
778 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
780 #ifndef _NO_EXTENSIONS
781 entry
->etype
= ET_SHELL
;
784 folder
= Globals
.iDesktop
;
787 entry
->pidl
= next_pidl
;
788 entry
->folder
= folder
;
793 /* copy first element of item idlist */
794 next_pidl
= (*Globals
.iMalloc
->lpVtbl
->Alloc
)(Globals
.iMalloc
, pidl
->mkid
.cb
+sizeof(USHORT
));
795 memcpy(next_pidl
, pidl
, pidl
->mkid
.cb
);
796 ((LPITEMIDLIST
)((LPBYTE
)next_pidl
+pidl
->mkid
.cb
))->mkid
.cb
= 0;
798 hr
= (*folder
->lpVtbl
->BindToObject
)(folder
, next_pidl
, 0, &IID_IShellFolder
, (void**)&child
);
802 read_directory(entry
, NULL
, sortOrder
, hwnd
);
805 entry
->expanded
= TRUE
;
807 next
= find_entry_shell(entry
, next_pidl
);
814 /* go to next element */
815 pidl
= (LPITEMIDLIST
) ((LPBYTE
)pidl
+pidl
->mkid
.cb
);
818 SetCursor(old_cursor
);
824 static void fill_w32fdata_shell(IShellFolder
* folder
, LPCITEMIDLIST pidl
, SFGAOF attribs
, WIN32_FIND_DATA
* w32fdata
)
826 if (!(attribs
& SFGAO_FILESYSTEM
) ||
827 FAILED(SHGetDataFromIDList(folder
, pidl
, SHGDFIL_FINDDATA
, w32fdata
, sizeof(WIN32_FIND_DATA
)))) {
828 WIN32_FILE_ATTRIBUTE_DATA fad
;
829 IDataObject
* pDataObj
;
831 STGMEDIUM medium
= {0, {0}, 0};
832 FORMATETC fmt
= {Globals
.cfStrFName
, 0, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
834 HRESULT hr
= (*folder
->lpVtbl
->GetUIObjectOf
)(folder
, 0, 1, &pidl
, &IID_IDataObject
, 0, (LPVOID
*)&pDataObj
);
837 hr
= (*pDataObj
->lpVtbl
->GetData
)(pDataObj
, &fmt
, &medium
);
839 (*pDataObj
->lpVtbl
->Release
)(pDataObj
);
842 LPCTSTR path
= (LPCTSTR
)GlobalLock(medium
.UNION_MEMBER(hGlobal
));
843 UINT sem_org
= SetErrorMode(SEM_FAILCRITICALERRORS
);
845 if (GetFileAttributesEx(path
, GetFileExInfoStandard
, &fad
)) {
846 w32fdata
->dwFileAttributes
= fad
.dwFileAttributes
;
847 w32fdata
->ftCreationTime
= fad
.ftCreationTime
;
848 w32fdata
->ftLastAccessTime
= fad
.ftLastAccessTime
;
849 w32fdata
->ftLastWriteTime
= fad
.ftLastWriteTime
;
851 if (!(fad
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
852 w32fdata
->nFileSizeLow
= fad
.nFileSizeLow
;
853 w32fdata
->nFileSizeHigh
= fad
.nFileSizeHigh
;
857 SetErrorMode(sem_org
);
859 GlobalUnlock(medium
.UNION_MEMBER(hGlobal
));
860 GlobalFree(medium
.UNION_MEMBER(hGlobal
));
865 if (attribs
& (SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
))
866 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
868 if (attribs
& SFGAO_READONLY
)
869 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_READONLY
;
871 if (attribs
& SFGAO_COMPRESSED
)
872 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_COMPRESSED
;
876 static void read_directory_shell(Entry
* dir
, HWND hwnd
)
878 IShellFolder
* folder
= dir
->folder
;
879 int level
= dir
->level
+ 1;
885 Entry
* first_entry
= NULL
;
892 hr
= (*folder
->lpVtbl
->EnumObjects
)(folder
, hwnd
, SHCONTF_FOLDERS
|SHCONTF_NONFOLDERS
|SHCONTF_INCLUDEHIDDEN
|SHCONTF_SHAREABLE
|SHCONTF_STORAGE
, &idlist
);
896 #define FETCH_ITEM_COUNT 32
897 LPITEMIDLIST pidls
[FETCH_ITEM_COUNT
];
902 memset(pidls
, 0, sizeof(pidls
));
904 hr
= (*idlist
->lpVtbl
->Next
)(idlist
, FETCH_ITEM_COUNT
, pidls
, &cnt
);
911 for(n
=0; n
<cnt
; ++n
) {
912 entry
= alloc_entry();
920 memset(&entry
->data
, 0, sizeof(WIN32_FIND_DATA
));
921 entry
->bhfi_valid
= FALSE
;
923 attribs
= ~SFGAO_FILESYSTEM
; /*SFGAO_HASSUBFOLDER|SFGAO_FOLDER; SFGAO_FILESYSTEM sorgt dafür, daß "My Documents" anstatt von "Martin's Documents" angezeigt wird */
925 hr
= (*folder
->lpVtbl
->GetAttributesOf
)(folder
, 1, (LPCITEMIDLIST
*)&pidls
[n
], &attribs
);
928 if (attribs
!= (SFGAOF
)~SFGAO_FILESYSTEM
) {
929 fill_w32fdata_shell(folder
, pidls
[n
], attribs
, &entry
->data
);
931 entry
->bhfi_valid
= TRUE
;
937 entry
->pidl
= pidls
[n
];
939 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
940 hr
= (*folder
->lpVtbl
->BindToObject
)(folder
, pidls
[n
], 0, &IID_IShellFolder
, (void**)&child
);
943 entry
->folder
= child
;
945 entry
->folder
= NULL
;
948 entry
->folder
= NULL
;
950 if (!entry
->data
.cFileName
[0])
951 /*hr = */name_from_pidl(folder
, pidls
[n
], entry
->data
.cFileName
, MAX_PATH
, /*SHGDN_INFOLDER*/0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/);
953 /* get display icons for files and virtual objects */
954 if (!(entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
955 !(attribs
& SFGAO_FILESYSTEM
)) {
956 entry
->hicon
= extract_icon(folder
, pidls
[n
]);
959 entry
->hicon
= (HICON
)-1; /* don't try again later */
964 entry
->expanded
= FALSE
;
965 entry
->scanned
= FALSE
;
966 entry
->level
= level
;
968 #ifndef _NO_EXTENSIONS
969 entry
->etype
= ET_SHELL
;
970 entry
->bhfi_valid
= FALSE
;
977 (*idlist
->lpVtbl
->Release
)(idlist
);
983 dir
->down
= first_entry
;
987 #endif /* _SHELL_FOLDERS */
990 /* sort order for different directory/file types */
999 /* distinguish between ".", ".." and any other directory names */
1000 static int TypeOrderFromDirname(LPCTSTR name
)
1002 if (name
[0] == '.') {
1003 if (name
[1] == '\0')
1004 return TO_DOT
; /* "." */
1006 if (name
[1]=='.' && name
[2]=='\0')
1007 return TO_DOTDOT
; /* ".." */
1010 return TO_OTHER_DIR
; /* anything else */
1013 /* directories first... */
1014 static int compareType(const WIN32_FIND_DATA
* fd1
, const WIN32_FIND_DATA
* fd2
)
1016 int order1
= fd1
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1017 int order2
= fd2
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1019 /* Handle "." and ".." as special case and move them at the very first beginning. */
1020 if (order1
==TO_DIR
&& order2
==TO_DIR
) {
1021 order1
= TypeOrderFromDirname(fd1
->cFileName
);
1022 order2
= TypeOrderFromDirname(fd2
->cFileName
);
1025 return order2
==order1
? 0: order1
<order2
? -1: 1;
1029 static int compareName(const void* arg1
, const void* arg2
)
1031 const WIN32_FIND_DATA
* fd1
= &(*(Entry
**)arg1
)->data
;
1032 const WIN32_FIND_DATA
* fd2
= &(*(Entry
**)arg2
)->data
;
1034 int cmp
= compareType(fd1
, fd2
);
1038 return lstrcmpi(fd1
->cFileName
, fd2
->cFileName
);
1041 static int compareExt(const void* arg1
, const void* arg2
)
1043 const WIN32_FIND_DATA
* fd1
= &(*(Entry
**)arg1
)->data
;
1044 const WIN32_FIND_DATA
* fd2
= &(*(Entry
**)arg2
)->data
;
1045 const TCHAR
*name1
, *name2
, *ext1
, *ext2
;
1047 int cmp
= compareType(fd1
, fd2
);
1051 name1
= fd1
->cFileName
;
1052 name2
= fd2
->cFileName
;
1054 ext1
= _tcsrchr(name1
, TEXT('.'));
1055 ext2
= _tcsrchr(name2
, TEXT('.'));
1067 cmp
= lstrcmpi(ext1
, ext2
);
1071 return lstrcmpi(name1
, name2
);
1074 static int compareSize(const void* arg1
, const void* arg2
)
1076 WIN32_FIND_DATA
* fd1
= &(*(Entry
**)arg1
)->data
;
1077 WIN32_FIND_DATA
* fd2
= &(*(Entry
**)arg2
)->data
;
1079 int cmp
= compareType(fd1
, fd2
);
1083 cmp
= fd2
->nFileSizeHigh
- fd1
->nFileSizeHigh
;
1090 cmp
= fd2
->nFileSizeLow
- fd1
->nFileSizeLow
;
1092 return cmp
<0? -1: cmp
>0? 1: 0;
1095 static int compareDate(const void* arg1
, const void* arg2
)
1097 WIN32_FIND_DATA
* fd1
= &(*(Entry
**)arg1
)->data
;
1098 WIN32_FIND_DATA
* fd2
= &(*(Entry
**)arg2
)->data
;
1100 int cmp
= compareType(fd1
, fd2
);
1104 return CompareFileTime(&fd2
->ftLastWriteTime
, &fd1
->ftLastWriteTime
);
1108 static int (*sortFunctions
[])(const void* arg1
, const void* arg2
) = {
1109 compareName
, /* SORT_NAME */
1110 compareExt
, /* SORT_EXT */
1111 compareSize
, /* SORT_SIZE */
1112 compareDate
/* SORT_DATE */
1116 static void SortDirectory(Entry
* dir
, SORT_ORDER sortOrder
)
1118 Entry
* entry
= dir
->down
;
1123 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1127 array
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(Entry
*));
1130 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1133 /* call qsort with the appropriate compare function */
1134 qsort(array
, len
, sizeof(array
[0]), sortFunctions
[sortOrder
]);
1136 dir
->down
= array
[0];
1138 for(p
=array
; --len
; p
++)
1142 HeapFree( GetProcessHeap(), 0, array
);
1147 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
1149 TCHAR buffer
[MAX_PATH
];
1154 #ifdef _SHELL_FOLDERS
1155 if (dir
->etype
== ET_SHELL
)
1157 read_directory_shell(dir
, hwnd
);
1159 if (Globals
.prescan_node
) {
1168 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1169 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1170 read_directory_shell(entry
, hwnd
);
1171 SortDirectory(entry
, sortOrder
);
1177 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1178 if (dir
->etype
== ET_UNIX
)
1180 read_directory_unix(dir
, path
);
1182 if (Globals
.prescan_node
) {
1191 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1192 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1193 lstrcpy(d
, entry
->data
.cFileName
);
1194 read_directory_unix(entry
, buffer
);
1195 SortDirectory(entry
, sortOrder
);
1202 read_directory_win(dir
, path
);
1204 if (Globals
.prescan_node
) {
1213 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1214 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1215 lstrcpy(d
, entry
->data
.cFileName
);
1216 read_directory_win(entry
, buffer
);
1217 SortDirectory(entry
, sortOrder
);
1222 SortDirectory(dir
, sortOrder
);
1226 static ChildWnd
* alloc_child_window(LPCTSTR path
, LPITEMIDLIST pidl
, HWND hwnd
)
1228 TCHAR drv
[_MAX_DRIVE
+1], dir
[_MAX_DIR
], name
[_MAX_FNAME
], ext
[_MAX_EXT
];
1229 ChildWnd
* child
= (ChildWnd
*) malloc(sizeof(ChildWnd
));
1230 Root
* root
= &child
->root
;
1233 memset(child
, 0, sizeof(ChildWnd
));
1235 child
->left
.treePane
= TRUE
;
1236 child
->left
.visible_cols
= 0;
1238 child
->right
.treePane
= FALSE
;
1239 #ifndef _NO_EXTENSIONS
1240 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_INDEX
|COL_LINKS
;
1242 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
;
1245 child
->pos
.length
= sizeof(WINDOWPLACEMENT
);
1246 child
->pos
.flags
= 0;
1247 child
->pos
.showCmd
= SW_SHOWNORMAL
;
1248 child
->pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
1249 child
->pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
1250 child
->pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
1251 child
->pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
1253 child
->focus_pane
= 0;
1254 child
->split_pos
= DEFAULT_SPLIT_POS
;
1255 child
->sortOrder
= SORT_NAME
;
1256 child
->header_wdths_ok
= FALSE
;
1260 lstrcpy(child
->path
, path
);
1262 _tsplitpath(path
, drv
, dir
, name
, ext
);
1265 root
->entry
.level
= 0;
1267 #ifdef _SHELL_FOLDERS
1270 root
->drive_type
= DRIVE_UNKNOWN
;
1271 lstrcpy(drv
, TEXT("\\"));
1272 lstrcpy(root
->volname
, TEXT("Desktop"));
1274 lstrcpy(root
->fs
, TEXT("Shell"));
1276 entry
= read_tree_shell(root
, pidl
, child
->sortOrder
, hwnd
);
1280 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1283 root
->drive_type
= GetDriveType(path
);
1285 lstrcat(drv
, TEXT("/"));
1286 lstrcpy(root
->volname
, TEXT("root fs"));
1288 lstrcpy(root
->fs
, TEXT("unixfs"));
1290 lstrcpy(root
->path
, TEXT("/"));
1291 entry
= read_tree_unix(root
, path
, child
->sortOrder
, hwnd
);
1296 root
->drive_type
= GetDriveType(path
);
1298 lstrcat(drv
, TEXT("\\"));
1299 GetVolumeInformation(drv
, root
->volname
, _MAX_FNAME
, 0, 0, &root
->fs_flags
, root
->fs
, _MAX_DIR
);
1301 lstrcpy(root
->path
, drv
);
1302 entry
= read_tree_win(root
, path
, child
->sortOrder
, hwnd
);
1305 #ifdef _SHELL_FOLDERS
1306 if (root
->entry
.etype
== ET_SHELL
)
1307 lstrcpy(root
->entry
.data
.cFileName
, TEXT("Desktop"));
1310 wsprintf(root
->entry
.data
.cFileName
, TEXT("%s - %s"), drv
, root
->fs
);
1312 root
->entry
.data
.dwFileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
1314 child
->left
.root
= &root
->entry
;
1315 child
->right
.root
= NULL
;
1317 set_curdir(child
, entry
, hwnd
);
1323 /* free all memory associated with a child window */
1324 static void free_child_window(ChildWnd
* child
)
1326 free_entries(&child
->root
.entry
);
1331 /* get full path of specified directory entry */
1332 static void get_path(Entry
* dir
, PTSTR path
)
1338 #ifdef _SHELL_FOLDERS
1339 if (dir
->etype
== ET_SHELL
)
1344 path
[0] = TEXT('\0');
1349 hr
= (*dir
->folder
->lpVtbl
->GetAttributesOf
)(dir
->folder
, 1, (LPCITEMIDLIST
*)&dir
->pidl
, &attribs
);
1351 if (SUCCEEDED(hr
) && (attribs
&SFGAO_FILESYSTEM
)) {
1352 IShellFolder
* parent
= dir
->up
? dir
->up
->folder
: Globals
.iDesktop
;
1354 hr
= path_from_pidl(parent
, dir
->pidl
, path
, MAX_PATH
);
1360 for(entry
=dir
; entry
; level
++) {
1366 name
= entry
->data
.cFileName
;
1369 for(l
=0; *s
&& *s
!=TEXT('/') && *s
!=TEXT('\\'); s
++)
1375 memmove(path
+l
+1, path
, len
*sizeof(TCHAR
));
1376 memcpy(path
+1, name
, l
*sizeof(TCHAR
));
1379 #ifndef _NO_EXTENSIONS
1380 if (entry
->etype
== ET_UNIX
)
1381 path
[0] = TEXT('/');
1384 path
[0] = TEXT('\\');
1389 memmove(path
+l
, path
, len
*sizeof(TCHAR
));
1390 memcpy(path
, name
, l
*sizeof(TCHAR
));
1397 #ifndef _NO_EXTENSIONS
1398 if (entry
->etype
== ET_UNIX
)
1399 path
[len
++] = TEXT('/');
1402 path
[len
++] = TEXT('\\');
1405 path
[len
] = TEXT('\0');
1410 static void resize_frame_rect(HWND hwnd
, PRECT prect
)
1415 if (IsWindowVisible(Globals
.htoolbar
)) {
1416 SendMessage(Globals
.htoolbar
, WM_SIZE
, 0, 0);
1417 GetClientRect(Globals
.htoolbar
, &rt
);
1418 prect
->top
= rt
.bottom
+3;
1419 prect
->bottom
-= rt
.bottom
+3;
1422 if (IsWindowVisible(Globals
.hdrivebar
)) {
1423 SendMessage(Globals
.hdrivebar
, WM_SIZE
, 0, 0);
1424 GetClientRect(Globals
.hdrivebar
, &rt
);
1425 new_top
= --prect
->top
+ rt
.bottom
+3;
1426 MoveWindow(Globals
.hdrivebar
, 0, prect
->top
, rt
.right
, new_top
, TRUE
);
1427 prect
->top
= new_top
;
1428 prect
->bottom
-= rt
.bottom
+2;
1431 if (IsWindowVisible(Globals
.hstatusbar
)) {
1432 int parts
[] = {300, 500};
1434 SendMessage(Globals
.hstatusbar
, WM_SIZE
, 0, 0);
1435 SendMessage(Globals
.hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1436 GetClientRect(Globals
.hstatusbar
, &rt
);
1437 prect
->bottom
-= rt
.bottom
;
1440 MoveWindow(Globals
.hmdiclient
, prect
->left
-1,prect
->top
-1,prect
->right
+2,prect
->bottom
+1, TRUE
);
1443 static void resize_frame(HWND hwnd
, int cx
, int cy
)
1452 resize_frame_rect(hwnd
, &rect
);
1455 static void resize_frame_client(HWND hwnd
)
1459 GetClientRect(hwnd
, &rect
);
1461 resize_frame_rect(hwnd
, &rect
);
1465 static HHOOK hcbthook
;
1466 static ChildWnd
* newchild
= NULL
;
1468 LRESULT CALLBACK
CBTProc(int code
, WPARAM wparam
, LPARAM lparam
)
1470 if (code
==HCBT_CREATEWND
&& newchild
) {
1471 ChildWnd
* child
= newchild
;
1474 child
->hwnd
= (HWND
) wparam
;
1475 SetWindowLong(child
->hwnd
, GWL_USERDATA
, (LPARAM
)child
);
1478 return CallNextHookEx(hcbthook
, code
, wparam
, lparam
);
1481 static HWND
create_child_window(ChildWnd
* child
)
1483 MDICREATESTRUCT mcs
;
1486 mcs
.szClass
= WINEFILETREE
;
1487 mcs
.szTitle
= (LPTSTR
)child
->path
;
1488 mcs
.hOwner
= Globals
.hInstance
;
1489 mcs
.x
= child
->pos
.rcNormalPosition
.left
;
1490 mcs
.y
= child
->pos
.rcNormalPosition
.top
;
1491 mcs
.cx
= child
->pos
.rcNormalPosition
.right
-child
->pos
.rcNormalPosition
.left
;
1492 mcs
.cy
= child
->pos
.rcNormalPosition
.bottom
-child
->pos
.rcNormalPosition
.top
;
1496 hcbthook
= SetWindowsHookEx(WH_CBT
, CBTProc
, 0, GetCurrentThreadId());
1499 child
->hwnd
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDICREATE
, 0, (LPARAM
)&mcs
);
1501 UnhookWindowsHookEx(hcbthook
);
1505 UnhookWindowsHookEx(hcbthook
);
1507 idx
= ListBox_FindItemData(child
->left
.hwnd
, ListBox_GetCurSel(child
->left
.hwnd
), child
->left
.cur
);
1508 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
1514 struct ExecuteDialog
{
1515 TCHAR cmd
[MAX_PATH
];
1520 static BOOL CALLBACK
ExecuteDialogWndProg(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1522 static struct ExecuteDialog
* dlg
;
1526 dlg
= (struct ExecuteDialog
*) lparam
;
1530 int id
= (int)wparam
;
1533 GetWindowText(GetDlgItem(hwnd
, 201), dlg
->cmd
, MAX_PATH
);
1534 dlg
->cmdshow
= Button_GetState(GetDlgItem(hwnd
,214))&BST_CHECKED
?
1535 SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
1536 EndDialog(hwnd
, id
);
1537 } else if (id
== IDCANCEL
)
1538 EndDialog(hwnd
, id
);
1547 #ifndef _NO_EXTENSIONS
1549 static struct FullScreenParameters
{
1559 void frame_get_clientspace(HWND hwnd
, PRECT prect
)
1563 if (!IsIconic(hwnd
))
1564 GetClientRect(hwnd
, prect
);
1568 GetWindowPlacement(hwnd
, &wp
);
1570 prect
->left
= prect
->top
= 0;
1571 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
1572 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
1573 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
1574 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
1575 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
1578 if (IsWindowVisible(Globals
.htoolbar
)) {
1579 GetClientRect(Globals
.htoolbar
, &rt
);
1580 prect
->top
+= rt
.bottom
+2;
1583 if (IsWindowVisible(Globals
.hdrivebar
)) {
1584 GetClientRect(Globals
.hdrivebar
, &rt
);
1585 prect
->top
+= rt
.bottom
+2;
1588 if (IsWindowVisible(Globals
.hstatusbar
)) {
1589 GetClientRect(Globals
.hstatusbar
, &rt
);
1590 prect
->bottom
-= rt
.bottom
;
1594 static BOOL
toggle_fullscreen(HWND hwnd
)
1598 if ((g_fullscreen
.mode
=!g_fullscreen
.mode
)) {
1599 GetWindowRect(hwnd
, &g_fullscreen
.orgPos
);
1600 g_fullscreen
.wasZoomed
= IsZoomed(hwnd
);
1602 Frame_CalcFrameClient(hwnd
, &rt
);
1603 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
1604 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
1606 rt
.left
= g_fullscreen
.orgPos
.left
-rt
.left
;
1607 rt
.top
= g_fullscreen
.orgPos
.top
-rt
.top
;
1608 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+g_fullscreen
.orgPos
.right
-rt
.right
;
1609 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+g_fullscreen
.orgPos
.bottom
-rt
.bottom
;
1611 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
1613 MoveWindow(hwnd
, g_fullscreen
.orgPos
.left
, g_fullscreen
.orgPos
.top
,
1614 g_fullscreen
.orgPos
.right
-g_fullscreen
.orgPos
.left
,
1615 g_fullscreen
.orgPos
.bottom
-g_fullscreen
.orgPos
.top
, TRUE
);
1617 if (g_fullscreen
.wasZoomed
)
1618 ShowWindow(hwnd
, WS_MAXIMIZE
);
1621 return g_fullscreen
.mode
;
1624 static void fullscreen_move(HWND hwnd
)
1627 GetWindowRect(hwnd
, &pos
);
1629 Frame_CalcFrameClient(hwnd
, &rt
);
1630 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
1631 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
1633 rt
.left
= pos
.left
-rt
.left
;
1634 rt
.top
= pos
.top
-rt
.top
;
1635 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
1636 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
1638 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
1644 static void toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
)
1646 BOOL vis
= IsWindowVisible(hchild
);
1648 CheckMenuItem(Globals
.hMenuOptions
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
1650 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
1652 #ifndef _NO_EXTENSIONS
1653 if (g_fullscreen
.mode
)
1654 fullscreen_move(hwnd
);
1657 resize_frame_client(hwnd
);
1660 BOOL
activate_drive_window(LPCTSTR path
)
1662 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
1665 _tsplitpath(path
, drv1
, 0, 0, 0);
1667 /* search for a already open window for the same drive */
1668 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1669 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
1672 _tsplitpath(child
->root
.path
, drv2
, 0, 0, 0);
1674 if (!lstrcmpi(drv2
, drv1
)) {
1675 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1677 if (IsMinimized(child_wnd
))
1678 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1688 BOOL
activate_fs_window(LPCTSTR filesys
)
1692 /* search for a already open window of the given file system name */
1693 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1694 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
1697 if (!lstrcmpi(child
->root
.fs
, filesys
)) {
1698 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1700 if (IsMinimized(child_wnd
))
1701 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1711 LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1715 DestroyWindow(hwnd
);
1717 /* clear handle variables */
1718 Globals
.hMenuFrame
= 0;
1719 Globals
.hMenuView
= 0;
1720 Globals
.hMenuOptions
= 0;
1721 Globals
.hMainWnd
= 0;
1722 Globals
.hmdiclient
= 0;
1723 Globals
.hdrivebar
= 0;
1727 /* don't exit desktop when closing file manager window */
1728 if (!Globals
.hwndParent
)
1733 UINT cmd
= LOWORD(wparam
);
1734 HWND hwndClient
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1736 if (SendMessage(hwndClient
, WM_DISPATCH_COMMAND
, wparam
, lparam
))
1739 if (cmd
>=ID_DRIVE_FIRST
&& cmd
<=ID_DRIVE_FIRST
+0xFF) {
1740 TCHAR drv
[_MAX_DRIVE
], path
[MAX_PATH
];
1742 LPCTSTR root
= Globals
.drives
;
1745 for(i
=cmd
-ID_DRIVE_FIRST
; i
--; root
++)
1749 if (activate_drive_window(root
))
1752 _tsplitpath(root
, drv
, 0, 0, 0);
1754 if (!SetCurrentDirectory(drv
)) {
1755 display_error(hwnd
, GetLastError());
1759 GetCurrentDirectory(MAX_PATH
, path
); /*TODO: store last directory per drive */
1760 child
= alloc_child_window(path
, NULL
, hwnd
);
1762 if (!create_child_window(child
))
1764 } else switch(cmd
) {
1766 SendMessage(hwnd
, WM_CLOSE
, 0, 0);
1769 case ID_WINDOW_NEW
: {
1770 TCHAR path
[MAX_PATH
];
1773 GetCurrentDirectory(MAX_PATH
, path
);
1774 child
= alloc_child_window(path
, NULL
, hwnd
);
1776 if (!create_child_window(child
))
1780 case ID_WINDOW_CASCADE
:
1781 SendMessage(Globals
.hmdiclient
, WM_MDICASCADE
, 0, 0);
1784 case ID_WINDOW_TILE_HORZ
:
1785 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
1788 case ID_WINDOW_TILE_VERT
:
1789 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
1792 case ID_WINDOW_ARRANGE
:
1793 SendMessage(Globals
.hmdiclient
, WM_MDIICONARRANGE
, 0, 0);
1796 case ID_VIEW_TOOL_BAR
:
1797 toggle_child(hwnd
, cmd
, Globals
.htoolbar
);
1800 case ID_VIEW_DRIVE_BAR
:
1801 toggle_child(hwnd
, cmd
, Globals
.hdrivebar
);
1804 case ID_VIEW_STATUSBAR
:
1805 toggle_child(hwnd
, cmd
, Globals
.hstatusbar
);
1809 struct ExecuteDialog dlg
;
1811 memset(&dlg
, 0, sizeof(struct ExecuteDialog
));
1813 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), hwnd
, ExecuteDialogWndProg
, (LPARAM
)&dlg
) == IDOK
) {
1814 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
1816 if ((int)hinst
<= 32)
1817 display_error(hwnd
, GetLastError());
1822 WinHelp(hwnd
, TEXT("winfile"), HELP_INDEX
, 0);
1825 #ifndef _NO_EXTENSIONS
1826 case ID_VIEW_FULLSCREEN
:
1827 CheckMenuItem(Globals
.hMenuOptions
, cmd
, toggle_fullscreen(hwnd
)?MF_CHECKED
:0);
1831 case ID_DRIVE_UNIX_FS
: {
1832 TCHAR path
[MAX_PATH
];
1835 if (activate_fs_window(TEXT("unixfs")))
1838 getcwd(path
, MAX_PATH
);
1839 child
= alloc_child_window(path
, NULL
, hwnd
);
1841 if (!create_child_window(child
))
1845 #ifdef _SHELL_FOLDERS
1846 case ID_DRIVE_SHELL_NS
: {
1847 TCHAR path
[MAX_PATH
];
1850 if (activate_fs_window(TEXT("Shell")))
1853 GetCurrentDirectory(MAX_PATH
, path
);
1854 child
= alloc_child_window(path
, get_path_pidl(path
,hwnd
), hwnd
);
1856 if (!create_child_window(child
))
1862 /*TODO: There are even more menu items! */
1864 #ifndef _NO_EXTENSIONS
1867 WineLicense(Globals
.hMainWnd
);
1870 case ID_NO_WARRANTY
:
1871 WineWarranty(Globals
.hMainWnd
);
1876 ShellAbout(hwnd
, TEXT("WINE"), TEXT("Winefile"), 0);
1879 case ID_ABOUT
: /*ID_ABOUT_WINE: */
1880 ShellAbout(hwnd
, TEXT("Winefile"), NULL
, 0);
1882 #endif /* _NO_EXTENSIONS */
1885 /*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE)
1886 STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE);
1887 else */if ((cmd
<IDW_FIRST_CHILD
|| cmd
>=IDW_FIRST_CHILD
+0x100) &&
1888 (cmd
<SC_SIZE
|| cmd
>SC_RESTORE
))
1889 MessageBox(hwnd
, TEXT("Not yet implemented"), TEXT("Winefile"), MB_OK
);
1891 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
1896 resize_frame(hwnd
, LOWORD(lparam
), HIWORD(lparam
));
1897 break; /* do not pass message to DefFrameProc */
1899 #ifndef _NO_EXTENSIONS
1900 case WM_GETMINMAXINFO
: {
1901 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
1903 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
1904 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
1907 case FRM_CALC_CLIENT
:
1908 frame_get_clientspace(hwnd
, (PRECT
)lparam
);
1910 #endif /* _NO_EXTENSIONS */
1913 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
1920 static const LPTSTR g_pos_names
[COLUMNS
] = {
1921 TEXT(""), /* symbol */
1925 #ifndef _NO_EXTENSIONS
1928 TEXT("Index/Inode"),
1930 #endif /* _NO_EXTENSIONS */
1932 #ifndef _NO_EXTENSIONS
1937 static const int g_pos_align
[] = {
1939 HDF_LEFT
, /* Name */
1940 HDF_RIGHT
, /* Size */
1941 HDF_LEFT
, /* CDate */
1942 #ifndef _NO_EXTENSIONS
1943 HDF_LEFT
, /* ADate */
1944 HDF_LEFT
, /* MDate */
1945 HDF_LEFT
, /* Index */
1946 HDF_CENTER
, /* Links */
1948 HDF_CENTER
, /* Attributes */
1949 #ifndef _NO_EXTENSIONS
1950 HDF_LEFT
/* Security */
1954 static void resize_tree(ChildWnd
* child
, int cx
, int cy
)
1956 HDWP hdwp
= BeginDeferWindowPos(4);
1964 cx
= child
->split_pos
+ SPLIT_WIDTH
/2;
1966 #ifndef _NO_EXTENSIONS
1974 Header_Layout(child
->left
.hwndHeader
, &hdl
);
1976 DeferWindowPos(hdwp
, child
->left
.hwndHeader
, wp
.hwndInsertAfter
,
1977 wp
.x
-1, wp
.y
, child
->split_pos
-SPLIT_WIDTH
/2+1, wp
.cy
, wp
.flags
);
1978 DeferWindowPos(hdwp
, child
->right
.hwndHeader
, wp
.hwndInsertAfter
,
1979 rt
.left
+cx
+1, wp
.y
, wp
.cx
-cx
+2, wp
.cy
, wp
.flags
);
1981 #endif /* _NO_EXTENSIONS */
1983 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
);
1984 DeferWindowPos(hdwp
, child
->right
.hwnd
, 0, rt
.left
+cx
+1, rt
.top
, rt
.right
-cx
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
1986 EndDeferWindowPos(hdwp
);
1990 #ifndef _NO_EXTENSIONS
1992 static HWND
create_header(HWND parent
, Pane
* pane
, int id
)
1997 HWND hwnd
= CreateWindow(WC_HEADER
, 0, WS_CHILD
|WS_VISIBLE
|HDS_HORZ
/*TODO: |HDS_BUTTONS + sort orders*/,
1998 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2002 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), FALSE
);
2004 hdi
.mask
= HDI_TEXT
|HDI_WIDTH
|HDI_FORMAT
;
2006 for(idx
=0; idx
<COLUMNS
; idx
++) {
2007 hdi
.pszText
= g_pos_names
[idx
];
2008 hdi
.fmt
= HDF_STRING
| g_pos_align
[idx
];
2009 hdi
.cxy
= pane
->widths
[idx
];
2010 Header_InsertItem(hwnd
, idx
, &hdi
);
2016 #endif /* _NO_EXTENSIONS */
2019 static void init_output(HWND hwnd
)
2023 HDC hdc
= GetDC(hwnd
);
2025 if (GetNumberFormat(LOCALE_USER_DEFAULT
, 0, TEXT("1000"), 0, b
, 16) > 4)
2026 Globals
.num_sep
= b
[1];
2028 Globals
.num_sep
= TEXT('.');
2030 old_font
= SelectFont(hdc
, Globals
.hfont
);
2031 GetTextExtentPoint32(hdc
, TEXT(" "), 1, &Globals
.spaceSize
);
2032 SelectFont(hdc
, old_font
);
2033 ReleaseDC(hwnd
, hdc
);
2036 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
);
2039 /* calculate prefered width for all visible columns */
2041 static BOOL
calc_widths(Pane
* pane
, BOOL anyway
)
2043 int col
, x
, cx
, spc
=3*Globals
.spaceSize
.cx
;
2044 int entries
= ListBox_GetCount(pane
->hwnd
);
2045 int orgWidths
[COLUMNS
];
2046 int orgPositions
[COLUMNS
+1];
2052 memcpy(orgWidths
, pane
->widths
, sizeof(orgWidths
));
2053 memcpy(orgPositions
, pane
->positions
, sizeof(orgPositions
));
2056 for(col
=0; col
<COLUMNS
; col
++)
2057 pane
->widths
[col
] = 0;
2059 hdc
= GetDC(pane
->hwnd
);
2060 hfontOld
= SelectFont(hdc
, Globals
.hfont
);
2062 for(cnt
=0; cnt
<entries
; cnt
++) {
2063 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, cnt
);
2072 dis
.hwndItem
= pane
->hwnd
;
2074 dis
.rcItem
.left
= 0;
2076 dis
.rcItem
.right
= 0;
2077 dis
.rcItem
.bottom
= 0;
2078 /*dis.itemData = 0; */
2080 draw_item(pane
, &dis
, entry
, COLUMNS
);
2083 SelectObject(hdc
, hfontOld
);
2084 ReleaseDC(pane
->hwnd
, hdc
);
2087 for(col
=0; col
<COLUMNS
; col
++) {
2088 pane
->positions
[col
] = x
;
2089 cx
= pane
->widths
[col
];
2094 if (cx
< IMAGE_WIDTH
)
2097 pane
->widths
[col
] = cx
;
2103 pane
->positions
[COLUMNS
] = x
;
2105 ListBox_SetHorizontalExtent(pane
->hwnd
, x
);
2108 if (!memcmp(orgWidths
, pane
->widths
, sizeof(orgWidths
)))
2111 /* don't move, if only collapsing an entry */
2112 if (!anyway
&& pane
->widths
[0]<orgWidths
[0] &&
2113 !memcmp(orgWidths
+1, pane
->widths
+1, sizeof(orgWidths
)-sizeof(int))) {
2114 pane
->widths
[0] = orgWidths
[0];
2115 memcpy(pane
->positions
, orgPositions
, sizeof(orgPositions
));
2120 InvalidateRect(pane
->hwnd
, 0, TRUE
);
2126 /* calculate one prefered column width */
2128 static void calc_single_width(Pane
* pane
, int col
)
2132 int entries
= ListBox_GetCount(pane
->hwnd
);
2136 pane
->widths
[col
] = 0;
2138 hdc
= GetDC(pane
->hwnd
);
2139 hfontOld
= SelectFont(hdc
, Globals
.hfont
);
2141 for(cnt
=0; cnt
<entries
; cnt
++) {
2142 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, cnt
);
2150 dis
.hwndItem
= pane
->hwnd
;
2152 dis
.rcItem
.left
= 0;
2154 dis
.rcItem
.right
= 0;
2155 dis
.rcItem
.bottom
= 0;
2156 /*dis.itemData = 0; */
2158 draw_item(pane
, &dis
, entry
, col
);
2161 SelectObject(hdc
, hfontOld
);
2162 ReleaseDC(pane
->hwnd
, hdc
);
2164 cx
= pane
->widths
[col
];
2167 cx
+= 3*Globals
.spaceSize
.cx
;
2169 if (cx
< IMAGE_WIDTH
)
2173 pane
->widths
[col
] = cx
;
2175 x
= pane
->positions
[col
] + cx
;
2177 for(; col
<COLUMNS
; ) {
2178 pane
->positions
[++col
] = x
;
2179 x
+= pane
->widths
[col
];
2182 ListBox_SetHorizontalExtent(pane
->hwnd
, x
);
2186 /* insert listbox entries after index idx */
2188 static void insert_entries(Pane
* pane
, Entry
* dir
, int idx
)
2195 ShowWindow(pane
->hwnd
, SW_HIDE
);
2197 for(; entry
; entry
=entry
->next
) {
2199 if (pane
->treePane
&& !(entry
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
2203 /* don't display entries "." and ".." in the left pane */
2204 if (pane
->treePane
&& (entry
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
)
2205 && entry
->data
.cFileName
[0]==TEXT('.'))
2207 #ifndef _NO_EXTENSIONS
2208 entry
->data
.cFileName
[1]==TEXT('\0') ||
2210 (entry
->data
.cFileName
[1]==TEXT('.') && entry
->data
.cFileName
[2]==TEXT('\0')))
2216 ListBox_InsertItemData(pane
->hwnd
, idx
, entry
);
2218 if (pane
->treePane
&& entry
->expanded
)
2219 insert_entries(pane
, entry
->down
, idx
);
2222 ShowWindow(pane
->hwnd
, SW_SHOW
);
2226 static WNDPROC g_orgTreeWndProc
;
2228 static void create_tree_window(HWND parent
, Pane
* pane
, int id
, int id_header
)
2230 static int s_init
= 0;
2231 Entry
* entry
= pane
->root
;
2233 pane
->hwnd
= CreateWindow(TEXT("ListBox"), TEXT(""), WS_CHILD
|WS_VISIBLE
|WS_HSCROLL
|WS_VSCROLL
|
2234 LBS_DISABLENOSCROLL
|LBS_NOINTEGRALHEIGHT
|LBS_OWNERDRAWFIXED
|LBS_NOTIFY
,
2235 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2237 SetWindowLong(pane
->hwnd
, GWL_USERDATA
, (LPARAM
)pane
);
2238 g_orgTreeWndProc
= SubclassWindow(pane
->hwnd
, TreeWndProc
);
2240 SendMessage(pane
->hwnd
, WM_SETFONT
, (WPARAM
)Globals
.hfont
, FALSE
);
2242 /* insert entries into listbox */
2244 insert_entries(pane
, entry
, -1);
2246 /* calculate column widths */
2249 init_output(pane
->hwnd
);
2252 calc_widths(pane
, TRUE
);
2254 #ifndef _NO_EXTENSIONS
2255 pane
->hwndHeader
= create_header(parent
, pane
, id_header
);
2260 static void InitChildWindow(ChildWnd
* child
)
2262 create_tree_window(child
->hwnd
, &child
->left
, IDW_TREE_LEFT
, IDW_HEADER_LEFT
);
2263 create_tree_window(child
->hwnd
, &child
->right
, IDW_TREE_RIGHT
, IDW_HEADER_RIGHT
);
2267 static void format_date(const FILETIME
* ft
, TCHAR
* buffer
, int visible_cols
)
2273 *buffer
= TEXT('\0');
2275 if (!ft
->dwLowDateTime
&& !ft
->dwHighDateTime
)
2278 if (!FileTimeToLocalFileTime(ft
, &lft
))
2279 {err
: _tcscpy(buffer
,TEXT("???")); return;}
2281 if (!FileTimeToSystemTime(&lft
, &systime
))
2284 if (visible_cols
& COL_DATE
) {
2285 len
= GetDateFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
, BUFFER_LEN
);
2290 if (visible_cols
& COL_TIME
) {
2292 buffer
[len
-1] = ' ';
2294 buffer
[len
++] = ' ';
2296 if (!GetTimeFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
+len
, BUFFER_LEN
-len
))
2297 buffer
[len
] = TEXT('\0');
2302 static void calc_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2304 RECT rt
= {0, 0, 0, 0};
2306 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
2308 if (rt
.right
> pane
->widths
[col
])
2309 pane
->widths
[col
] = rt
.right
;
2312 static void calc_tabbed_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2314 RECT rt
= {0, 0, 0, 0};
2316 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
2317 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
2319 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
2320 /*FIXME rt (0,0) ??? */
2322 if (rt
.right
> pane
->widths
[col
])
2323 pane
->widths
[col
] = rt
.right
;
2327 static void output_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
, DWORD flags
)
2329 int x
= dis
->rcItem
.left
;
2332 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2333 rt
.top
= dis
->rcItem
.top
;
2334 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2335 rt
.bottom
= dis
->rcItem
.bottom
;
2337 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_SINGLELINE
|DT_NOPREFIX
|flags
);
2340 static void output_tabbed_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2342 int x
= dis
->rcItem
.left
;
2345 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2346 rt
.top
= dis
->rcItem
.top
;
2347 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2348 rt
.bottom
= dis
->rcItem
.bottom
;
2350 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
2351 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
2353 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
2356 static void output_number(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2358 int x
= dis
->rcItem
.left
;
2365 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2366 rt
.top
= dis
->rcItem
.top
;
2367 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2368 rt
.bottom
= dis
->rcItem
.bottom
;
2373 /* insert number separator characters */
2374 pos
= lstrlen(s
) % 3;
2380 *d
++ = Globals
.num_sep
;
2384 DrawText(dis
->hDC
, b
, d
-b
, &rt
, DT_RIGHT
|DT_SINGLELINE
|DT_NOPREFIX
|DT_END_ELLIPSIS
);
2388 static int is_exe_file(LPCTSTR ext
)
2390 static const LPCTSTR executable_extensions
[] = {
2395 #ifndef _NO_EXTENSIONS
2399 #endif /* _NO_EXTENSIONS */
2403 TCHAR ext_buffer
[_MAX_EXT
];
2408 for(s
=ext
+1,d
=ext_buffer
; (*d
=tolower(*s
)); s
++)
2411 for(p
=executable_extensions
; *p
; p
++)
2412 if (!_tcscmp(ext_buffer
, *p
))
2418 static int is_registered_type(LPCTSTR ext
)
2426 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
)
2428 TCHAR buffer
[BUFFER_LEN
];
2430 int visible_cols
= pane
->visible_cols
;
2431 COLORREF bkcolor
, textcolor
;
2432 RECT focusRect
= dis
->rcItem
;
2439 attrs
= entry
->data
.dwFileAttributes
;
2441 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) {
2442 if (entry
->data
.cFileName
[0]==TEXT('.') && entry
->data
.cFileName
[1]==TEXT('.')
2443 && entry
->data
.cFileName
[2]==TEXT('\0'))
2444 img
= IMG_FOLDER_UP
;
2445 #ifndef _NO_EXTENSIONS
2446 else if (entry
->data
.cFileName
[0]==TEXT('.') && entry
->data
.cFileName
[1]==TEXT('\0'))
2447 img
= IMG_FOLDER_CUR
;
2450 #ifdef _NO_EXTENSIONS
2453 (pane
->treePane
&& (dis
->itemState
&ODS_FOCUS
)))
2454 img
= IMG_OPEN_FOLDER
;
2458 LPCTSTR ext
= _tcsrchr(entry
->data
.cFileName
, '.');
2462 if (is_exe_file(ext
))
2463 img
= IMG_EXECUTABLE
;
2464 else if (is_registered_type(ext
))
2474 if (pane
->treePane
) {
2476 img_pos
= dis
->rcItem
.left
+ entry
->level
*(IMAGE_WIDTH
+Globals
.spaceSize
.cx
);
2478 if (calcWidthCol
== -1) {
2480 int y
= dis
->rcItem
.top
+ IMAGE_HEIGHT
/2;
2483 HRGN hrgn_org
= CreateRectRgn(0, 0, 0, 0);
2486 rt_clip
.left
= dis
->rcItem
.left
;
2487 rt_clip
.top
= dis
->rcItem
.top
;
2488 rt_clip
.right
= dis
->rcItem
.left
+pane
->widths
[col
];
2489 rt_clip
.bottom
= dis
->rcItem
.bottom
;
2491 hrgn
= CreateRectRgnIndirect(&rt_clip
);
2493 if (!GetClipRgn(dis
->hDC
, hrgn_org
)) {
2494 DeleteObject(hrgn_org
);
2498 /* HGDIOBJ holdPen = SelectObject(dis->hDC, GetStockObject(BLACK_PEN)); */
2499 ExtSelectClipRgn(dis
->hDC
, hrgn
, RGN_AND
);
2502 if ((up
=entry
->up
) != NULL
) {
2503 MoveToEx(dis
->hDC
, img_pos
-IMAGE_WIDTH
/2, y
, 0);
2504 LineTo(dis
->hDC
, img_pos
-2, y
);
2506 x
= img_pos
- IMAGE_WIDTH
/2;
2509 x
-= IMAGE_WIDTH
+Globals
.spaceSize
.cx
;
2513 && (up
->next
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
2516 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
2517 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2519 } while((up
=up
->up
) != NULL
);
2522 x
= img_pos
- IMAGE_WIDTH
/2;
2524 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
2525 LineTo(dis
->hDC
, x
, y
);
2529 && (entry
->next
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
)
2532 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2534 if (entry
->down
&& entry
->expanded
) {
2535 x
+= IMAGE_WIDTH
+Globals
.spaceSize
.cx
;
2536 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
+IMAGE_HEIGHT
, 0);
2537 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2540 SelectClipRgn(dis
->hDC
, hrgn_org
);
2541 if (hrgn_org
) DeleteObject(hrgn_org
);
2542 /* SelectObject(dis->hDC, holdPen); */
2543 } else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
) {
2544 int right
= img_pos
+ IMAGE_WIDTH
- Globals
.spaceSize
.cx
;
2546 if (right
> pane
->widths
[col
])
2547 pane
->widths
[col
] = right
;
2550 img_pos
= dis
->rcItem
.left
;
2553 img_pos
= dis
->rcItem
.left
;
2555 if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2556 pane
->widths
[col
] = IMAGE_WIDTH
;
2559 if (calcWidthCol
== -1) {
2560 focusRect
.left
= img_pos
-2;
2562 #ifdef _NO_EXTENSIONS
2563 if (pane
->treePane
&& entry
) {
2566 DrawText(dis
->hDC
, entry
->data
.cFileName
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
2568 focusRect
.right
= dis
->rcItem
.left
+pane
->positions
[col
+1]+Globals
.spaceSize
.cx
+ rt
.right
+2;
2572 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
)
2573 textcolor
= COLOR_COMPRESSED
;
2575 #endif /* _NO_EXTENSIONS */
2576 textcolor
= RGB(0,0,0);
2578 if (dis
->itemState
& ODS_FOCUS
) {
2579 textcolor
= RGB(255,255,255);
2580 bkcolor
= COLOR_SELECTION
;
2582 bkcolor
= RGB(255,255,255);
2585 hbrush
= CreateSolidBrush(bkcolor
);
2586 FillRect(dis
->hDC
, &focusRect
, hbrush
);
2587 DeleteObject(hbrush
);
2589 SetBkMode(dis
->hDC
, TRANSPARENT
);
2590 SetTextColor(dis
->hDC
, textcolor
);
2592 cx
= pane
->widths
[col
];
2594 if (cx
&& img
!=IMG_NONE
) {
2595 if (cx
> IMAGE_WIDTH
)
2598 #ifdef _SHELL_FOLDERS
2599 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
2600 DrawIconEx(dis
->hDC
, img_pos
, dis
->rcItem
.top
, entry
->hicon
, cx
, GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
2603 ImageList_DrawEx(Globals
.himl
, img
, dis
->hDC
,
2604 img_pos
, dis
->rcItem
.top
, cx
,
2605 IMAGE_HEIGHT
, bkcolor
, CLR_DEFAULT
, ILD_NORMAL
);
2612 #ifdef _NO_EXTENSIONS
2613 if (img
>= IMG_FOLDER_UP
)
2619 /* ouput file name */
2620 if (calcWidthCol
== -1)
2621 output_text(pane
, dis
, col
, entry
->data
.cFileName
, 0);
2622 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2623 calc_width(pane
, dis
, col
, entry
->data
.cFileName
);
2627 #ifdef _NO_EXTENSIONS
2628 if (!pane
->treePane
) {
2631 /* display file size */
2632 if (visible_cols
& COL_SIZE
) {
2633 #ifdef _NO_EXTENSIONS
2634 if (!(attrs
&FILE_ATTRIBUTE_DIRECTORY
))
2639 size
= ((ULONGLONG
)entry
->data
.nFileSizeHigh
<< 32) | entry
->data
.nFileSizeLow
;
2641 _stprintf(buffer
, TEXT("%") LONGLONGARG
TEXT("d"), size
);
2643 if (calcWidthCol
== -1)
2644 output_number(pane
, dis
, col
, buffer
);
2645 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2646 calc_width(pane
, dis
, col
, buffer
);/*TODO: not ever time enough */
2652 /* display file date */
2653 if (visible_cols
& (COL_DATE
|COL_TIME
)) {
2654 #ifndef _NO_EXTENSIONS
2655 format_date(&entry
->data
.ftCreationTime
, buffer
, visible_cols
);
2656 if (calcWidthCol
== -1)
2657 output_text(pane
, dis
, col
, buffer
, 0);
2658 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2659 calc_width(pane
, dis
, col
, buffer
);
2662 format_date(&entry
->data
.ftLastAccessTime
, buffer
, visible_cols
);
2663 if (calcWidthCol
== -1)
2664 output_text(pane
, dis
, col
, buffer
, 0);
2665 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2666 calc_width(pane
, dis
, col
, buffer
);
2668 #endif /* _NO_EXTENSIONS */
2670 format_date(&entry
->data
.ftLastWriteTime
, buffer
, visible_cols
);
2671 if (calcWidthCol
== -1)
2672 output_text(pane
, dis
, col
, buffer
, 0);
2673 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2674 calc_width(pane
, dis
, col
, buffer
);
2678 #ifndef _NO_EXTENSIONS
2679 if (entry
->bhfi_valid
) {
2680 ULONGLONG index
= ((ULONGLONG
)entry
->bhfi
.nFileIndexHigh
<< 32) | entry
->bhfi
.nFileIndexLow
;
2682 if (visible_cols
& COL_INDEX
) {
2683 _stprintf(buffer
, TEXT("%") LONGLONGARG
TEXT("X"), index
);
2684 if (calcWidthCol
== -1)
2685 output_text(pane
, dis
, col
, buffer
, DT_RIGHT
);
2686 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2687 calc_width(pane
, dis
, col
, buffer
);
2691 if (visible_cols
& COL_LINKS
) {
2692 wsprintf(buffer
, TEXT("%d"), entry
->bhfi
.nNumberOfLinks
);
2693 if (calcWidthCol
== -1)
2694 output_text(pane
, dis
, col
, buffer
, DT_CENTER
);
2695 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2696 calc_width(pane
, dis
, col
, buffer
);
2701 #endif /* _NO_EXTENSIONS */
2703 /* show file attributes */
2704 if (visible_cols
& COL_ATTRIBUTES
) {
2705 #ifdef _NO_EXTENSIONS
2706 _tcscpy(buffer
, TEXT(" \t \t \t \t "));
2708 _tcscpy(buffer
, TEXT(" \t \t \t \t \t \t \t \t \t \t \t "));
2711 if (attrs
& FILE_ATTRIBUTE_NORMAL
) buffer
[ 0] = 'N';
2713 if (attrs
& FILE_ATTRIBUTE_READONLY
) buffer
[ 2] = 'R';
2714 if (attrs
& FILE_ATTRIBUTE_HIDDEN
) buffer
[ 4] = 'H';
2715 if (attrs
& FILE_ATTRIBUTE_SYSTEM
) buffer
[ 6] = 'S';
2716 if (attrs
& FILE_ATTRIBUTE_ARCHIVE
) buffer
[ 8] = 'A';
2717 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
) buffer
[10] = 'C';
2718 #ifndef _NO_EXTENSIONS
2719 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) buffer
[12] = 'D';
2720 if (attrs
& FILE_ATTRIBUTE_ENCRYPTED
) buffer
[14] = 'E';
2721 if (attrs
& FILE_ATTRIBUTE_TEMPORARY
) buffer
[16] = 'T';
2722 if (attrs
& FILE_ATTRIBUTE_SPARSE_FILE
) buffer
[18] = 'P';
2723 if (attrs
& FILE_ATTRIBUTE_REPARSE_POINT
) buffer
[20] = 'Q';
2724 if (attrs
& FILE_ATTRIBUTE_OFFLINE
) buffer
[22] = 'O';
2725 if (attrs
& FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
) buffer
[24] = 'X';
2726 #endif /* _NO_EXTENSIONS */
2729 if (calcWidthCol
== -1)
2730 output_tabbed_text(pane
, dis
, col
, buffer
);
2731 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2732 calc_tabbed_width(pane
, dis
, col
, buffer
);
2738 if (flags.security) {
2739 DWORD rights = get_access_mask();
2741 tcscpy(buffer, TEXT(" \t \t \t \t \t \t \t \t \t \t \t "));
2743 if (rights & FILE_READ_DATA) buffer[ 0] = 'R';
2744 if (rights & FILE_WRITE_DATA) buffer[ 2] = 'W';
2745 if (rights & FILE_APPEND_DATA) buffer[ 4] = 'A';
2746 if (rights & FILE_READ_EA) {buffer[6] = 'entry'; buffer[ 7] = 'R';}
2747 if (rights & FILE_WRITE_EA) {buffer[9] = 'entry'; buffer[10] = 'W';}
2748 if (rights & FILE_EXECUTE) buffer[12] = 'X';
2749 if (rights & FILE_DELETE_CHILD) buffer[14] = 'D';
2750 if (rights & FILE_READ_ATTRIBUTES) {buffer[16] = 'a'; buffer[17] = 'R';}
2751 if (rights & FILE_WRITE_ATTRIBUTES) {buffer[19] = 'a'; buffer[20] = 'W';}
2752 if (rights & WRITE_DAC) buffer[22] = 'C';
2753 if (rights & WRITE_OWNER) buffer[24] = 'O';
2754 if (rights & SYNCHRONIZE) buffer[26] = 'S';
2756 output_text(dis, col++, buffer, DT_LEFT, 3, psize);
2759 if (flags.description) {
2760 get_description(buffer);
2761 output_text(dis, col++, buffer, 0, psize);
2765 #ifdef _NO_EXTENSIONS
2768 /* draw focus frame */
2769 if ((dis
->itemState
&ODS_FOCUS
) && calcWidthCol
==-1) {
2770 /* Currently [04/2000] Wine neither behaves exactly the same */
2771 /* way as WIN 95 nor like Windows NT... */
2776 if (!(GetVersion() & 0x80000000)) { /* Windows NT? */
2777 LOGBRUSH lb
= {PS_SOLID
, RGB(255,255,255)};
2778 hpen
= ExtCreatePen(PS_COSMETIC
|PS_ALTERNATE
, 1, &lb
, 0, 0);
2780 hpen
= CreatePen(PS_DOT
, 0, RGB(255,255,255));
2782 lastPen
= SelectPen(dis
->hDC
, hpen
);
2783 lastBrush
= SelectObject(dis
->hDC
, GetStockObject(HOLLOW_BRUSH
));
2784 SetROP2(dis
->hDC
, R2_XORPEN
);
2785 Rectangle(dis
->hDC
, focusRect
.left
, focusRect
.top
, focusRect
.right
, focusRect
.bottom
);
2786 SelectObject(dis
->hDC
, lastBrush
);
2787 SelectObject(dis
->hDC
, lastPen
);
2790 #endif /* _NO_EXTENSIONS */
2794 #ifdef _NO_EXTENSIONS
2796 static void draw_splitbar(HWND hwnd
, int x
)
2799 HDC hdc
= GetDC(hwnd
);
2801 GetClientRect(hwnd
, &rt
);
2803 rt
.left
= x
- SPLIT_WIDTH
/2;
2804 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
2806 InvertRect(hdc
, &rt
);
2808 ReleaseDC(hwnd
, hdc
);
2811 #endif /* _NO_EXTENSIONS */
2814 #ifndef _NO_EXTENSIONS
2816 static void set_header(Pane
* pane
)
2819 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
2822 item
.mask
= HDI_WIDTH
;
2825 for(; x
+pane
->widths
[i
]<scroll_pos
&& i
<COLUMNS
; i
++) {
2826 x
+= pane
->widths
[i
];
2827 Header_SetItem(pane
->hwndHeader
, i
, &item
);
2831 x
+= pane
->widths
[i
];
2832 item
.cxy
= x
- scroll_pos
;
2833 Header_SetItem(pane
->hwndHeader
, i
++, &item
);
2835 for(; i
<COLUMNS
; i
++) {
2836 item
.cxy
= pane
->widths
[i
];
2837 x
+= pane
->widths
[i
];
2838 Header_SetItem(pane
->hwndHeader
, i
, &item
);
2843 static LRESULT
pane_notify(Pane
* pane
, NMHDR
* pnmh
)
2845 switch(pnmh
->code
) {
2847 case HDN_ENDTRACK
: {
2848 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
2849 int idx
= phdn
->iItem
;
2850 int dx
= phdn
->pitem
->cxy
- pane
->widths
[idx
];
2854 GetClientRect(pane
->hwnd
, &clnt
);
2856 /* move immediate to simulate HDS_FULLDRAG (for now [04/2000] not really needed with WINELIB) */
2857 Header_SetItem(pane
->hwndHeader
, idx
, phdn
->pitem
);
2859 pane
->widths
[idx
] += dx
;
2861 for(i
=idx
; ++i
<=COLUMNS
; )
2862 pane
->positions
[i
] += dx
;
2865 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
2869 rt_scr
.left
= pane
->positions
[idx
+1]-scroll_pos
;
2871 rt_scr
.right
= clnt
.right
;
2872 rt_scr
.bottom
= clnt
.bottom
;
2874 rt_clip
.left
= pane
->positions
[idx
]-scroll_pos
;
2876 rt_clip
.right
= clnt
.right
;
2877 rt_clip
.bottom
= clnt
.bottom
;
2879 if (rt_scr
.left
< 0) rt_scr
.left
= 0;
2880 if (rt_clip
.left
< 0) rt_clip
.left
= 0;
2882 ScrollWindowEx(pane
->hwnd
, dx
, 0, &rt_scr
, &rt_clip
, 0, 0, SW_INVALIDATE
);
2884 rt_clip
.right
= pane
->positions
[idx
+1];
2885 RedrawWindow(pane
->hwnd
, &rt_clip
, 0, RDW_INVALIDATE
|RDW_UPDATENOW
);
2887 if (pnmh
->code
== HDN_ENDTRACK
) {
2888 ListBox_SetHorizontalExtent(pane
->hwnd
, pane
->positions
[COLUMNS
]);
2890 if (GetScrollPos(pane
->hwnd
, SB_HORZ
) != scroll_pos
)
2898 case HDN_DIVIDERDBLCLICK
: {
2899 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
2902 calc_single_width(pane
, phdn
->iItem
);
2903 item
.mask
= HDI_WIDTH
;
2904 item
.cxy
= pane
->widths
[phdn
->iItem
];
2906 Header_SetItem(pane
->hwndHeader
, phdn
->iItem
, &item
);
2907 InvalidateRect(pane
->hwnd
, 0, TRUE
);
2914 #endif /* _NO_EXTENSIONS */
2917 static void scan_entry(ChildWnd
* child
, Entry
* entry
, HWND hwnd
)
2919 TCHAR path
[MAX_PATH
];
2920 int idx
= ListBox_GetCurSel(child
->left
.hwnd
);
2921 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
2923 /* delete sub entries in left pane */
2925 LRESULT res
= ListBox_GetItemData(child
->left
.hwnd
, idx
+1);
2926 Entry
* sub
= (Entry
*) res
;
2928 if (res
==LB_ERR
|| !sub
|| sub
->level
<=entry
->level
)
2931 ListBox_DeleteString(child
->left
.hwnd
, idx
+1);
2934 /* empty right pane */
2935 ListBox_ResetContent(child
->right
.hwnd
);
2937 /* release memory */
2938 free_entries(entry
);
2940 /* read contents from disk */
2941 #ifdef _SHELL_FOLDERS
2942 if (entry
->etype
== ET_SHELL
)
2944 read_directory(entry
, NULL
, child
->sortOrder
, hwnd
);
2949 get_path(entry
, path
);
2950 read_directory(entry
, path
, child
->sortOrder
, hwnd
);
2953 /* insert found entries in right pane */
2954 insert_entries(&child
->right
, entry
->down
, -1);
2955 calc_widths(&child
->right
, FALSE
);
2956 #ifndef _NO_EXTENSIONS
2957 set_header(&child
->right
);
2960 child
->header_wdths_ok
= FALSE
;
2962 SetCursor(old_cursor
);
2966 /* expand a directory entry */
2968 static BOOL
expand_entry(ChildWnd
* child
, Entry
* dir
)
2973 if (!dir
|| dir
->expanded
|| !dir
->down
)
2978 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='\0' && p
->next
) {
2981 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='.' &&
2982 p
->data
.cFileName
[2]=='\0' && p
->next
)
2986 /* no subdirectories ? */
2987 if (!(p
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
2990 idx
= ListBox_FindItemData(child
->left
.hwnd
, 0, dir
);
2992 dir
->expanded
= TRUE
;
2994 /* insert entries in left pane */
2995 insert_entries(&child
->left
, p
, idx
);
2997 if (!child
->header_wdths_ok
) {
2998 if (calc_widths(&child
->left
, FALSE
)) {
2999 #ifndef _NO_EXTENSIONS
3000 set_header(&child
->left
);
3003 child
->header_wdths_ok
= TRUE
;
3011 static void collapse_entry(Pane
* pane
, Entry
* dir
)
3013 int idx
= ListBox_FindItemData(pane
->hwnd
, 0, dir
);
3015 ShowWindow(pane
->hwnd
, SW_HIDE
);
3017 /* hide sub entries */
3019 LRESULT res
= ListBox_GetItemData(pane
->hwnd
, idx
+1);
3020 Entry
* sub
= (Entry
*) res
;
3022 if (res
==LB_ERR
|| !sub
|| sub
->level
<=dir
->level
)
3025 ListBox_DeleteString(pane
->hwnd
, idx
+1);
3028 dir
->expanded
= FALSE
;
3030 ShowWindow(pane
->hwnd
, SW_SHOW
);
3034 static void set_curdir(ChildWnd
* child
, Entry
* entry
, HWND hwnd
)
3036 TCHAR path
[MAX_PATH
];
3040 child
->left
.cur
= entry
;
3041 child
->right
.root
= entry
->down
? entry
->down
: entry
;
3042 child
->right
.cur
= entry
;
3044 if (!entry
->scanned
)
3045 scan_entry(child
, entry
, hwnd
);
3047 ListBox_ResetContent(child
->right
.hwnd
);
3048 insert_entries(&child
->right
, entry
->down
, -1);
3049 calc_widths(&child
->right
, FALSE
);
3050 #ifndef _NO_EXTENSIONS
3051 set_header(&child
->right
);
3055 get_path(entry
, path
);
3056 lstrcpy(child
->path
, path
);
3058 if (child
->hwnd
) /* only change window title, if the window already exists */
3059 SetWindowText(child
->hwnd
, path
);
3062 SetCurrentDirectory(path
);
3066 BOOL
launch_file(HWND hwnd
, LPCTSTR cmd
, UINT nCmdShow
)
3068 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, cmd
, NULL
/*parameters*/, NULL
/*dir*/, nCmdShow
);
3070 if ((int)hinst
<= 32) {
3071 display_error(hwnd
, GetLastError());
3079 BOOL
launch_fileA(HWND hwnd
, LPSTR cmd
, UINT nCmdShow
)
3081 HINSTANCE hinst
= ShellExecuteA(hwnd
, NULL
/*operation*/, cmd
, NULL
/*parameters*/, NULL
/*dir*/, nCmdShow
);
3083 if ((int)hinst
<= 32) {
3084 display_error(hwnd
, GetLastError());
3093 BOOL
launch_entry(Entry
* entry
, HWND hwnd
, UINT nCmdShow
)
3095 TCHAR cmd
[MAX_PATH
];
3097 #ifdef _SHELL_FOLDERS
3098 if (entry
->etype
== ET_SHELL
) {
3101 SHELLEXECUTEINFO shexinfo
;
3103 shexinfo
.cbSize
= sizeof(SHELLEXECUTEINFO
);
3104 shexinfo
.fMask
= SEE_MASK_IDLIST
;
3105 shexinfo
.hwnd
= hwnd
;
3106 shexinfo
.lpVerb
= NULL
;
3107 shexinfo
.lpFile
= NULL
;
3108 shexinfo
.lpParameters
= NULL
;
3109 shexinfo
.lpDirectory
= NULL
;
3110 shexinfo
.nShow
= nCmdShow
;
3111 shexinfo
.lpIDList
= get_to_absolute_pidl(entry
, hwnd
);
3113 if (!ShellExecuteEx(&shexinfo
)) {
3114 display_error(hwnd
, GetLastError());
3118 if (shexinfo
.lpIDList
!= entry
->pidl
)
3119 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, shexinfo
.lpIDList
);
3125 get_path(entry
, cmd
);
3127 /* start program, open document... */
3128 return launch_file(hwnd
, cmd
, nCmdShow
);
3132 static void activate_entry(ChildWnd
* child
, Pane
* pane
, HWND hwnd
)
3134 Entry
* entry
= pane
->cur
;
3139 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
3140 int scanned_old
= entry
->scanned
;
3143 scan_entry(child
, entry
, hwnd
);
3145 #ifndef _NO_EXTENSIONS
3146 if (entry
->data
.cFileName
[0]=='.' && entry
->data
.cFileName
[1]=='\0')
3150 if (entry
->data
.cFileName
[0]=='.' && entry
->data
.cFileName
[1]=='.' && entry
->data
.cFileName
[2]=='\0') {
3151 entry
= child
->left
.cur
->up
;
3152 collapse_entry(&child
->left
, entry
);
3154 } else if (entry
->expanded
)
3155 collapse_entry(pane
, child
->left
.cur
);
3157 expand_entry(child
, child
->left
.cur
);
3159 if (!pane
->treePane
) focus_entry
: {
3160 int idx
= ListBox_FindItemData(child
->left
.hwnd
, ListBox_GetCurSel(child
->left
.hwnd
), entry
);
3161 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
3162 set_curdir(child
, entry
, hwnd
);
3167 calc_widths(pane
, FALSE
);
3169 #ifndef _NO_EXTENSIONS
3174 launch_entry(entry
, child
->hwnd
, SW_SHOWNORMAL
);
3179 static BOOL
pane_command(Pane
* pane
, UINT cmd
)
3183 if (pane
->visible_cols
) {
3184 pane
->visible_cols
= 0;
3185 calc_widths(pane
, TRUE
);
3186 #ifndef _NO_EXTENSIONS
3189 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3190 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
|MF_CHECKED
);
3191 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_ALL_ATTRIBUTES
, MF_BYCOMMAND
);
3192 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SELECTED_ATTRIBUTES
, MF_BYCOMMAND
);
3196 case ID_VIEW_ALL_ATTRIBUTES
:
3197 if (pane
->visible_cols
!= COL_ALL
) {
3198 pane
->visible_cols
= COL_ALL
;
3199 calc_widths(pane
, TRUE
);
3200 #ifndef _NO_EXTENSIONS
3203 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3204 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
);
3205 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_ALL_ATTRIBUTES
, MF_BYCOMMAND
|MF_CHECKED
);
3206 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SELECTED_ATTRIBUTES
, MF_BYCOMMAND
);
3210 #ifndef _NO_EXTENSIONS
3211 case ID_PREFERED_SIZES
: {
3212 calc_widths(pane
, TRUE
);
3214 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3218 /* TODO: more command ids... */
3228 static HRESULT
ShellFolderContextMenu(IShellFolder
* shell_folder
, HWND hwndParent
, int cidl
, LPCITEMIDLIST
* apidl
, int x
, int y
)
3232 HRESULT hr
= (*shell_folder
->lpVtbl
->GetUIObjectOf
)(shell_folder
, hwndParent
, cidl
, apidl
, &IID_IContextMenu
, NULL
, (LPVOID
*)&pcm
);
3233 /* HRESULT hr = CDefFolderMenu_Create2(dir?dir->_pidl:DesktopFolder(), hwndParent, 1, &pidl, shell_folder, NULL, 0, NULL, &pcm); */
3235 if (SUCCEEDED(hr
)) {
3236 HMENU hmenu
= CreatePopupMenu();
3239 hr
= (*pcm
->lpVtbl
->QueryContextMenu
)(pcm
, hmenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, CMF_NORMAL
);
3241 if (SUCCEEDED(hr
)) {
3242 UINT idCmd
= TrackPopupMenu(hmenu
, TPM_LEFTALIGN
|TPM_RETURNCMD
|TPM_RIGHTBUTTON
, x
, y
, 0, hwndParent
, NULL
);
3245 CMINVOKECOMMANDINFO cmi
;
3247 cmi
.cbSize
= sizeof(CMINVOKECOMMANDINFO
);
3249 cmi
.hwnd
= hwndParent
;
3250 cmi
.lpVerb
= (LPCSTR
)(INT_PTR
)(idCmd
- FCIDM_SHVIEWFIRST
);
3251 cmi
.lpParameters
= NULL
;
3252 cmi
.lpDirectory
= NULL
;
3253 cmi
.nShow
= SW_SHOWNORMAL
;
3257 hr
= (*pcm
->lpVtbl
->InvokeCommand
)(pcm
, &cmi
);
3262 (*pcm
->lpVtbl
->Release
)(pcm
);
3269 LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
3271 static int last_split
;
3273 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(hwnd
, GWL_USERDATA
);
3278 LPDRAWITEMSTRUCT dis
= (LPDRAWITEMSTRUCT
)lparam
;
3279 Entry
* entry
= (Entry
*) dis
->itemData
;
3281 if (dis
->CtlID
== IDW_TREE_LEFT
)
3282 draw_item(&child
->left
, dis
, entry
, -1);
3284 draw_item(&child
->right
, dis
, entry
, -1);
3289 InitChildWindow(child
);
3293 free_child_window(child
);
3294 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
3301 GetClientRect(hwnd
, &rt
);
3302 BeginPaint(hwnd
, &ps
);
3303 rt
.left
= child
->split_pos
-SPLIT_WIDTH
/2;
3304 rt
.right
= child
->split_pos
+SPLIT_WIDTH
/2+1;
3305 lastBrush
= SelectBrush(ps
.hdc
, (HBRUSH
)GetStockObject(COLOR_SPLITBAR
));
3306 Rectangle(ps
.hdc
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
3307 SelectObject(ps
.hdc
, lastBrush
);
3308 #ifdef _NO_EXTENSIONS
3309 rt
.top
= rt
.bottom
- GetSystemMetrics(SM_CYHSCROLL
);
3310 FillRect(ps
.hdc
, &rt
, GetStockObject(BLACK_BRUSH
));
3312 EndPaint(hwnd
, &ps
);
3316 if (LOWORD(lparam
) == HTCLIENT
) {
3319 ScreenToClient(hwnd
, &pt
);
3321 if (pt
.x
>=child
->split_pos
-SPLIT_WIDTH
/2 && pt
.x
<child
->split_pos
+SPLIT_WIDTH
/2+1) {
3322 SetCursor(LoadCursor(0, IDC_SIZEWE
));
3328 case WM_LBUTTONDOWN
: {
3330 int x
= LOWORD(lparam
);
3332 GetClientRect(hwnd
, &rt
);
3334 if (x
>=child
->split_pos
-SPLIT_WIDTH
/2 && x
<child
->split_pos
+SPLIT_WIDTH
/2+1) {
3335 last_split
= child
->split_pos
;
3336 #ifdef _NO_EXTENSIONS
3337 draw_splitbar(hwnd
, last_split
);
3345 if (GetCapture() == hwnd
) {
3346 #ifdef _NO_EXTENSIONS
3348 int x
= LOWORD(lparam
);
3349 draw_splitbar(hwnd
, last_split
);
3351 GetClientRect(hwnd
, &rt
);
3352 child
->split_pos
= x
;
3353 resize_tree(child
, rt
.right
, rt
.bottom
);
3359 #ifdef _NO_EXTENSIONS
3360 case WM_CAPTURECHANGED
:
3361 if (GetCapture()==hwnd
&& last_split
>=0)
3362 draw_splitbar(hwnd
, last_split
);
3367 if (wparam
== VK_ESCAPE
)
3368 if (GetCapture() == hwnd
) {
3370 #ifdef _NO_EXTENSIONS
3371 draw_splitbar(hwnd
, last_split
);
3373 child
->split_pos
= last_split
;
3375 GetClientRect(hwnd
, &rt
);
3376 resize_tree(child
, rt
.right
, rt
.bottom
);
3379 SetCursor(LoadCursor(0, IDC_ARROW
));
3384 if (GetCapture() == hwnd
) {
3386 int x
= LOWORD(lparam
);
3388 #ifdef _NO_EXTENSIONS
3389 HDC hdc
= GetDC(hwnd
);
3390 GetClientRect(hwnd
, &rt
);
3392 rt
.left
= last_split
-SPLIT_WIDTH
/2;
3393 rt
.right
= last_split
+SPLIT_WIDTH
/2+1;
3394 InvertRect(hdc
, &rt
);
3397 rt
.left
= x
-SPLIT_WIDTH
/2;
3398 rt
.right
= x
+SPLIT_WIDTH
/2+1;
3399 InvertRect(hdc
, &rt
);
3401 ReleaseDC(hwnd
, hdc
);
3403 GetClientRect(hwnd
, &rt
);
3405 if (x
>=0 && x
<rt
.right
) {
3406 child
->split_pos
= x
;
3407 resize_tree(child
, rt
.right
, rt
.bottom
);
3408 rt
.left
= x
-SPLIT_WIDTH
/2;
3409 rt
.right
= x
+SPLIT_WIDTH
/2+1;
3410 InvalidateRect(hwnd
, &rt
, FALSE
);
3411 UpdateWindow(child
->left
.hwnd
);
3413 UpdateWindow(child
->right
.hwnd
);
3419 #ifndef _NO_EXTENSIONS
3420 case WM_GETMINMAXINFO
:
3421 DefMDIChildProc(hwnd
, nmsg
, wparam
, lparam
);
3423 {LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
3425 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
3426 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
3428 #endif /* _NO_EXTENSIONS */
3431 SetCurrentDirectory(child
->path
);
3432 SetFocus(child
->focus_pane
? child
->right
.hwnd
: child
->left
.hwnd
);
3435 case WM_DISPATCH_COMMAND
: {
3436 Pane
* pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
3438 switch(LOWORD(wparam
)) {
3439 case ID_WINDOW_NEW
: {
3440 ChildWnd
* new_child
= alloc_child_window(child
->path
, NULL
, hwnd
);
3442 if (!create_child_window(new_child
))
3448 scan_entry(child
, pane
->cur
, hwnd
);
3452 activate_entry(child
, pane
, hwnd
);
3456 return pane_command(pane
, LOWORD(wparam
));
3462 Pane
* pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
3464 switch(HIWORD(wparam
)) {
3465 case LBN_SELCHANGE
: {
3466 int idx
= ListBox_GetCurSel(pane
->hwnd
);
3467 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, idx
);
3469 if (pane
== &child
->left
)
3470 set_curdir(child
, entry
, hwnd
);
3476 activate_entry(child
, pane
, hwnd
);
3481 #ifndef _NO_EXTENSIONS
3483 NMHDR
* pnmh
= (NMHDR
*) lparam
;
3484 return pane_notify(pnmh
->idFrom
==IDW_HEADER_LEFT
? &child
->left
: &child
->right
, pnmh
);}
3487 #ifdef _SHELL_FOLDERS
3488 case WM_CONTEXTMENU
: {
3492 /* first select the current item in the listbox */
3493 HWND hpanel
= (HWND
) wparam
;
3494 POINTS
* ppos
= &MAKEPOINTS(lparam
);
3495 POINT pt
; POINTSTOPOINT(pt
, *ppos
);
3496 ScreenToClient(hpanel
, &pt
);
3497 SendMessage(hpanel
, WM_LBUTTONDOWN
, 0, MAKELONG(pt
.x
, pt
.y
));
3498 SendMessage(hpanel
, WM_LBUTTONUP
, 0, MAKELONG(pt
.x
, pt
.y
));
3500 /* now create the popup menu using shell namespace and IContextMenu */
3501 pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
3502 idx
= ListBox_GetCurSel(pane
->hwnd
);
3506 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, idx
);
3508 LPITEMIDLIST pidl_abs
= get_to_absolute_pidl(entry
, hwnd
);
3511 IShellFolder
* parentFolder
;
3512 LPCITEMIDLIST pidlLast
;
3514 /* get and use the parent folder to display correct context menu in all cases */
3515 if (SUCCEEDED(SHBindToParent(pidl_abs
, &IID_IShellFolder
, (LPVOID
*)&parentFolder
, &pidlLast
))) {
3516 hr
= ShellFolderContextMenu(parentFolder
, hwnd
, 1, &pidlLast
, ppos
->x
, ppos
->y
);
3518 (*parentFolder
->lpVtbl
->Release
)(parentFolder
);
3521 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, pidl_abs
);
3528 if (wparam
!= SIZE_MINIMIZED
)
3529 resize_tree(child
, LOWORD(lparam
), HIWORD(lparam
));
3533 return DefMDIChildProc(hwnd
, nmsg
, wparam
, lparam
);
3540 LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
3542 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(GetParent(hwnd
), GWL_USERDATA
);
3543 Pane
* pane
= (Pane
*) GetWindowLong(hwnd
, GWL_USERDATA
);
3547 #ifndef _NO_EXTENSIONS
3554 child
->focus_pane
= pane
==&child
->right
? 1: 0;
3555 ListBox_SetSel(hwnd
, TRUE
, 1);
3556 /*TODO: check menu items */
3560 if (wparam
== VK_TAB
) {
3561 /*TODO: SetFocus(Globals.hdrivebar) */
3562 SetFocus(child
->focus_pane
? child
->left
.hwnd
: child
->right
.hwnd
);
3566 return CallWindowProc(g_orgTreeWndProc
, hwnd
, nmsg
, wparam
, lparam
);
3570 static void InitInstance(HINSTANCE hinstance
)
3576 INITCOMMONCONTROLSEX icc
= {
3577 sizeof(INITCOMMONCONTROLSEX
),
3583 setlocale(LC_COLLATE
, ""); /* set collating rules to local settings for compareName */
3585 InitCommonControlsEx(&icc
);
3588 /* register frame window class */
3590 wcFrame
.cbSize
= sizeof(WNDCLASSEX
);
3592 wcFrame
.lpfnWndProc
= FrameWndProc
;
3593 wcFrame
.cbClsExtra
= 0;
3594 wcFrame
.cbWndExtra
= 0;
3595 wcFrame
.hInstance
= hinstance
;
3596 wcFrame
.hIcon
= LoadIcon(hinstance
, MAKEINTRESOURCE(IDI_WINEFILE
));
3597 wcFrame
.hCursor
= LoadCursor(0, IDC_ARROW
);
3598 wcFrame
.hbrBackground
= 0;
3599 wcFrame
.lpszMenuName
= 0;
3600 wcFrame
.lpszClassName
= WINEFILEFRAME
;
3601 wcFrame
.hIconSm
= (HICON
)LoadImage(hinstance
,
3602 MAKEINTRESOURCE(IDI_WINEFILE
),
3604 GetSystemMetrics(SM_CXSMICON
),
3605 GetSystemMetrics(SM_CYSMICON
),
3608 Globals
.hframeClass
= RegisterClassEx(&wcFrame
);
3611 /* register tree windows class */
3613 wcChild
.style
= CS_CLASSDC
|CS_DBLCLKS
|CS_VREDRAW
;
3614 wcChild
.lpfnWndProc
= ChildWndProc
;
3615 wcChild
.cbClsExtra
= 0;
3616 wcChild
.cbWndExtra
= 0;
3617 wcChild
.hInstance
= hinstance
;
3619 wcChild
.hCursor
= LoadCursor(0, IDC_ARROW
);
3620 wcChild
.hbrBackground
= 0;
3621 wcChild
.lpszMenuName
= 0;
3622 wcChild
.lpszClassName
= WINEFILETREE
;
3624 hChildClass
= RegisterClass(&wcChild
);
3627 Globals
.haccel
= LoadAccelerators(hinstance
, MAKEINTRESOURCE(IDA_WINEFILE
));
3629 Globals
.hfont
= CreateFont(-MulDiv(8,GetDeviceCaps(hdc
,LOGPIXELSY
),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("MS Shell Dlg"));
3633 Globals
.hInstance
= hinstance
;
3635 #ifdef _SHELL_FOLDERS
3637 CoGetMalloc(MEMCTX_TASK
, &Globals
.iMalloc
);
3638 SHGetDesktopFolder(&Globals
.iDesktop
);
3639 Globals
.cfStrFName
= RegisterClipboardFormat(CFSTR_FILENAME
);
3644 void show_frame(HWND hwndParent
, int cmdshow
)
3646 TCHAR path
[MAX_PATH
];
3648 HMENU hMenuFrame
, hMenuWindow
;
3650 CLIENTCREATESTRUCT ccs
;
3652 if (Globals
.hMainWnd
)
3655 Globals
.hwndParent
= hwndParent
;
3657 hMenuFrame
= LoadMenu(Globals
.hInstance
, MAKEINTRESOURCE(IDM_WINEFILE
));
3658 hMenuWindow
= GetSubMenu(hMenuFrame
, GetMenuItemCount(hMenuFrame
)-2);
3660 Globals
.hMenuFrame
= hMenuFrame
;
3661 Globals
.hMenuView
= GetSubMenu(hMenuFrame
, 3);
3662 Globals
.hMenuOptions
= GetSubMenu(hMenuFrame
, 4);
3664 ccs
.hWindowMenu
= hMenuWindow
;
3665 ccs
.idFirstChild
= IDW_FIRST_CHILD
;
3668 /* create main window */
3669 Globals
.hMainWnd
= CreateWindowEx(0, (LPCTSTR
)(int)Globals
.hframeClass
, TEXT("Wine File"), WS_OVERLAPPEDWINDOW
,
3670 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
3671 hwndParent
, Globals
.hMenuFrame
, Globals
.hInstance
, 0/*lpParam*/);
3674 Globals
.hmdiclient
= CreateWindowEx(0, TEXT("MDICLIENT"), NULL
,
3675 WS_CHILD
|WS_CLIPCHILDREN
|WS_VSCROLL
|WS_HSCROLL
|WS_VISIBLE
|WS_BORDER
,
3677 Globals
.hMainWnd
, 0, Globals
.hInstance
, &ccs
);
3681 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
3685 Globals
.hdrivebar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
3686 IDW_DRIVEBAR
, 2, Globals
.hInstance
, IDB_DRIVEBAR
, &drivebarBtn
,
3687 1, 16, 13, 16, 13, sizeof(TBBUTTON
));
3688 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_DRIVE_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
3690 GetLogicalDriveStrings(BUFFER_LEN
, Globals
.drives
);
3692 drivebarBtn
.fsStyle
= BTNS_BUTTON
;
3694 #ifndef _NO_EXTENSIONS
3696 /* insert unix file system button */
3697 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("/\0"));
3699 drivebarBtn
.idCommand
= ID_DRIVE_UNIX_FS
;
3700 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3701 drivebarBtn
.iString
++;
3703 #ifdef _SHELL_FOLDERS
3704 /* insert shell namespace button */
3705 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Shell\0"));
3707 drivebarBtn
.idCommand
= ID_DRIVE_SHELL_NS
;
3708 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3709 drivebarBtn
.iString
++;
3712 /* register windows drive root strings */
3713 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)Globals
.drives
);
3716 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
3718 for(p
=Globals
.drives
; *p
; ) {
3719 #ifdef _NO_EXTENSIONS
3720 /* insert drive letter */
3721 TCHAR b
[3] = {tolower(*p
)};
3722 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b
);
3724 switch(GetDriveType(p
)) {
3725 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
3726 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
3727 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
3728 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
3729 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
3732 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3733 drivebarBtn
.idCommand
++;
3734 drivebarBtn
.iString
++;
3741 TBBUTTON toolbarBtns
[] = {
3742 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
3743 {0, ID_WINDOW_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
3744 {1, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
3745 {2, ID_WINDOW_TILE_HORZ
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
3746 {3, ID_WINDOW_TILE_VERT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
3748 {4, ID_... , TBSTATE_ENABLED, BTNS_BUTTON},
3749 {5, ID_... , TBSTATE_ENABLED, BTNS_BUTTON},
3752 Globals
.htoolbar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
,
3753 IDW_TOOLBAR
, 2, Globals
.hInstance
, IDB_TOOLBAR
, toolbarBtns
,
3754 sizeof(toolbarBtns
)/sizeof(TBBUTTON
), 16, 15, 16, 15, sizeof(TBBUTTON
));
3755 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_TOOL_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
3758 Globals
.hstatusbar
= CreateStatusWindow(WS_CHILD
|WS_VISIBLE
, 0, Globals
.hMainWnd
, IDW_STATUSBAR
);
3759 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
3761 /* CreateStatusWindow does not accept WS_BORDER
3762 Globals.hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
3763 WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
3764 Globals.hMainWnd, (HMENU)IDW_STATUSBAR, hinstance, 0);*/
3766 /*TODO: read paths and window placements from registry */
3767 GetCurrentDirectory(MAX_PATH
, path
);
3769 ShowWindow(Globals
.hMainWnd
, cmdshow
);
3771 #if defined(_SHELL_FOLDERS) && !defined(__WINE__)
3772 /* Shell Namespace as default: */
3773 child
= alloc_child_window(path
, get_path_pidl(path
,Globals
.hMainWnd
), Globals
.hMainWnd
);
3775 child
= alloc_child_window(path
, NULL
, Globals
.hMainWnd
);
3778 child
->pos
.showCmd
= SW_SHOWMAXIMIZED
;
3779 child
->pos
.rcNormalPosition
.left
= 0;
3780 child
->pos
.rcNormalPosition
.top
= 0;
3781 child
->pos
.rcNormalPosition
.right
= 320;
3782 child
->pos
.rcNormalPosition
.bottom
= 280;
3784 if (!create_child_window(child
))
3787 SetWindowPlacement(child
->hwnd
, &child
->pos
);
3789 Globals
.himl
= ImageList_LoadBitmap(Globals
.hInstance
, MAKEINTRESOURCE(IDB_IMAGES
), 16, 0, RGB(0,255,0));
3791 Globals
.prescan_node
= FALSE
;
3793 UpdateWindow(Globals
.hMainWnd
);
3798 #ifdef _SHELL_FOLDERS
3799 (*Globals
.iDesktop
->lpVtbl
->Release
)(Globals
.iDesktop
);
3800 (*Globals
.iMalloc
->lpVtbl
->Release
)(Globals
.iMalloc
);
3804 ImageList_Destroy(Globals
.himl
);
3808 /* search for already running win[e]files */
3810 static int g_foundPrevInstance
= 0;
3812 static BOOL CALLBACK
EnumWndProc(HWND hwnd
, LPARAM lparam
)
3816 GetClassName(hwnd
, cls
, 128);
3818 if (!lstrcmp(cls
, (LPCTSTR
)lparam
)) {
3819 g_foundPrevInstance
++;
3826 /* search for window of given class name to allow only one running instance */
3827 int find_window_class(LPCTSTR classname
)
3829 EnumWindows(EnumWndProc
, (LPARAM
)classname
);
3831 if (g_foundPrevInstance
)
3838 int winefile_main(HINSTANCE hinstance
, HWND hwndParent
, int cmdshow
)
3842 InitInstance(hinstance
);
3844 #ifndef _ROS_ /* don't maximize if being called from the ROS desktop */
3845 if (cmdshow
== SW_SHOWNORMAL
)
3846 /*TODO: read window placement from registry */
3847 cmdshow
= SW_MAXIMIZE
;
3850 show_frame(hwndParent
, cmdshow
);
3852 while(GetMessage(&msg
, 0, 0, 0)) {
3853 if (Globals
.hmdiclient
&& TranslateMDISysAccel(Globals
.hmdiclient
, &msg
))
3856 if (Globals
.hMainWnd
&& TranslateAccelerator(Globals
.hMainWnd
, Globals
.haccel
, &msg
))
3859 TranslateMessage(&msg
);
3860 DispatchMessage(&msg
);
3871 int APIENTRY
WinMain(HINSTANCE hinstance
,
3872 HINSTANCE previnstance
,
3876 #ifdef _NO_EXTENSIONS
3877 if (find_window_class(WINEFILEFRAME
))
3881 winefile_main(hinstance
, 0, cmdshow
);