4 * Copyright 2000, 2003, 2004 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"
32 #include "externals.h"
36 /* for read_directory_unix() */
37 #if !defined(_NO_EXTENSIONS) && !defined(_WIN32)
50 #define _MAX_FNAME 256
51 #define _MAX_DIR _MAX_FNAME
52 #define _MAX_EXT _MAX_FNAME
57 #define UNION_MEMBER(x) DUMMYUNIONNAME.##x
59 #define UNION_MEMBER(x) x
64 #define DEFAULT_SPLIT_POS 300
66 #define DEFAULT_SPLIT_POS 200
70 WINEFILE_GLOBALS Globals
;
72 extern void WineLicense(HWND hwnd
);
73 extern void WineWarranty(HWND hwnd
);
83 typedef struct _Entry
{
94 #ifndef _NO_EXTENSIONS
95 BY_HANDLE_FILE_INFORMATION bhfi
;
97 enum ENTRY_TYPE etype
;
101 IShellFolder
* folder
;
108 TCHAR path
[MAX_PATH
];
109 TCHAR volname
[_MAX_FNAME
];
119 COL_ATTRIBUTES
= 0x08,
121 #ifdef _NO_EXTENSIONS
122 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
126 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
|COL_INDEX
|COL_LINKS
139 #ifndef _NO_EXTENSIONS
143 #ifndef _NO_EXTENSIONS
149 int positions
[COLUMNS
+1];
161 int focus_pane
; /* 0: left 1: right */
164 BOOL header_wdths_ok
;
166 TCHAR path
[MAX_PATH
];
169 SORT_ORDER sortOrder
;
173 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
);
174 static void set_curdir(ChildWnd
* child
, Entry
* entry
, HWND hwnd
);
175 static void get_path(Entry
* dir
, PTSTR path
);
177 LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
178 LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
179 LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
182 static void display_error(HWND hwnd
, DWORD error
)
186 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_FROM_SYSTEM
,
187 0, error
, MAKELANGID(LANG_NEUTRAL
,SUBLANG_DEFAULT
), (PTSTR
)&msg
, 0, NULL
))
188 MessageBox(hwnd
, msg
, TEXT("Winefile"), MB_OK
);
190 MessageBox(hwnd
, TEXT("Error"), TEXT("Winefile"), MB_OK
);
196 /* allocate and initialise a directory entry */
197 static Entry
* alloc_entry()
199 Entry
* entry
= (Entry
*) malloc(sizeof(Entry
));
201 #ifdef _SHELL_FOLDERS
203 entry
->folder
= NULL
;
210 /* free a directory entry */
211 static void free_entry(Entry
* entry
)
213 #ifdef _SHELL_FOLDERS
214 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
215 DestroyIcon(entry
->hicon
);
217 if (entry
->folder
&& entry
->folder
!=Globals
.iDesktop
)
218 (*entry
->folder
->lpVtbl
->Release
)(entry
->folder
);
221 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, entry
->pidl
);
227 /* recursively free all child entries */
228 static void free_entries(Entry
* dir
)
230 Entry
*entry
, *next
=dir
->down
;
246 static void read_directory_win(Entry
* dir
, LPCTSTR path
)
248 Entry
* first_entry
= NULL
;
252 int level
= dir
->level
+ 1;
253 WIN32_FIND_DATA w32fd
;
255 #ifndef _NO_EXTENSIONS
259 TCHAR buffer
[MAX_PATH
], *p
;
260 for(p
=buffer
; *path
; )
263 lstrcpy(p
, TEXT("\\*"));
265 hFind
= FindFirstFile(buffer
, &w32fd
);
267 if (hFind
!= INVALID_HANDLE_VALUE
) {
269 entry
= alloc_entry();
277 memcpy(&entry
->data
, &w32fd
, sizeof(WIN32_FIND_DATA
));
280 entry
->expanded
= FALSE
;
281 entry
->scanned
= FALSE
;
282 entry
->level
= level
;
284 #ifdef _NO_EXTENSIONS
285 /* hide directory entry "." */
286 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
287 LPCTSTR name
= entry
->data
.cFileName
;
289 if (name
[0]=='.' && name
[1]=='\0')
293 entry
->etype
= ET_WINDOWS
;
294 entry
->bhfi_valid
= FALSE
;
296 lstrcpy(p
+1, entry
->data
.cFileName
);
298 hFile
= CreateFile(buffer
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
,
299 0, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0);
301 if (hFile
!= INVALID_HANDLE_VALUE
) {
302 if (GetFileInformationByHandle(hFile
, &entry
->bhfi
))
303 entry
->bhfi_valid
= TRUE
;
310 } while(FindNextFile(hFind
, &entry
->data
));
317 dir
->down
= first_entry
;
322 static Entry
* find_entry_win(Entry
* dir
, LPCTSTR name
)
326 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
328 LPCTSTR q
= entry
->data
.cFileName
;
331 if (!*p
|| *p
==TEXT('\\') || *p
==TEXT('/'))
333 } while(tolower(*p
++) == tolower(*q
++));
336 q
= entry
->data
.cAlternateFileName
;
339 if (!*p
|| *p
==TEXT('\\') || *p
==TEXT('/'))
341 } while(tolower(*p
++) == tolower(*q
++));
348 static Entry
* read_tree_win(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
350 TCHAR buffer
[MAX_PATH
];
351 Entry
* entry
= &root
->entry
;
355 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
357 #ifndef _NO_EXTENSIONS
358 entry
->etype
= ET_WINDOWS
;
362 while(*s
&& *s
!=TEXT('\\') && *s
!=TEXT('/'))
365 while(*s
==TEXT('\\') || *s
==TEXT('/'))
371 read_directory(entry
, buffer
, sortOrder
, hwnd
);
374 entry
->expanded
= TRUE
;
379 entry
= find_entry_win(entry
, s
);
382 SetCursor(old_cursor
);
388 #if !defined(_NO_EXTENSIONS) && defined(__linux__)
390 static void read_directory_unix(Entry
* dir
, LPCTSTR path
)
392 Entry
* first_entry
= NULL
;
396 int level
= dir
->level
+ 1;
398 DIR* pdir
= opendir(path
);
403 TCHAR buffer
[MAX_PATH
], *p
;
405 for(p
=buffer
; *path
; )
408 if (p
==buffer
|| p
[-1]!='/')
411 while((ent
=readdir(pdir
))) {
412 entry
= alloc_entry();
420 entry
->etype
= ET_UNIX
;
422 lstrcpy(entry
->data
.cFileName
, ent
->d_name
);
423 entry
->data
.dwFileAttributes
= ent
->d_name
[0]=='.'? FILE_ATTRIBUTE_HIDDEN
: 0;
425 strcpy(p
, ent
->d_name
);
427 if (!stat(buffer
, &st
)) {
428 if (S_ISDIR(st
.st_mode
))
429 entry
->data
.dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
431 entry
->data
.nFileSizeLow
= st
.st_size
& 0xFFFFFFFF;
432 entry
->data
.nFileSizeHigh
= st
.st_size
>> 32;
434 memset(&entry
->data
.ftCreationTime
, 0, sizeof(FILETIME
));
435 time_to_filetime(&st
.st_atime
, &entry
->data
.ftLastAccessTime
);
436 time_to_filetime(&st
.st_mtime
, &entry
->data
.ftLastWriteTime
);
438 entry
->bhfi
.nFileIndexLow
= ent
->d_ino
;
439 entry
->bhfi
.nFileIndexHigh
= 0;
441 entry
->bhfi
.nNumberOfLinks
= st
.st_nlink
;
443 entry
->bhfi_valid
= TRUE
;
445 entry
->data
.nFileSizeLow
= 0;
446 entry
->data
.nFileSizeHigh
= 0;
447 entry
->bhfi_valid
= FALSE
;
452 entry
->expanded
= FALSE
;
453 entry
->scanned
= FALSE
;
454 entry
->level
= level
;
464 dir
->down
= first_entry
;
468 static Entry
* find_entry_unix(Entry
* dir
, LPCTSTR name
)
472 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
474 LPCTSTR q
= entry
->data
.cFileName
;
477 if (!*p
|| *p
==TEXT('/'))
479 } while(*p
++ == *q
++);
485 static Entry
* read_tree_unix(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
487 TCHAR buffer
[MAX_PATH
];
488 Entry
* entry
= &root
->entry
;
492 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
494 entry
->etype
= ET_UNIX
;
497 while(*s
&& *s
!=TEXT('/'))
500 while(*s
== TEXT('/'))
506 read_directory(entry
, buffer
, sortOrder
, hwnd
);
509 entry
->expanded
= TRUE
;
514 entry
= find_entry_unix(entry
, s
);
517 SetCursor(old_cursor
);
522 #endif // !defined(_NO_EXTENSIONS) && defined(__linux__)
525 #ifdef _SHELL_FOLDERS
528 #define tcscpyn strcpyn
529 #define get_strret get_strretW
530 #define path_from_pidl path_from_pidlW
532 #define tcscpyn wcscpyn
533 #define get_strret get_strretA
534 #define path_from_pidl path_from_pidlA
538 static LPSTR
strcpyn(LPSTR dest
, LPCSTR source
, size_t count
)
543 for(s
=source
; count
&&(*d
++=*s
++); )
549 static LPWSTR
wcscpyn(LPWSTR dest
, LPCWSTR source
, size_t count
)
554 for(s
=source
; count
&&(*d
++=*s
++); )
561 static void get_strretA(STRRET
* str
, const SHITEMID
* shiid
, LPSTR buffer
, int len
)
565 WideCharToMultiByte(CP_ACP
, 0, str
->UNION_MEMBER(pOleStr
), -1, buffer
, len
, NULL
, NULL
);
569 strcpyn(buffer
, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), len
);
573 strcpyn(buffer
, str
->UNION_MEMBER(cStr
), len
);
577 static void get_strretW(STRRET
* str
, const SHITEMID
* shiid
, LPWSTR buffer
, int len
)
581 wcscpyn(buffer
, str
->UNION_MEMBER(pOleStr
), len
);
585 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), -1, buffer
, len
);
589 MultiByteToWideChar(CP_ACP
, 0, str
->UNION_MEMBER(cStr
), -1, buffer
, len
);
594 static void free_strret(STRRET
* str
)
596 if (str
->uType
== STRRET_WSTR
)
597 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, str
->UNION_MEMBER(pOleStr
));
601 HRESULT
name_from_pidl(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPTSTR buffer
, int len
, SHGDNF flags
)
605 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, flags
, &str
);
608 get_strret(&str
, &pidl
->mkid
, buffer
, len
);
617 HRESULT
path_from_pidlA(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPSTR buffer
, int len
)
621 // SHGDN_FORPARSING: get full path of id list
622 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, SHGDN_FORPARSING
, &str
);
625 get_strretA(&str
, &pidl
->mkid
, buffer
, len
);
633 HRESULT
path_from_pidlW(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPWSTR buffer
, int len
)
637 // SHGDN_FORPARSING: get full path of id list
638 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, SHGDN_FORPARSING
, &str
);
641 get_strretW(&str
, &pidl
->mkid
, buffer
, len
);
650 /* create an item id list from a file system path */
652 static LPITEMIDLIST
get_path_pidl(LPTSTR path
, HWND hwnd
)
659 LPWSTR buffer
= path
;
661 WCHAR buffer
[MAX_PATH
];
662 MultiByteToWideChar(CP_ACP
, 0, path
, -1, buffer
, MAX_PATH
);
665 hr
= (*Globals
.iDesktop
->lpVtbl
->ParseDisplayName
)(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
673 /* convert an item id list from relative to absolute (=relative to the desktop) format */
675 static LPITEMIDLIST
get_to_absolute_pidl(Entry
* entry
, HWND hwnd
)
677 if (entry
->up
&& entry
->up
->etype
==ET_SHELL
) {
678 IShellFolder
* folder
= entry
->up
->folder
;
679 WCHAR buffer
[MAX_PATH
];
681 HRESULT hr
= path_from_pidlW(folder
, entry
->pidl
, buffer
, MAX_PATH
);
687 hr
= (*Globals
.iDesktop
->lpVtbl
->ParseDisplayName
)(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
692 } else if (entry
->etype
== ET_WINDOWS
) {
693 TCHAR path
[MAX_PATH
];
695 get_path(entry
, path
);
697 return get_path_pidl(path
, hwnd
);
698 } else if (entry
->pidl
)
699 return ILClone(entry
->pidl
);
705 HICON
extract_icon(IShellFolder
* folder
, LPCITEMIDLIST pidl
)
707 IExtractIcon
* pExtract
;
709 if (SUCCEEDED((*folder
->lpVtbl
->GetUIObjectOf
)(folder
, 0, 1, (LPCITEMIDLIST
*)&pidl
, &IID_IExtractIcon
, 0, (LPVOID
*)&pExtract
))) {
710 TCHAR path
[_MAX_PATH
];
715 if (SUCCEEDED((*pExtract
->lpVtbl
->GetIconLocation
)(pExtract
, GIL_FORSHELL
, path
, _MAX_PATH
, &idx
, &flags
))) {
716 if (!(flags
& GIL_NOTFILENAME
)) {
718 idx
= 0; /* special case for some control panel applications */
720 if ((int)ExtractIconEx(path
, idx
, 0, &hicon
, 1) > 0)
721 flags
&= ~GIL_DONTCACHE
;
723 HICON hIconLarge
= 0;
725 HRESULT hr
= (*pExtract
->lpVtbl
->Extract
)(pExtract
, path
, idx
, &hIconLarge
, &hicon
, MAKELONG(0/*GetSystemMetrics(SM_CXICON)*/,GetSystemMetrics(SM_CXSMICON
)));
728 DestroyIcon(hIconLarge
);
739 static Entry
* find_entry_shell(Entry
* dir
, LPITEMIDLIST pidl
)
743 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
744 if (entry
->pidl
->mkid
.cb
== pidl
->mkid
.cb
&&
745 !memcmp(entry
->pidl
, pidl
, entry
->pidl
->mkid
.cb
))
752 static Entry
* read_tree_shell(Root
* root
, LPITEMIDLIST pidl
, SORT_ORDER sortOrder
, HWND hwnd
)
754 Entry
* entry
= &root
->entry
;
756 LPITEMIDLIST next_pidl
= pidl
;
757 IShellFolder
* folder
;
758 IShellFolder
* child
= NULL
;
761 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
763 #ifndef _NO_EXTENSIONS
764 entry
->etype
= ET_SHELL
;
767 folder
= Globals
.iDesktop
;
770 entry
->pidl
= next_pidl
;
771 entry
->folder
= folder
;
776 // copy first element of item idlist -> could be replaced by SHBindToParent()
777 next_pidl
= (*Globals
.iMalloc
->lpVtbl
->Alloc
)(Globals
.iMalloc
, pidl
->mkid
.cb
+sizeof(USHORT
));
778 memcpy(next_pidl
, pidl
, pidl
->mkid
.cb
);
779 ((LPITEMIDLIST
)((LPBYTE
)next_pidl
+pidl
->mkid
.cb
))->mkid
.cb
= 0;
781 hr
= (*folder
->lpVtbl
->BindToObject
)(folder
, next_pidl
, 0, &IID_IShellFolder
, (void**)&child
);
785 read_directory(entry
, NULL
, sortOrder
, hwnd
);
788 entry
->expanded
= TRUE
;
790 next
= find_entry_shell(entry
, next_pidl
);
797 // go to next element
798 pidl
= (LPITEMIDLIST
) ((LPBYTE
)pidl
+pidl
->mkid
.cb
);
801 SetCursor(old_cursor
);
807 static void fill_w32fdata_shell(IShellFolder
* folder
, LPCITEMIDLIST pidl
, SFGAOF attribs
, WIN32_FIND_DATA
* w32fdata
)
809 if (!(attribs
& SFGAO_FILESYSTEM
) ||
810 FAILED(SHGetDataFromIDList(folder
, pidl
, SHGDFIL_FINDDATA
, w32fdata
, sizeof(WIN32_FIND_DATA
)))) {
811 WIN32_FILE_ATTRIBUTE_DATA fad
;
812 IDataObject
* pDataObj
;
814 STGMEDIUM medium
= {0, {0}, 0};
815 FORMATETC fmt
= {Globals
.cfStrFName
, 0, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
817 HRESULT hr
= (*folder
->lpVtbl
->GetUIObjectOf
)(folder
, 0, 1, &pidl
, &IID_IDataObject
, 0, (LPVOID
*)&pDataObj
);
820 hr
= (*pDataObj
->lpVtbl
->GetData
)(pDataObj
, &fmt
, &medium
);
822 (*pDataObj
->lpVtbl
->Release
)(pDataObj
);
825 LPCTSTR path
= (LPCTSTR
)GlobalLock(medium
.UNION_MEMBER(hGlobal
));
826 UINT sem_org
= SetErrorMode(SEM_FAILCRITICALERRORS
);
828 if (GetFileAttributesEx(path
, GetFileExInfoStandard
, &fad
)) {
829 w32fdata
->dwFileAttributes
= fad
.dwFileAttributes
;
830 w32fdata
->ftCreationTime
= fad
.ftCreationTime
;
831 w32fdata
->ftLastAccessTime
= fad
.ftLastAccessTime
;
832 w32fdata
->ftLastWriteTime
= fad
.ftLastWriteTime
;
834 if (!(fad
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
835 w32fdata
->nFileSizeLow
= fad
.nFileSizeLow
;
836 w32fdata
->nFileSizeHigh
= fad
.nFileSizeHigh
;
840 SetErrorMode(sem_org
);
842 GlobalUnlock(medium
.UNION_MEMBER(hGlobal
));
843 GlobalFree(medium
.UNION_MEMBER(hGlobal
));
848 if (attribs
& (SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
))
849 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
851 if (attribs
& SFGAO_READONLY
)
852 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_READONLY
;
854 if (attribs
& SFGAO_COMPRESSED
)
855 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_COMPRESSED
;
859 static void read_directory_shell(Entry
* dir
, HWND hwnd
)
861 IShellFolder
* folder
= dir
->folder
;
862 int level
= dir
->level
+ 1;
868 Entry
* first_entry
= NULL
;
875 hr
= (*folder
->lpVtbl
->EnumObjects
)(folder
, hwnd
, SHCONTF_FOLDERS
|SHCONTF_NONFOLDERS
|SHCONTF_INCLUDEHIDDEN
|SHCONTF_SHAREABLE
|SHCONTF_STORAGE
, &idlist
);
879 #define FETCH_ITEM_COUNT 32
880 LPITEMIDLIST pidls
[FETCH_ITEM_COUNT
];
885 memset(pidls
, 0, sizeof(pidls
));
887 hr
= (*idlist
->lpVtbl
->Next
)(idlist
, FETCH_ITEM_COUNT
, pidls
, &cnt
);
894 for(n
=0; n
<cnt
; ++n
) {
895 entry
= alloc_entry();
903 memset(&entry
->data
, 0, sizeof(WIN32_FIND_DATA
));
904 entry
->bhfi_valid
= FALSE
;
906 attribs
= ~SFGAO_FILESYSTEM
; //SFGAO_HASSUBFOLDER|SFGAO_FOLDER; SFGAO_FILESYSTEM sorgt dafür, daß "My Documents" anstatt von "Martin's Documents" angezeigt wird
908 hr
= (*folder
->lpVtbl
->GetAttributesOf
)(folder
, 1, (LPCITEMIDLIST
*)&pidls
[n
], &attribs
);
911 if (attribs
!= (SFGAOF
)~SFGAO_FILESYSTEM
) {
912 fill_w32fdata_shell(folder
, pidls
[n
], attribs
, &entry
->data
);
914 entry
->bhfi_valid
= TRUE
;
920 entry
->pidl
= pidls
[n
];
922 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
923 hr
= (*folder
->lpVtbl
->BindToObject
)(folder
, pidls
[n
], 0, &IID_IShellFolder
, (void**)&child
);
926 entry
->folder
= child
;
928 entry
->folder
= NULL
;
931 entry
->folder
= NULL
;
933 if (!entry
->data
.cFileName
[0])
934 /*hr = */name_from_pidl(folder
, pidls
[n
], entry
->data
.cFileName
, MAX_PATH
, /*SHGDN_INFOLDER*/0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/);
936 /* get display icons for files and virtual objects */
937 if (!(entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
938 !(attribs
& SFGAO_FILESYSTEM
)) {
939 entry
->hicon
= extract_icon(folder
, pidls
[n
]);
942 entry
->hicon
= (HICON
)-1; /* don't try again later */
947 entry
->expanded
= FALSE
;
948 entry
->scanned
= FALSE
;
949 entry
->level
= level
;
951 #ifndef _NO_EXTENSIONS
952 entry
->etype
= ET_SHELL
;
953 entry
->bhfi_valid
= FALSE
;
960 (*idlist
->lpVtbl
->Release
)(idlist
);
966 dir
->down
= first_entry
;
970 #endif // _SHELL_FOLDERS
973 /* sort order for different directory/file types */
982 /* distinguish between ".", ".." and any other directory names */
983 static int TypeOrderFromDirname(LPCTSTR name
)
985 if (name
[0] == '.') {
987 return TO_DOT
; /* "." */
989 if (name
[1]=='.' && name
[2]=='\0')
990 return TO_DOTDOT
; /* ".." */
993 return TO_OTHER_DIR
; /* anything else */
996 /* directories first... */
997 static int compareType(const WIN32_FIND_DATA
* fd1
, const WIN32_FIND_DATA
* fd2
)
999 int order1
= fd1
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1000 int order2
= fd2
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1002 /* Handle "." and ".." as special case and move them at the very first beginning. */
1003 if (order1
==TO_DIR
&& order2
==TO_DIR
) {
1004 order1
= TypeOrderFromDirname(fd1
->cFileName
);
1005 order2
= TypeOrderFromDirname(fd2
->cFileName
);
1008 return order2
==order1
? 0: order1
<order2
? -1: 1;
1012 static int compareName(const void* arg1
, const void* arg2
)
1014 const WIN32_FIND_DATA
* fd1
= &(*(Entry
**)arg1
)->data
;
1015 const WIN32_FIND_DATA
* fd2
= &(*(Entry
**)arg2
)->data
;
1017 int cmp
= compareType(fd1
, fd2
);
1021 return lstrcmpi(fd1
->cFileName
, fd2
->cFileName
);
1024 static int compareExt(const void* arg1
, const void* arg2
)
1026 const WIN32_FIND_DATA
* fd1
= &(*(Entry
**)arg1
)->data
;
1027 const WIN32_FIND_DATA
* fd2
= &(*(Entry
**)arg2
)->data
;
1028 const TCHAR
*name1
, *name2
, *ext1
, *ext2
;
1030 int cmp
= compareType(fd1
, fd2
);
1034 name1
= fd1
->cFileName
;
1035 name2
= fd2
->cFileName
;
1037 ext1
= _tcsrchr(name1
, TEXT('.'));
1038 ext2
= _tcsrchr(name2
, TEXT('.'));
1050 cmp
= lstrcmpi(ext1
, ext2
);
1054 return lstrcmpi(name1
, name2
);
1057 static int compareSize(const void* arg1
, const void* arg2
)
1059 WIN32_FIND_DATA
* fd1
= &(*(Entry
**)arg1
)->data
;
1060 WIN32_FIND_DATA
* fd2
= &(*(Entry
**)arg2
)->data
;
1062 int cmp
= compareType(fd1
, fd2
);
1066 cmp
= fd2
->nFileSizeHigh
- fd1
->nFileSizeHigh
;
1073 cmp
= fd2
->nFileSizeLow
- fd1
->nFileSizeLow
;
1075 return cmp
<0? -1: cmp
>0? 1: 0;
1078 static int compareDate(const void* arg1
, const void* arg2
)
1080 WIN32_FIND_DATA
* fd1
= &(*(Entry
**)arg1
)->data
;
1081 WIN32_FIND_DATA
* fd2
= &(*(Entry
**)arg2
)->data
;
1083 int cmp
= compareType(fd1
, fd2
);
1087 return CompareFileTime(&fd2
->ftLastWriteTime
, &fd1
->ftLastWriteTime
);
1091 static int (*sortFunctions
[])(const void* arg1
, const void* arg2
) = {
1092 compareName
, /* SORT_NAME */
1093 compareExt
, /* SORT_EXT */
1094 compareSize
, /* SORT_SIZE */
1095 compareDate
/* SORT_DATE */
1099 static void SortDirectory(Entry
* dir
, SORT_ORDER sortOrder
)
1101 Entry
* entry
= dir
->down
;
1106 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1110 array
= (Entry
**) alloca(len
*sizeof(Entry
*));
1113 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1116 /* call qsort with the appropriate compare function */
1117 qsort(array
, len
, sizeof(array
[0]), sortFunctions
[sortOrder
]);
1119 dir
->down
= array
[0];
1121 for(p
=array
; --len
; p
++)
1129 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
1131 TCHAR buffer
[MAX_PATH
];
1136 #ifdef _SHELL_FOLDERS
1137 if (dir
->etype
== ET_SHELL
)
1139 read_directory_shell(dir
, hwnd
);
1141 if (Globals
.prescan_node
) {
1150 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1151 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1152 read_directory_shell(entry
, hwnd
);
1153 SortDirectory(entry
, sortOrder
);
1159 #if !defined(_NO_EXTENSIONS) && defined(__linux__)
1160 if (dir
->etype
== ET_UNIX
)
1162 read_directory_unix(dir
, path
);
1164 if (Globals
.prescan_node
) {
1173 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1174 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1175 lstrcpy(d
, entry
->data
.cFileName
);
1176 read_directory_unix(entry
, buffer
);
1177 SortDirectory(entry
, sortOrder
);
1184 read_directory_win(dir
, path
);
1186 if (Globals
.prescan_node
) {
1195 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1196 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1197 lstrcpy(d
, entry
->data
.cFileName
);
1198 read_directory_win(entry
, buffer
);
1199 SortDirectory(entry
, sortOrder
);
1204 SortDirectory(dir
, sortOrder
);
1208 static ChildWnd
* alloc_child_window(LPCTSTR path
, LPITEMIDLIST pidl
, HWND hwnd
)
1210 TCHAR drv
[_MAX_DRIVE
+1], dir
[_MAX_DIR
], name
[_MAX_FNAME
], ext
[_MAX_EXT
];
1211 ChildWnd
* child
= (ChildWnd
*) malloc(sizeof(ChildWnd
));
1212 Root
* root
= &child
->root
;
1215 memset(child
, 0, sizeof(ChildWnd
));
1217 child
->left
.treePane
= TRUE
;
1218 child
->left
.visible_cols
= 0;
1220 child
->right
.treePane
= FALSE
;
1221 #ifndef _NO_EXTENSIONS
1222 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_INDEX
|COL_LINKS
;
1224 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
;
1227 child
->pos
.length
= sizeof(WINDOWPLACEMENT
);
1228 child
->pos
.flags
= 0;
1229 child
->pos
.showCmd
= SW_SHOWNORMAL
;
1230 child
->pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
1231 child
->pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
1232 child
->pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
1233 child
->pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
1235 child
->focus_pane
= 0;
1236 child
->split_pos
= DEFAULT_SPLIT_POS
;
1237 child
->sortOrder
= SORT_NAME
;
1238 child
->header_wdths_ok
= FALSE
;
1242 lstrcpy(child
->path
, path
);
1244 _tsplitpath(path
, drv
, dir
, name
, ext
);
1247 root
->entry
.level
= 0;
1249 #ifdef _SHELL_FOLDERS
1252 root
->drive_type
= DRIVE_UNKNOWN
;
1253 lstrcpy(drv
, TEXT("\\"));
1254 lstrcpy(root
->volname
, TEXT("Desktop"));
1256 lstrcpy(root
->fs
, TEXT("Shell"));
1258 entry
= read_tree_shell(root
, pidl
, child
->sortOrder
, hwnd
);
1262 #if !defined(_NO_EXTENSIONS) && defined(__linux__)
1265 root
->drive_type
= GetDriveType(path
);
1267 lstrcat(drv
, TEXT("/"));
1268 lstrcpy(root
->volname
, TEXT("root fs"));
1270 lstrcpy(root
->fs
, TEXT("unixfs"));
1272 lstrcpy(root
->path
, TEXT("/"));
1273 entry
= read_tree_unix(root
, path
, child
->sortOrder
, hwnd
);
1278 root
->drive_type
= GetDriveType(path
);
1280 lstrcat(drv
, TEXT("\\"));
1281 GetVolumeInformation(drv
, root
->volname
, _MAX_FNAME
, 0, 0, &root
->fs_flags
, root
->fs
, _MAX_DIR
);
1283 lstrcpy(root
->path
, drv
);
1284 entry
= read_tree_win(root
, path
, child
->sortOrder
, hwnd
);
1287 #ifdef _SHELL_FOLDERS
1288 if (root
->entry
.etype
== ET_SHELL
)
1289 lstrcpy(root
->entry
.data
.cFileName
, TEXT("Desktop"));
1292 wsprintf(root
->entry
.data
.cFileName
, TEXT("%s - %s"), drv
, root
->fs
);
1294 root
->entry
.data
.dwFileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
1296 child
->left
.root
= &root
->entry
;
1297 child
->right
.root
= NULL
;
1299 set_curdir(child
, entry
, hwnd
);
1305 /* free all memory associated with a child window */
1306 static void free_child_window(ChildWnd
* child
)
1308 free_entries(&child
->root
.entry
);
1313 /* get full path of specified directory entry */
1314 static void get_path(Entry
* dir
, PTSTR path
)
1320 #ifdef _SHELL_FOLDERS
1321 if (dir
->etype
== ET_SHELL
)
1326 path
[0] = TEXT('\0');
1331 hr
= (*dir
->folder
->lpVtbl
->GetAttributesOf
)(dir
->folder
, 1, (LPCITEMIDLIST
*)&dir
->pidl
, &attribs
);
1333 if (SUCCEEDED(hr
) && (attribs
&SFGAO_FILESYSTEM
)) {
1334 IShellFolder
* parent
= dir
->up
? dir
->up
->folder
: Globals
.iDesktop
;
1336 hr
= path_from_pidl(parent
, dir
->pidl
, path
, MAX_PATH
);
1342 for(entry
=dir
; entry
; level
++) {
1348 name
= entry
->data
.cFileName
;
1351 for(l
=0; *s
&& *s
!=TEXT('/') && *s
!=TEXT('\\'); s
++)
1357 memmove(path
+l
+1, path
, len
*sizeof(TCHAR
));
1358 memcpy(path
+1, name
, l
*sizeof(TCHAR
));
1361 #ifndef _NO_EXTENSIONS
1362 if (entry
->etype
== ET_UNIX
)
1363 path
[0] = TEXT('/');
1366 path
[0] = TEXT('\\');
1371 memmove(path
+l
, path
, len
*sizeof(TCHAR
));
1372 memcpy(path
, name
, l
*sizeof(TCHAR
));
1379 #ifndef _NO_EXTENSIONS
1380 if (entry
->etype
== ET_UNIX
)
1381 path
[len
++] = TEXT('/');
1384 path
[len
++] = TEXT('\\');
1387 path
[len
] = TEXT('\0');
1392 static void resize_frame_rect(HWND hwnd
, PRECT prect
)
1397 if (IsWindowVisible(Globals
.htoolbar
)) {
1398 SendMessage(Globals
.htoolbar
, WM_SIZE
, 0, 0);
1399 GetClientRect(Globals
.htoolbar
, &rt
);
1400 prect
->top
= rt
.bottom
+3;
1401 prect
->bottom
-= rt
.bottom
+3;
1404 if (IsWindowVisible(Globals
.hdrivebar
)) {
1405 SendMessage(Globals
.hdrivebar
, WM_SIZE
, 0, 0);
1406 GetClientRect(Globals
.hdrivebar
, &rt
);
1407 new_top
= --prect
->top
+ rt
.bottom
+3;
1408 MoveWindow(Globals
.hdrivebar
, 0, prect
->top
, rt
.right
, new_top
, TRUE
);
1409 prect
->top
= new_top
;
1410 prect
->bottom
-= rt
.bottom
+2;
1413 if (IsWindowVisible(Globals
.hstatusbar
)) {
1414 int parts
[] = {300, 500};
1416 SendMessage(Globals
.hstatusbar
, WM_SIZE
, 0, 0);
1417 SendMessage(Globals
.hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1418 GetClientRect(Globals
.hstatusbar
, &rt
);
1419 prect
->bottom
-= rt
.bottom
;
1422 MoveWindow(Globals
.hmdiclient
, prect
->left
-1,prect
->top
-1,prect
->right
+2,prect
->bottom
+1, TRUE
);
1425 static void resize_frame(HWND hwnd
, int cx
, int cy
)
1434 resize_frame_rect(hwnd
, &rect
);
1437 static void resize_frame_client(HWND hwnd
)
1441 GetClientRect(hwnd
, &rect
);
1443 resize_frame_rect(hwnd
, &rect
);
1447 static HHOOK hcbthook
;
1448 static ChildWnd
* newchild
= NULL
;
1450 LRESULT CALLBACK
CBTProc(int code
, WPARAM wparam
, LPARAM lparam
)
1452 if (code
==HCBT_CREATEWND
&& newchild
) {
1453 ChildWnd
* child
= newchild
;
1456 child
->hwnd
= (HWND
) wparam
;
1457 SetWindowLong(child
->hwnd
, GWL_USERDATA
, (LPARAM
)child
);
1460 return CallNextHookEx(hcbthook
, code
, wparam
, lparam
);
1463 static HWND
create_child_window(ChildWnd
* child
)
1465 MDICREATESTRUCT mcs
;
1468 mcs
.szClass
= WINEFILETREE
;
1469 mcs
.szTitle
= (LPTSTR
)child
->path
;
1470 mcs
.hOwner
= Globals
.hInstance
;
1471 mcs
.x
= child
->pos
.rcNormalPosition
.left
;
1472 mcs
.y
= child
->pos
.rcNormalPosition
.top
;
1473 mcs
.cx
= child
->pos
.rcNormalPosition
.right
-child
->pos
.rcNormalPosition
.left
;
1474 mcs
.cy
= child
->pos
.rcNormalPosition
.bottom
-child
->pos
.rcNormalPosition
.top
;
1478 hcbthook
= SetWindowsHookEx(WH_CBT
, CBTProc
, 0, GetCurrentThreadId());
1481 child
->hwnd
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDICREATE
, 0, (LPARAM
)&mcs
);
1483 UnhookWindowsHookEx(hcbthook
);
1487 UnhookWindowsHookEx(hcbthook
);
1489 idx
= ListBox_FindItemData(child
->left
.hwnd
, ListBox_GetCurSel(child
->left
.hwnd
), child
->left
.cur
);
1490 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
1496 struct ExecuteDialog
{
1497 TCHAR cmd
[MAX_PATH
];
1502 static BOOL CALLBACK
ExecuteDialogWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1504 static struct ExecuteDialog
* dlg
;
1508 dlg
= (struct ExecuteDialog
*) lparam
;
1512 int id
= (int)wparam
;
1515 GetWindowText(GetDlgItem(hwnd
, 201), dlg
->cmd
, MAX_PATH
);
1516 dlg
->cmdshow
= Button_GetState(GetDlgItem(hwnd
,214))&BST_CHECKED
?
1517 SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
1518 EndDialog(hwnd
, id
);
1519 } else if (id
== IDCANCEL
)
1520 EndDialog(hwnd
, id
);
1529 #ifndef _NO_EXTENSIONS
1531 static struct FullScreenParameters
{
1541 void frame_get_clientspace(HWND hwnd
, PRECT prect
)
1545 if (!IsIconic(hwnd
))
1546 GetClientRect(hwnd
, prect
);
1550 GetWindowPlacement(hwnd
, &wp
);
1552 prect
->left
= prect
->top
= 0;
1553 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
1554 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
1555 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
1556 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
1557 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
1560 if (IsWindowVisible(Globals
.htoolbar
)) {
1561 GetClientRect(Globals
.htoolbar
, &rt
);
1562 prect
->top
+= rt
.bottom
+2;
1565 if (IsWindowVisible(Globals
.hdrivebar
)) {
1566 GetClientRect(Globals
.hdrivebar
, &rt
);
1567 prect
->top
+= rt
.bottom
+2;
1570 if (IsWindowVisible(Globals
.hstatusbar
)) {
1571 GetClientRect(Globals
.hstatusbar
, &rt
);
1572 prect
->bottom
-= rt
.bottom
;
1576 static BOOL
toggle_fullscreen(HWND hwnd
)
1580 if ((g_fullscreen
.mode
=!g_fullscreen
.mode
)) {
1581 GetWindowRect(hwnd
, &g_fullscreen
.orgPos
);
1582 g_fullscreen
.wasZoomed
= IsZoomed(hwnd
);
1584 Frame_CalcFrameClient(hwnd
, &rt
);
1585 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
1586 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
1588 rt
.left
= g_fullscreen
.orgPos
.left
-rt
.left
;
1589 rt
.top
= g_fullscreen
.orgPos
.top
-rt
.top
;
1590 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+g_fullscreen
.orgPos
.right
-rt
.right
;
1591 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+g_fullscreen
.orgPos
.bottom
-rt
.bottom
;
1593 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
1595 MoveWindow(hwnd
, g_fullscreen
.orgPos
.left
, g_fullscreen
.orgPos
.top
,
1596 g_fullscreen
.orgPos
.right
-g_fullscreen
.orgPos
.left
,
1597 g_fullscreen
.orgPos
.bottom
-g_fullscreen
.orgPos
.top
, TRUE
);
1599 if (g_fullscreen
.wasZoomed
)
1600 ShowWindow(hwnd
, WS_MAXIMIZE
);
1603 return g_fullscreen
.mode
;
1606 static void fullscreen_move(HWND hwnd
)
1609 GetWindowRect(hwnd
, &pos
);
1611 Frame_CalcFrameClient(hwnd
, &rt
);
1612 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
1613 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
1615 rt
.left
= pos
.left
-rt
.left
;
1616 rt
.top
= pos
.top
-rt
.top
;
1617 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
1618 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
1620 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
1626 static void toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
)
1628 BOOL vis
= IsWindowVisible(hchild
);
1630 CheckMenuItem(Globals
.hMenuOptions
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
1632 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
1634 #ifndef _NO_EXTENSIONS
1635 if (g_fullscreen
.mode
)
1636 fullscreen_move(hwnd
);
1639 resize_frame_client(hwnd
);
1642 BOOL
activate_drive_window(LPCTSTR path
)
1644 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
1647 _tsplitpath(path
, drv1
, 0, 0, 0);
1649 /* search for a already open window for the same drive */
1650 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1651 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
1654 _tsplitpath(child
->root
.path
, drv2
, 0, 0, 0);
1656 if (!lstrcmpi(drv2
, drv1
)) {
1657 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1659 if (IsMinimized(child_wnd
))
1660 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1670 BOOL
activate_fs_window(LPCTSTR filesys
)
1674 /* search for a already open window of the given file system name */
1675 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1676 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
1679 if (!lstrcmpi(child
->root
.fs
, filesys
)) {
1680 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1682 if (IsMinimized(child_wnd
))
1683 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1693 LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1697 DestroyWindow(hwnd
);
1699 // clear handle variables
1700 Globals
.hMenuFrame
= 0;
1701 Globals
.hMenuView
= 0;
1702 Globals
.hMenuOptions
= 0;
1703 Globals
.hMainWnd
= 0;
1704 Globals
.hmdiclient
= 0;
1705 Globals
.hdrivebar
= 0;
1709 // don't exit desktop when closing file manager window
1710 if (!Globals
.hwndParent
)
1715 UINT cmd
= LOWORD(wparam
);
1716 HWND hwndClient
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1718 if (SendMessage(hwndClient
, WM_DISPATCH_COMMAND
, wparam
, lparam
))
1721 if (cmd
>=ID_DRIVE_FIRST
&& cmd
<=ID_DRIVE_FIRST
+0xFF) {
1722 TCHAR drv
[_MAX_DRIVE
], path
[MAX_PATH
];
1724 LPCTSTR root
= Globals
.drives
;
1727 for(i
=cmd
-ID_DRIVE_FIRST
; i
--; root
++)
1731 if (activate_drive_window(root
))
1734 _tsplitpath(root
, drv
, 0, 0, 0);
1736 if (!SetCurrentDirectory(drv
)) {
1737 display_error(hwnd
, GetLastError());
1741 GetCurrentDirectory(MAX_PATH
, path
); /*TODO: store last directory per drive */
1742 child
= alloc_child_window(path
, NULL
, hwnd
);
1744 if (!create_child_window(child
))
1746 } else switch(cmd
) {
1748 SendMessage(hwnd
, WM_CLOSE
, 0, 0);
1751 case ID_WINDOW_NEW
: {
1752 TCHAR path
[MAX_PATH
];
1755 GetCurrentDirectory(MAX_PATH
, path
);
1756 child
= alloc_child_window(path
, NULL
, hwnd
);
1758 if (!create_child_window(child
))
1762 case ID_WINDOW_CASCADE
:
1763 SendMessage(Globals
.hmdiclient
, WM_MDICASCADE
, 0, 0);
1766 case ID_WINDOW_TILE_HORZ
:
1767 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
1770 case ID_WINDOW_TILE_VERT
:
1771 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
1774 case ID_WINDOW_ARRANGE
:
1775 SendMessage(Globals
.hmdiclient
, WM_MDIICONARRANGE
, 0, 0);
1778 case ID_VIEW_TOOL_BAR
:
1779 toggle_child(hwnd
, cmd
, Globals
.htoolbar
);
1782 case ID_VIEW_DRIVE_BAR
:
1783 toggle_child(hwnd
, cmd
, Globals
.hdrivebar
);
1786 case ID_VIEW_STATUSBAR
:
1787 toggle_child(hwnd
, cmd
, Globals
.hstatusbar
);
1791 struct ExecuteDialog dlg
;
1793 memset(&dlg
, 0, sizeof(struct ExecuteDialog
));
1795 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), hwnd
, ExecuteDialogWndProc
, (LPARAM
)&dlg
) == IDOK
) {
1796 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
1798 if ((int)hinst
<= 32)
1799 display_error(hwnd
, GetLastError());
1804 WinHelp(hwnd
, TEXT("winfile"), HELP_INDEX
, 0);
1807 #ifndef _NO_EXTENSIONS
1808 case ID_VIEW_FULLSCREEN
:
1809 CheckMenuItem(Globals
.hMenuOptions
, cmd
, toggle_fullscreen(hwnd
)?MF_CHECKED
:0);
1813 case ID_DRIVE_UNIX_FS
: {
1814 TCHAR path
[MAX_PATH
];
1817 if (activate_fs_window(TEXT("unixfs")))
1820 getcwd(path
, MAX_PATH
);
1821 child
= alloc_child_window(path
, NULL
, hwnd
);
1823 if (!create_child_window(child
))
1827 #ifdef _SHELL_FOLDERS
1828 case ID_DRIVE_SHELL_NS
: {
1829 TCHAR path
[MAX_PATH
];
1832 if (activate_fs_window(TEXT("Shell")))
1835 GetCurrentDirectory(MAX_PATH
, path
);
1836 child
= alloc_child_window(path
, get_path_pidl(path
,hwnd
), hwnd
);
1838 if (!create_child_window(child
))
1844 /*TODO: There are even more menu items! */
1846 #ifndef _NO_EXTENSIONS
1849 WineLicense(Globals
.hMainWnd
);
1852 case ID_NO_WARRANTY
:
1853 WineWarranty(Globals
.hMainWnd
);
1858 ShellAbout(hwnd
, TEXT("WINE"), TEXT("Winefile"), 0);
1861 case ID_ABOUT
: //ID_ABOUT_WINE:
1862 ShellAbout(hwnd
, TEXT("Winefile"), NULL
, 0);
1864 #endif // _NO_EXTENSIONS
1867 /*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE)
1868 STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE);
1869 else */if ((cmd
<IDW_FIRST_CHILD
|| cmd
>=IDW_FIRST_CHILD
+0x100) &&
1870 (cmd
<SC_SIZE
|| cmd
>SC_RESTORE
))
1871 MessageBox(hwnd
, TEXT("Not yet implemented"), TEXT("Winefile"), MB_OK
);
1873 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
1878 resize_frame(hwnd
, LOWORD(lparam
), HIWORD(lparam
));
1879 break; /* do not pass message to DefFrameProc */
1881 #ifndef _NO_EXTENSIONS
1882 case WM_GETMINMAXINFO
: {
1883 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
1885 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
1886 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
1889 case FRM_CALC_CLIENT
:
1890 frame_get_clientspace(hwnd
, (PRECT
)lparam
);
1892 #endif // _NO_EXTENSIONS
1895 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
1902 static const LPTSTR g_pos_names
[COLUMNS
] = {
1903 TEXT(""), /* symbol */
1907 #ifndef _NO_EXTENSIONS
1910 TEXT("Index/Inode"),
1912 #endif // _NO_EXTENSIONS
1914 #ifndef _NO_EXTENSIONS
1919 static const int g_pos_align
[] = {
1921 HDF_LEFT
, /* Name */
1922 HDF_RIGHT
, /* Size */
1923 HDF_LEFT
, /* CDate */
1924 #ifndef _NO_EXTENSIONS
1925 HDF_LEFT
, /* ADate */
1926 HDF_LEFT
, /* MDate */
1927 HDF_LEFT
, /* Index */
1928 HDF_CENTER
, /* Links */
1930 HDF_CENTER
, /* Attributes */
1931 #ifndef _NO_EXTENSIONS
1932 HDF_LEFT
/* Security */
1936 static void resize_tree(ChildWnd
* child
, int cx
, int cy
)
1938 HDWP hdwp
= BeginDeferWindowPos(4);
1946 cx
= child
->split_pos
+ SPLIT_WIDTH
/2;
1948 #ifndef _NO_EXTENSIONS
1956 Header_Layout(child
->left
.hwndHeader
, &hdl
);
1958 DeferWindowPos(hdwp
, child
->left
.hwndHeader
, wp
.hwndInsertAfter
,
1959 wp
.x
-1, wp
.y
, child
->split_pos
-SPLIT_WIDTH
/2+1, wp
.cy
, wp
.flags
);
1960 DeferWindowPos(hdwp
, child
->right
.hwndHeader
, wp
.hwndInsertAfter
,
1961 rt
.left
+cx
+1, wp
.y
, wp
.cx
-cx
+2, wp
.cy
, wp
.flags
);
1963 #endif // _NO_EXTENSIONS
1965 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
);
1966 DeferWindowPos(hdwp
, child
->right
.hwnd
, 0, rt
.left
+cx
+1, rt
.top
, rt
.right
-cx
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
1968 EndDeferWindowPos(hdwp
);
1972 #ifndef _NO_EXTENSIONS
1974 static HWND
create_header(HWND parent
, Pane
* pane
, int id
)
1979 HWND hwnd
= CreateWindow(WC_HEADER
, 0, WS_CHILD
|WS_VISIBLE
|HDS_HORZ
/*TODO: |HDS_BUTTONS + sort orders*/,
1980 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
1984 SetWindowFont(hwnd
, GetStockObject(DEFAULT_GUI_FONT
), FALSE
);
1986 hdi
.mask
= HDI_TEXT
|HDI_WIDTH
|HDI_FORMAT
;
1988 for(idx
=0; idx
<COLUMNS
; idx
++) {
1989 hdi
.pszText
= g_pos_names
[idx
];
1990 hdi
.fmt
= HDF_STRING
| g_pos_align
[idx
];
1991 hdi
.cxy
= pane
->widths
[idx
];
1992 Header_InsertItem(hwnd
, idx
, &hdi
);
1998 #endif // _NO_EXTENSIONS
2001 static void init_output(HWND hwnd
)
2005 HDC hdc
= GetDC(hwnd
);
2007 if (GetNumberFormat(LOCALE_USER_DEFAULT
, 0, TEXT("1000"), 0, b
, 16) > 4)
2008 Globals
.num_sep
= b
[1];
2010 Globals
.num_sep
= TEXT('.');
2012 old_font
= SelectFont(hdc
, Globals
.hfont
);
2013 GetTextExtentPoint32(hdc
, TEXT(" "), 1, &Globals
.spaceSize
);
2014 SelectFont(hdc
, old_font
);
2015 ReleaseDC(hwnd
, hdc
);
2018 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
);
2021 /* calculate prefered width for all visible columns */
2023 static BOOL
calc_widths(Pane
* pane
, BOOL anyway
)
2025 int col
, x
, cx
, spc
=3*Globals
.spaceSize
.cx
;
2026 int entries
= ListBox_GetCount(pane
->hwnd
);
2027 int orgWidths
[COLUMNS
];
2028 int orgPositions
[COLUMNS
+1];
2034 memcpy(orgWidths
, pane
->widths
, sizeof(orgWidths
));
2035 memcpy(orgPositions
, pane
->positions
, sizeof(orgPositions
));
2038 for(col
=0; col
<COLUMNS
; col
++)
2039 pane
->widths
[col
] = 0;
2041 hdc
= GetDC(pane
->hwnd
);
2042 hfontOld
= SelectFont(hdc
, Globals
.hfont
);
2044 for(cnt
=0; cnt
<entries
; cnt
++) {
2045 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, cnt
);
2054 dis
.hwndItem
= pane
->hwnd
;
2056 dis
.rcItem
.left
= 0;
2058 dis
.rcItem
.right
= 0;
2059 dis
.rcItem
.bottom
= 0;
2060 /*dis.itemData = 0; */
2062 draw_item(pane
, &dis
, entry
, COLUMNS
);
2065 SelectObject(hdc
, hfontOld
);
2066 ReleaseDC(pane
->hwnd
, hdc
);
2069 for(col
=0; col
<COLUMNS
; col
++) {
2070 pane
->positions
[col
] = x
;
2071 cx
= pane
->widths
[col
];
2076 if (cx
< IMAGE_WIDTH
)
2079 pane
->widths
[col
] = cx
;
2085 pane
->positions
[COLUMNS
] = x
;
2087 ListBox_SetHorizontalExtent(pane
->hwnd
, x
);
2090 if (!memcmp(orgWidths
, pane
->widths
, sizeof(orgWidths
)))
2093 /* don't move, if only collapsing an entry */
2094 if (!anyway
&& pane
->widths
[0]<orgWidths
[0] &&
2095 !memcmp(orgWidths
+1, pane
->widths
+1, sizeof(orgWidths
)-sizeof(int))) {
2096 pane
->widths
[0] = orgWidths
[0];
2097 memcpy(pane
->positions
, orgPositions
, sizeof(orgPositions
));
2102 InvalidateRect(pane
->hwnd
, 0, TRUE
);
2108 /* calculate one prefered column width */
2110 static void calc_single_width(Pane
* pane
, int col
)
2114 int entries
= ListBox_GetCount(pane
->hwnd
);
2118 pane
->widths
[col
] = 0;
2120 hdc
= GetDC(pane
->hwnd
);
2121 hfontOld
= SelectFont(hdc
, Globals
.hfont
);
2123 for(cnt
=0; cnt
<entries
; cnt
++) {
2124 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, cnt
);
2132 dis
.hwndItem
= pane
->hwnd
;
2134 dis
.rcItem
.left
= 0;
2136 dis
.rcItem
.right
= 0;
2137 dis
.rcItem
.bottom
= 0;
2138 /*dis.itemData = 0; */
2140 draw_item(pane
, &dis
, entry
, col
);
2143 SelectObject(hdc
, hfontOld
);
2144 ReleaseDC(pane
->hwnd
, hdc
);
2146 cx
= pane
->widths
[col
];
2149 cx
+= 3*Globals
.spaceSize
.cx
;
2151 if (cx
< IMAGE_WIDTH
)
2155 pane
->widths
[col
] = cx
;
2157 x
= pane
->positions
[col
] + cx
;
2159 for(; col
<COLUMNS
; ) {
2160 pane
->positions
[++col
] = x
;
2161 x
+= pane
->widths
[col
];
2164 ListBox_SetHorizontalExtent(pane
->hwnd
, x
);
2168 /* insert listbox entries after index idx */
2170 static void insert_entries(Pane
* pane
, Entry
* dir
, int idx
)
2177 ShowWindow(pane
->hwnd
, SW_HIDE
);
2179 for(; entry
; entry
=entry
->next
) {
2181 if (pane
->treePane
&& !(entry
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
2185 /* don't display entries "." and ".." in the left pane */
2186 if (pane
->treePane
&& (entry
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
)
2187 && entry
->data
.cFileName
[0]==TEXT('.'))
2189 #ifndef _NO_EXTENSIONS
2190 entry
->data
.cFileName
[1]==TEXT('\0') ||
2192 (entry
->data
.cFileName
[1]==TEXT('.') && entry
->data
.cFileName
[2]==TEXT('\0')))
2198 ListBox_InsertItemData(pane
->hwnd
, idx
, entry
);
2200 if (pane
->treePane
&& entry
->expanded
)
2201 insert_entries(pane
, entry
->down
, idx
);
2204 ShowWindow(pane
->hwnd
, SW_SHOW
);
2208 static WNDPROC g_orgTreeWndProc
;
2210 static void create_tree_window(HWND parent
, Pane
* pane
, int id
, int id_header
)
2212 static int s_init
= 0;
2213 Entry
* entry
= pane
->root
;
2215 pane
->hwnd
= CreateWindow(TEXT("ListBox"), TEXT(""), WS_CHILD
|WS_VISIBLE
|WS_HSCROLL
|WS_VSCROLL
|
2216 LBS_DISABLENOSCROLL
|LBS_NOINTEGRALHEIGHT
|LBS_OWNERDRAWFIXED
|LBS_NOTIFY
,
2217 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2219 SetWindowLong(pane
->hwnd
, GWL_USERDATA
, (LPARAM
)pane
);
2220 g_orgTreeWndProc
= SubclassWindow(pane
->hwnd
, TreeWndProc
);
2222 SetWindowFont(pane
->hwnd
, Globals
.hfont
, FALSE
);
2224 /* insert entries into listbox */
2226 insert_entries(pane
, entry
, -1);
2228 /* calculate column widths */
2231 init_output(pane
->hwnd
);
2234 calc_widths(pane
, TRUE
);
2236 #ifndef _NO_EXTENSIONS
2237 pane
->hwndHeader
= create_header(parent
, pane
, id_header
);
2242 static void InitChildWindow(ChildWnd
* child
)
2244 create_tree_window(child
->hwnd
, &child
->left
, IDW_TREE_LEFT
, IDW_HEADER_LEFT
);
2245 create_tree_window(child
->hwnd
, &child
->right
, IDW_TREE_RIGHT
, IDW_HEADER_RIGHT
);
2249 static void format_date(const FILETIME
* ft
, TCHAR
* buffer
, int visible_cols
)
2255 *buffer
= TEXT('\0');
2257 if (!ft
->dwLowDateTime
&& !ft
->dwHighDateTime
)
2260 if (!FileTimeToLocalFileTime(ft
, &lft
))
2261 {err
: _tcscpy(buffer
,TEXT("???")); return;}
2263 if (!FileTimeToSystemTime(&lft
, &systime
))
2266 if (visible_cols
& COL_DATE
) {
2267 len
= GetDateFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
, BUFFER_LEN
);
2272 if (visible_cols
& COL_TIME
) {
2274 buffer
[len
-1] = ' ';
2276 buffer
[len
++] = ' ';
2278 if (!GetTimeFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
+len
, BUFFER_LEN
-len
))
2279 buffer
[len
] = TEXT('\0');
2284 static void calc_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2286 RECT rt
= {0, 0, 0, 0};
2288 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
2290 if (rt
.right
> pane
->widths
[col
])
2291 pane
->widths
[col
] = rt
.right
;
2294 static void calc_tabbed_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2296 RECT rt
= {0, 0, 0, 0};
2298 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
2299 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
2301 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
2302 /*FIXME rt (0,0) ??? */
2304 if (rt
.right
> pane
->widths
[col
])
2305 pane
->widths
[col
] = rt
.right
;
2309 static void output_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
, DWORD flags
)
2311 int x
= dis
->rcItem
.left
;
2314 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2315 rt
.top
= dis
->rcItem
.top
;
2316 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2317 rt
.bottom
= dis
->rcItem
.bottom
;
2319 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_SINGLELINE
|DT_NOPREFIX
|flags
);
2322 static void output_tabbed_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2324 int x
= dis
->rcItem
.left
;
2327 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2328 rt
.top
= dis
->rcItem
.top
;
2329 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2330 rt
.bottom
= dis
->rcItem
.bottom
;
2332 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
2333 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
2335 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
2338 static void output_number(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2340 int x
= dis
->rcItem
.left
;
2347 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2348 rt
.top
= dis
->rcItem
.top
;
2349 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2350 rt
.bottom
= dis
->rcItem
.bottom
;
2355 /* insert number separator characters */
2356 pos
= lstrlen(s
) % 3;
2362 *d
++ = Globals
.num_sep
;
2366 DrawText(dis
->hDC
, b
, d
-b
, &rt
, DT_RIGHT
|DT_SINGLELINE
|DT_NOPREFIX
|DT_END_ELLIPSIS
);
2370 static int is_exe_file(LPCTSTR ext
)
2372 static const LPCTSTR executable_extensions
[] = {
2377 #ifndef _NO_EXTENSIONS
2381 #endif // _NO_EXTENSIONS
2385 TCHAR ext_buffer
[_MAX_EXT
];
2390 for(s
=ext
+1,d
=ext_buffer
; (*d
=tolower(*s
)); s
++)
2393 for(p
=executable_extensions
; *p
; p
++)
2394 if (!_tcscmp(ext_buffer
, *p
))
2400 static int is_registered_type(LPCTSTR ext
)
2408 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
)
2410 TCHAR buffer
[BUFFER_LEN
];
2412 int visible_cols
= pane
->visible_cols
;
2413 COLORREF bkcolor
, textcolor
;
2414 RECT focusRect
= dis
->rcItem
;
2421 attrs
= entry
->data
.dwFileAttributes
;
2423 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) {
2424 if (entry
->data
.cFileName
[0]==TEXT('.') && entry
->data
.cFileName
[1]==TEXT('.')
2425 && entry
->data
.cFileName
[2]==TEXT('\0'))
2426 img
= IMG_FOLDER_UP
;
2427 #ifndef _NO_EXTENSIONS
2428 else if (entry
->data
.cFileName
[0]==TEXT('.') && entry
->data
.cFileName
[1]==TEXT('\0'))
2429 img
= IMG_FOLDER_CUR
;
2432 #ifdef _NO_EXTENSIONS
2435 (pane
->treePane
&& (dis
->itemState
&ODS_FOCUS
)))
2436 img
= IMG_OPEN_FOLDER
;
2440 LPCTSTR ext
= _tcsrchr(entry
->data
.cFileName
, '.');
2444 if (is_exe_file(ext
))
2445 img
= IMG_EXECUTABLE
;
2446 else if (is_registered_type(ext
))
2456 if (pane
->treePane
) {
2458 img_pos
= dis
->rcItem
.left
+ entry
->level
*(IMAGE_WIDTH
+Globals
.spaceSize
.cx
);
2460 if (calcWidthCol
== -1) {
2462 int y
= dis
->rcItem
.top
+ IMAGE_HEIGHT
/2;
2465 HRGN hrgn_org
= CreateRectRgn(0, 0, 0, 0);
2468 rt_clip
.left
= dis
->rcItem
.left
;
2469 rt_clip
.top
= dis
->rcItem
.top
;
2470 rt_clip
.right
= dis
->rcItem
.left
+pane
->widths
[col
];
2471 rt_clip
.bottom
= dis
->rcItem
.bottom
;
2473 hrgn
= CreateRectRgnIndirect(&rt_clip
);
2475 if (!GetClipRgn(dis
->hDC
, hrgn_org
)) {
2476 DeleteObject(hrgn_org
);
2480 /* HGDIOBJ holdPen = SelectObject(dis->hDC, GetStockObject(BLACK_PEN)); */
2481 ExtSelectClipRgn(dis
->hDC
, hrgn
, RGN_AND
);
2484 if ((up
=entry
->up
) != NULL
) {
2485 MoveToEx(dis
->hDC
, img_pos
-IMAGE_WIDTH
/2, y
, 0);
2486 LineTo(dis
->hDC
, img_pos
-2, y
);
2488 x
= img_pos
- IMAGE_WIDTH
/2;
2491 x
-= IMAGE_WIDTH
+Globals
.spaceSize
.cx
;
2495 && (up
->next
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
2498 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
2499 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2501 } while((up
=up
->up
) != NULL
);
2504 x
= img_pos
- IMAGE_WIDTH
/2;
2506 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
2507 LineTo(dis
->hDC
, x
, y
);
2511 && (entry
->next
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
)
2514 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2516 if (entry
->down
&& entry
->expanded
) {
2517 x
+= IMAGE_WIDTH
+Globals
.spaceSize
.cx
;
2518 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
+IMAGE_HEIGHT
, 0);
2519 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2522 SelectClipRgn(dis
->hDC
, hrgn_org
);
2523 if (hrgn_org
) DeleteObject(hrgn_org
);
2524 /* SelectObject(dis->hDC, holdPen); */
2525 } else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
) {
2526 int right
= img_pos
+ IMAGE_WIDTH
- Globals
.spaceSize
.cx
;
2528 if (right
> pane
->widths
[col
])
2529 pane
->widths
[col
] = right
;
2532 img_pos
= dis
->rcItem
.left
;
2535 img_pos
= dis
->rcItem
.left
;
2537 if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2538 pane
->widths
[col
] = IMAGE_WIDTH
;
2541 if (calcWidthCol
== -1) {
2542 focusRect
.left
= img_pos
- 2;
2544 #ifdef _NO_EXTENSIONS
2545 if (pane
->treePane
&& entry
) {
2548 DrawText(dis
->hDC
, entry
->data
.cFileName
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
2550 focusRect
.right
= dis
->rcItem
.left
+pane
->positions
[col
+1]+Globals
.spaceSize
.cx
+ rt
.right
+2;
2554 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
)
2555 textcolor
= COLOR_COMPRESSED
;
2557 #endif // _NO_EXTENSIONS
2558 textcolor
= RGB(0,0,0);
2560 if (dis
->itemState
& ODS_FOCUS
) {
2561 textcolor
= RGB(255,255,255);
2562 bkcolor
= COLOR_SELECTION
;
2564 bkcolor
= RGB(255,255,255);
2567 hbrush
= CreateSolidBrush(bkcolor
);
2568 FillRect(dis
->hDC
, &focusRect
, hbrush
);
2569 DeleteObject(hbrush
);
2571 SetBkMode(dis
->hDC
, TRANSPARENT
);
2572 SetTextColor(dis
->hDC
, textcolor
);
2574 cx
= pane
->widths
[col
];
2576 if (cx
&& img
!=IMG_NONE
) {
2577 if (cx
> IMAGE_WIDTH
)
2580 #ifdef _SHELL_FOLDERS
2581 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
2582 DrawIconEx(dis
->hDC
, img_pos
, dis
->rcItem
.top
, entry
->hicon
, cx
, GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
2585 ImageList_DrawEx(Globals
.himl
, img
, dis
->hDC
,
2586 img_pos
, dis
->rcItem
.top
, cx
,
2587 IMAGE_HEIGHT
, bkcolor
, CLR_DEFAULT
, ILD_NORMAL
);
2594 #ifdef _NO_EXTENSIONS
2595 if (img
>= IMG_FOLDER_UP
)
2601 /* ouput file name */
2602 if (calcWidthCol
== -1)
2603 output_text(pane
, dis
, col
, entry
->data
.cFileName
, 0);
2604 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2605 calc_width(pane
, dis
, col
, entry
->data
.cFileName
);
2609 #ifdef _NO_EXTENSIONS
2610 if (!pane
->treePane
) {
2613 /* display file size */
2614 if (visible_cols
& COL_SIZE
) {
2615 #ifdef _NO_EXTENSIONS
2616 if (!(attrs
&FILE_ATTRIBUTE_DIRECTORY
))
2621 size
= ((ULONGLONG
)entry
->data
.nFileSizeHigh
<< 32) | entry
->data
.nFileSizeLow
;
2623 _stprintf(buffer
, TEXT("%") LONGLONGARG
TEXT("d"), size
);
2625 if (calcWidthCol
== -1)
2626 output_number(pane
, dis
, col
, buffer
);
2627 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2628 calc_width(pane
, dis
, col
, buffer
);/*TODO: not in every case time enough */
2634 /* display file date */
2635 if (visible_cols
& (COL_DATE
|COL_TIME
)) {
2636 #ifndef _NO_EXTENSIONS
2637 format_date(&entry
->data
.ftCreationTime
, buffer
, visible_cols
);
2638 if (calcWidthCol
== -1)
2639 output_text(pane
, dis
, col
, buffer
, 0);
2640 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2641 calc_width(pane
, dis
, col
, buffer
);
2644 format_date(&entry
->data
.ftLastAccessTime
, buffer
, visible_cols
);
2645 if (calcWidthCol
== -1)
2646 output_text(pane
, dis
, col
, buffer
, 0);
2647 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2648 calc_width(pane
, dis
, col
, buffer
);
2650 #endif // _NO_EXTENSIONS
2652 format_date(&entry
->data
.ftLastWriteTime
, buffer
, visible_cols
);
2653 if (calcWidthCol
== -1)
2654 output_text(pane
, dis
, col
, buffer
, 0);
2655 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2656 calc_width(pane
, dis
, col
, buffer
);
2660 #ifndef _NO_EXTENSIONS
2661 if (entry
->bhfi_valid
) {
2662 ULONGLONG index
= ((ULONGLONG
)entry
->bhfi
.nFileIndexHigh
<< 32) | entry
->bhfi
.nFileIndexLow
;
2664 if (visible_cols
& COL_INDEX
) {
2665 _stprintf(buffer
, TEXT("%") LONGLONGARG
TEXT("X"), index
);
2666 if (calcWidthCol
== -1)
2667 output_text(pane
, dis
, col
, buffer
, DT_RIGHT
);
2668 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2669 calc_width(pane
, dis
, col
, buffer
);
2673 if (visible_cols
& COL_LINKS
) {
2674 wsprintf(buffer
, TEXT("%d"), entry
->bhfi
.nNumberOfLinks
);
2675 if (calcWidthCol
== -1)
2676 output_text(pane
, dis
, col
, buffer
, DT_CENTER
);
2677 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2678 calc_width(pane
, dis
, col
, buffer
);
2683 #endif // _NO_EXTENSIONS
2685 /* show file attributes */
2686 if (visible_cols
& COL_ATTRIBUTES
) {
2687 #ifdef _NO_EXTENSIONS
2688 _tcscpy(buffer
, TEXT(" \t \t \t \t "));
2690 _tcscpy(buffer
, TEXT(" \t \t \t \t \t \t \t \t \t \t \t "));
2693 if (attrs
& FILE_ATTRIBUTE_NORMAL
) buffer
[ 0] = 'N';
2695 if (attrs
& FILE_ATTRIBUTE_READONLY
) buffer
[ 2] = 'R';
2696 if (attrs
& FILE_ATTRIBUTE_HIDDEN
) buffer
[ 4] = 'H';
2697 if (attrs
& FILE_ATTRIBUTE_SYSTEM
) buffer
[ 6] = 'S';
2698 if (attrs
& FILE_ATTRIBUTE_ARCHIVE
) buffer
[ 8] = 'A';
2699 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
) buffer
[10] = 'C';
2700 #ifndef _NO_EXTENSIONS
2701 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) buffer
[12] = 'D';
2702 if (attrs
& FILE_ATTRIBUTE_ENCRYPTED
) buffer
[14] = 'E';
2703 if (attrs
& FILE_ATTRIBUTE_TEMPORARY
) buffer
[16] = 'T';
2704 if (attrs
& FILE_ATTRIBUTE_SPARSE_FILE
) buffer
[18] = 'P';
2705 if (attrs
& FILE_ATTRIBUTE_REPARSE_POINT
) buffer
[20] = 'Q';
2706 if (attrs
& FILE_ATTRIBUTE_OFFLINE
) buffer
[22] = 'O';
2707 if (attrs
& FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
) buffer
[24] = 'X';
2708 #endif // _NO_EXTENSIONS
2711 if (calcWidthCol
== -1)
2712 output_tabbed_text(pane
, dis
, col
, buffer
);
2713 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2714 calc_tabbed_width(pane
, dis
, col
, buffer
);
2720 if (flags.security) {
2721 DWORD rights = get_access_mask();
2723 tcscpy(buffer, TEXT(" \t \t \t \t \t \t \t \t \t \t \t "));
2725 if (rights & FILE_READ_DATA) buffer[ 0] = 'R';
2726 if (rights & FILE_WRITE_DATA) buffer[ 2] = 'W';
2727 if (rights & FILE_APPEND_DATA) buffer[ 4] = 'A';
2728 if (rights & FILE_READ_EA) {buffer[6] = 'entry'; buffer[ 7] = 'R';}
2729 if (rights & FILE_WRITE_EA) {buffer[9] = 'entry'; buffer[10] = 'W';}
2730 if (rights & FILE_EXECUTE) buffer[12] = 'X';
2731 if (rights & FILE_DELETE_CHILD) buffer[14] = 'D';
2732 if (rights & FILE_READ_ATTRIBUTES) {buffer[16] = 'a'; buffer[17] = 'R';}
2733 if (rights & FILE_WRITE_ATTRIBUTES) {buffer[19] = 'a'; buffer[20] = 'W';}
2734 if (rights & WRITE_DAC) buffer[22] = 'C';
2735 if (rights & WRITE_OWNER) buffer[24] = 'O';
2736 if (rights & SYNCHRONIZE) buffer[26] = 'S';
2738 output_text(dis, col++, buffer, DT_LEFT, 3, psize);
2741 if (flags.description) {
2742 get_description(buffer);
2743 output_text(dis, col++, buffer, 0, psize);
2747 #ifdef _NO_EXTENSIONS
2750 /* draw focus frame */
2751 if ((dis
->itemState
&ODS_FOCUS
) && calcWidthCol
==-1) {
2752 /* Currently [04/2000] Wine neither behaves exactly the same */
2753 /* way as WIN 95 nor like Windows NT... */
2758 if (!(GetVersion() & 0x80000000)) { /* Windows NT? */
2759 LOGBRUSH lb
= {PS_SOLID
, RGB(255,255,255)};
2760 hpen
= ExtCreatePen(PS_COSMETIC
|PS_ALTERNATE
, 1, &lb
, 0, 0);
2762 hpen
= CreatePen(PS_DOT
, 0, RGB(255,255,255));
2764 lastPen
= SelectPen(dis
->hDC
, hpen
);
2765 lastBrush
= SelectObject(dis
->hDC
, GetStockObject(HOLLOW_BRUSH
));
2766 SetROP2(dis
->hDC
, R2_XORPEN
);
2767 Rectangle(dis
->hDC
, focusRect
.left
, focusRect
.top
, focusRect
.right
, focusRect
.bottom
);
2768 SelectObject(dis
->hDC
, lastBrush
);
2769 SelectObject(dis
->hDC
, lastPen
);
2772 #endif // _NO_EXTENSIONS
2776 #ifdef _NO_EXTENSIONS
2778 static void draw_splitbar(HWND hwnd
, int x
)
2781 HDC hdc
= GetDC(hwnd
);
2783 GetClientRect(hwnd
, &rt
);
2785 rt
.left
= x
- SPLIT_WIDTH
/2;
2786 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
2788 InvertRect(hdc
, &rt
);
2790 ReleaseDC(hwnd
, hdc
);
2793 #endif // _NO_EXTENSIONS
2796 #ifndef _NO_EXTENSIONS
2798 static void set_header(Pane
* pane
)
2801 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
2804 item
.mask
= HDI_WIDTH
;
2807 for(; x
+pane
->widths
[i
]<scroll_pos
&& i
<COLUMNS
; i
++) {
2808 x
+= pane
->widths
[i
];
2809 Header_SetItem(pane
->hwndHeader
, i
, &item
);
2813 x
+= pane
->widths
[i
];
2814 item
.cxy
= x
- scroll_pos
;
2815 Header_SetItem(pane
->hwndHeader
, i
++, &item
);
2817 for(; i
<COLUMNS
; i
++) {
2818 item
.cxy
= pane
->widths
[i
];
2819 x
+= pane
->widths
[i
];
2820 Header_SetItem(pane
->hwndHeader
, i
, &item
);
2825 static LRESULT
pane_notify(Pane
* pane
, NMHDR
* pnmh
)
2827 switch(pnmh
->code
) {
2829 case HDN_ENDTRACK
: {
2830 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
2831 int idx
= phdn
->iItem
;
2832 int dx
= phdn
->pitem
->cxy
- pane
->widths
[idx
];
2836 GetClientRect(pane
->hwnd
, &clnt
);
2838 /* move immediate to simulate HDS_FULLDRAG (for now [04/2000] not realy needed with WINELIB) */
2839 Header_SetItem(pane
->hwndHeader
, idx
, phdn
->pitem
);
2841 pane
->widths
[idx
] += dx
;
2843 for(i
=idx
; ++i
<=COLUMNS
; )
2844 pane
->positions
[i
] += dx
;
2847 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
2851 rt_scr
.left
= pane
->positions
[idx
+1]-scroll_pos
;
2853 rt_scr
.right
= clnt
.right
;
2854 rt_scr
.bottom
= clnt
.bottom
;
2856 rt_clip
.left
= pane
->positions
[idx
]-scroll_pos
;
2858 rt_clip
.right
= clnt
.right
;
2859 rt_clip
.bottom
= clnt
.bottom
;
2861 if (rt_scr
.left
< 0) rt_scr
.left
= 0;
2862 if (rt_clip
.left
< 0) rt_clip
.left
= 0;
2864 ScrollWindowEx(pane
->hwnd
, dx
, 0, &rt_scr
, &rt_clip
, 0, 0, SW_INVALIDATE
);
2866 rt_clip
.right
= pane
->positions
[idx
+1];
2867 RedrawWindow(pane
->hwnd
, &rt_clip
, 0, RDW_INVALIDATE
|RDW_UPDATENOW
);
2869 if (pnmh
->code
== HDN_ENDTRACK
) {
2870 ListBox_SetHorizontalExtent(pane
->hwnd
, pane
->positions
[COLUMNS
]);
2872 if (GetScrollPos(pane
->hwnd
, SB_HORZ
) != scroll_pos
)
2880 case HDN_DIVIDERDBLCLICK
: {
2881 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
2884 calc_single_width(pane
, phdn
->iItem
);
2885 item
.mask
= HDI_WIDTH
;
2886 item
.cxy
= pane
->widths
[phdn
->iItem
];
2888 Header_SetItem(pane
->hwndHeader
, phdn
->iItem
, &item
);
2889 InvalidateRect(pane
->hwnd
, 0, TRUE
);
2896 #endif // _NO_EXTENSIONS
2899 static void scan_entry(ChildWnd
* child
, Entry
* entry
, HWND hwnd
)
2901 TCHAR path
[MAX_PATH
];
2902 int idx
= ListBox_GetCurSel(child
->left
.hwnd
);
2903 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
2905 /* delete sub entries in left pane */
2907 LRESULT res
= ListBox_GetItemData(child
->left
.hwnd
, idx
+1);
2908 Entry
* sub
= (Entry
*) res
;
2910 if (res
==LB_ERR
|| !sub
|| sub
->level
<=entry
->level
)
2913 ListBox_DeleteString(child
->left
.hwnd
, idx
+1);
2916 /* empty right pane */
2917 ListBox_ResetContent(child
->right
.hwnd
);
2919 /* release memory */
2920 free_entries(entry
);
2922 /* read contents from disk */
2923 #ifdef _SHELL_FOLDERS
2924 if (entry
->etype
== ET_SHELL
)
2926 read_directory(entry
, NULL
, child
->sortOrder
, hwnd
);
2931 get_path(entry
, path
);
2932 read_directory(entry
, path
, child
->sortOrder
, hwnd
);
2935 /* insert found entries in right pane */
2936 insert_entries(&child
->right
, entry
->down
, -1);
2937 calc_widths(&child
->right
, FALSE
);
2938 #ifndef _NO_EXTENSIONS
2939 set_header(&child
->right
);
2942 child
->header_wdths_ok
= FALSE
;
2944 SetCursor(old_cursor
);
2948 /* expand a directory entry */
2950 static BOOL
expand_entry(ChildWnd
* child
, Entry
* dir
)
2955 if (!dir
|| dir
->expanded
|| !dir
->down
)
2960 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='\0' && p
->next
) {
2963 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='.' &&
2964 p
->data
.cFileName
[2]=='\0' && p
->next
)
2968 /* no subdirectories ? */
2969 if (!(p
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
2972 idx
= ListBox_FindItemData(child
->left
.hwnd
, 0, dir
);
2974 dir
->expanded
= TRUE
;
2976 /* insert entries in left pane */
2977 insert_entries(&child
->left
, p
, idx
);
2979 if (!child
->header_wdths_ok
) {
2980 if (calc_widths(&child
->left
, FALSE
)) {
2981 #ifndef _NO_EXTENSIONS
2982 set_header(&child
->left
);
2985 child
->header_wdths_ok
= TRUE
;
2993 static void collapse_entry(Pane
* pane
, Entry
* dir
)
2995 int idx
= ListBox_FindItemData(pane
->hwnd
, 0, dir
);
2997 ShowWindow(pane
->hwnd
, SW_HIDE
);
2999 /* hide sub entries */
3001 LRESULT res
= ListBox_GetItemData(pane
->hwnd
, idx
+1);
3002 Entry
* sub
= (Entry
*) res
;
3004 if (res
==LB_ERR
|| !sub
|| sub
->level
<=dir
->level
)
3007 ListBox_DeleteString(pane
->hwnd
, idx
+1);
3010 dir
->expanded
= FALSE
;
3012 ShowWindow(pane
->hwnd
, SW_SHOW
);
3016 static void set_curdir(ChildWnd
* child
, Entry
* entry
, HWND hwnd
)
3018 TCHAR path
[MAX_PATH
];
3022 child
->left
.cur
= entry
;
3023 child
->right
.root
= entry
->down
? entry
->down
: entry
;
3024 child
->right
.cur
= entry
;
3026 if (!entry
->scanned
)
3027 scan_entry(child
, entry
, hwnd
);
3029 ListBox_ResetContent(child
->right
.hwnd
);
3030 insert_entries(&child
->right
, entry
->down
, -1);
3031 calc_widths(&child
->right
, FALSE
);
3032 #ifndef _NO_EXTENSIONS
3033 set_header(&child
->right
);
3037 get_path(entry
, path
);
3038 lstrcpy(child
->path
, path
);
3040 if (child
->hwnd
) /* only change window title, if the window already exists */
3041 SetWindowText(child
->hwnd
, path
);
3044 SetCurrentDirectory(path
);
3048 BOOL
launch_file(HWND hwnd
, LPCTSTR cmd
, UINT nCmdShow
)
3050 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, cmd
, NULL
/*parameters*/, NULL
/*dir*/, nCmdShow
);
3052 if ((int)hinst
<= 32) {
3053 display_error(hwnd
, GetLastError());
3061 BOOL
launch_fileA(HWND hwnd
, LPSTR cmd
, UINT nCmdShow
)
3063 HINSTANCE hinst
= ShellExecuteA(hwnd
, NULL
/*operation*/, cmd
, NULL
/*parameters*/, NULL
/*dir*/, nCmdShow
);
3065 if ((int)hinst
<= 32) {
3066 display_error(hwnd
, GetLastError());
3075 BOOL
launch_entry(Entry
* entry
, HWND hwnd
, UINT nCmdShow
)
3077 TCHAR cmd
[MAX_PATH
];
3079 #ifdef _SHELL_FOLDERS
3080 if (entry
->etype
== ET_SHELL
) {
3083 SHELLEXECUTEINFO shexinfo
;
3085 shexinfo
.cbSize
= sizeof(SHELLEXECUTEINFO
);
3086 shexinfo
.fMask
= SEE_MASK_IDLIST
;
3087 shexinfo
.hwnd
= hwnd
;
3088 shexinfo
.lpVerb
= NULL
;
3089 shexinfo
.lpFile
= NULL
;
3090 shexinfo
.lpParameters
= NULL
;
3091 shexinfo
.lpDirectory
= NULL
;
3092 shexinfo
.nShow
= nCmdShow
;
3093 shexinfo
.lpIDList
= get_to_absolute_pidl(entry
, hwnd
);
3095 if (!ShellExecuteEx(&shexinfo
)) {
3096 display_error(hwnd
, GetLastError());
3100 if (shexinfo
.lpIDList
!= entry
->pidl
)
3101 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, shexinfo
.lpIDList
);
3107 get_path(entry
, cmd
);
3109 /* start program, open document... */
3110 return launch_file(hwnd
, cmd
, nCmdShow
);
3114 static void activate_entry(ChildWnd
* child
, Pane
* pane
, HWND hwnd
)
3116 Entry
* entry
= pane
->cur
;
3121 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
3122 int scanned_old
= entry
->scanned
;
3125 scan_entry(child
, entry
, hwnd
);
3127 #ifndef _NO_EXTENSIONS
3128 if (entry
->data
.cFileName
[0]=='.' && entry
->data
.cFileName
[1]=='\0')
3132 if (entry
->data
.cFileName
[0]=='.' && entry
->data
.cFileName
[1]=='.' && entry
->data
.cFileName
[2]=='\0') {
3133 entry
= child
->left
.cur
->up
;
3134 collapse_entry(&child
->left
, entry
);
3136 } else if (entry
->expanded
)
3137 collapse_entry(pane
, child
->left
.cur
);
3139 expand_entry(child
, child
->left
.cur
);
3141 if (!pane
->treePane
) focus_entry
: {
3142 int idx
= ListBox_FindItemData(child
->left
.hwnd
, ListBox_GetCurSel(child
->left
.hwnd
), entry
);
3143 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
3144 set_curdir(child
, entry
, hwnd
);
3149 calc_widths(pane
, FALSE
);
3151 #ifndef _NO_EXTENSIONS
3156 launch_entry(entry
, child
->hwnd
, SW_SHOWNORMAL
);
3161 static BOOL
pane_command(Pane
* pane
, UINT cmd
)
3165 if (pane
->visible_cols
) {
3166 pane
->visible_cols
= 0;
3167 calc_widths(pane
, TRUE
);
3168 #ifndef _NO_EXTENSIONS
3171 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3172 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
|MF_CHECKED
);
3173 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_ALL_ATTRIBUTES
, MF_BYCOMMAND
);
3174 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SELECTED_ATTRIBUTES
, MF_BYCOMMAND
);
3178 case ID_VIEW_ALL_ATTRIBUTES
:
3179 if (pane
->visible_cols
!= COL_ALL
) {
3180 pane
->visible_cols
= COL_ALL
;
3181 calc_widths(pane
, TRUE
);
3182 #ifndef _NO_EXTENSIONS
3185 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3186 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
);
3187 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_ALL_ATTRIBUTES
, MF_BYCOMMAND
|MF_CHECKED
);
3188 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_SELECTED_ATTRIBUTES
, MF_BYCOMMAND
);
3192 #ifndef _NO_EXTENSIONS
3193 case ID_PREFERED_SIZES
: {
3194 calc_widths(pane
, TRUE
);
3196 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3200 /* TODO: more command ids... */
3210 static HRESULT
ShellFolderContextMenu(IShellFolder
* shell_folder
, HWND hwndParent
, int cidl
, LPCITEMIDLIST
* apidl
, int x
, int y
)
3214 HRESULT hr
= (*shell_folder
->lpVtbl
->GetUIObjectOf
)(shell_folder
, hwndParent
, cidl
, apidl
, &IID_IContextMenu
, NULL
, (LPVOID
*)&pcm
);
3215 // HRESULT hr = CDefFolderMenu_Create2(dir?dir->_pidl:DesktopFolder(), hwndParent, 1, &pidl, shell_folder, NULL, 0, NULL, &pcm);
3217 if (SUCCEEDED(hr
)) {
3218 HMENU hmenu
= CreatePopupMenu();
3221 hr
= (*pcm
->lpVtbl
->QueryContextMenu
)(pcm
, hmenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, CMF_NORMAL
);
3223 if (SUCCEEDED(hr
)) {
3224 UINT idCmd
= TrackPopupMenu(hmenu
, TPM_LEFTALIGN
|TPM_RETURNCMD
|TPM_RIGHTBUTTON
, x
, y
, 0, hwndParent
, NULL
);
3227 CMINVOKECOMMANDINFO cmi
;
3229 cmi
.cbSize
= sizeof(CMINVOKECOMMANDINFO
);
3231 cmi
.hwnd
= hwndParent
;
3232 cmi
.lpVerb
= (LPCSTR
)(INT_PTR
)(idCmd
- FCIDM_SHVIEWFIRST
);
3233 cmi
.lpParameters
= NULL
;
3234 cmi
.lpDirectory
= NULL
;
3235 cmi
.nShow
= SW_SHOWNORMAL
;
3239 hr
= (*pcm
->lpVtbl
->InvokeCommand
)(pcm
, &cmi
);
3244 (*pcm
->lpVtbl
->Release
)(pcm
);
3251 LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
3253 static int last_split
;
3255 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(hwnd
, GWL_USERDATA
);
3260 LPDRAWITEMSTRUCT dis
= (LPDRAWITEMSTRUCT
)lparam
;
3261 Entry
* entry
= (Entry
*) dis
->itemData
;
3263 if (dis
->CtlID
== IDW_TREE_LEFT
)
3264 draw_item(&child
->left
, dis
, entry
, -1);
3266 draw_item(&child
->right
, dis
, entry
, -1);
3271 InitChildWindow(child
);
3275 free_child_window(child
);
3276 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
3283 GetClientRect(hwnd
, &rt
);
3284 BeginPaint(hwnd
, &ps
);
3285 rt
.left
= child
->split_pos
-SPLIT_WIDTH
/2;
3286 rt
.right
= child
->split_pos
+SPLIT_WIDTH
/2+1;
3287 lastBrush
= SelectBrush(ps
.hdc
, (HBRUSH
)GetStockObject(COLOR_SPLITBAR
));
3288 Rectangle(ps
.hdc
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
3289 SelectObject(ps
.hdc
, lastBrush
);
3290 #ifdef _NO_EXTENSIONS
3291 rt
.top
= rt
.bottom
- GetSystemMetrics(SM_CYHSCROLL
);
3292 FillRect(ps
.hdc
, &rt
, GetStockObject(BLACK_BRUSH
));
3294 EndPaint(hwnd
, &ps
);
3298 if (LOWORD(lparam
) == HTCLIENT
) {
3301 ScreenToClient(hwnd
, &pt
);
3303 if (pt
.x
>=child
->split_pos
-SPLIT_WIDTH
/2 && pt
.x
<child
->split_pos
+SPLIT_WIDTH
/2+1) {
3304 SetCursor(LoadCursor(0, IDC_SIZEWE
));
3310 case WM_LBUTTONDOWN
: {
3312 int x
= GET_X_LPARAM(lparam
);
3314 GetClientRect(hwnd
, &rt
);
3316 if (x
>=child
->split_pos
-SPLIT_WIDTH
/2 && x
<child
->split_pos
+SPLIT_WIDTH
/2+1) {
3317 last_split
= child
->split_pos
;
3318 #ifdef _NO_EXTENSIONS
3319 draw_splitbar(hwnd
, last_split
);
3327 if (GetCapture() == hwnd
) {
3328 #ifdef _NO_EXTENSIONS
3330 int x
= LOWORD(lparam
);
3331 draw_splitbar(hwnd
, last_split
);
3333 GetClientRect(hwnd
, &rt
);
3334 child
->split_pos
= x
;
3335 resize_tree(child
, rt
.right
, rt
.bottom
);
3341 #ifdef _NO_EXTENSIONS
3342 case WM_CAPTURECHANGED
:
3343 if (GetCapture()==hwnd
&& last_split
>=0)
3344 draw_splitbar(hwnd
, last_split
);
3349 if (wparam
== VK_ESCAPE
)
3350 if (GetCapture() == hwnd
) {
3352 #ifdef _NO_EXTENSIONS
3353 draw_splitbar(hwnd
, last_split
);
3355 child
->split_pos
= last_split
;
3357 GetClientRect(hwnd
, &rt
);
3358 resize_tree(child
, rt
.right
, rt
.bottom
);
3361 SetCursor(LoadCursor(0, IDC_ARROW
));
3366 if (GetCapture() == hwnd
) {
3368 int x
= LOWORD(lparam
);
3370 #ifdef _NO_EXTENSIONS
3371 HDC hdc
= GetDC(hwnd
);
3372 GetClientRect(hwnd
, &rt
);
3374 rt
.left
= last_split
-SPLIT_WIDTH
/2;
3375 rt
.right
= last_split
+SPLIT_WIDTH
/2+1;
3376 InvertRect(hdc
, &rt
);
3379 rt
.left
= x
-SPLIT_WIDTH
/2;
3380 rt
.right
= x
+SPLIT_WIDTH
/2+1;
3381 InvertRect(hdc
, &rt
);
3383 ReleaseDC(hwnd
, hdc
);
3385 GetClientRect(hwnd
, &rt
);
3387 if (x
>=0 && x
<rt
.right
) {
3388 child
->split_pos
= x
;
3389 resize_tree(child
, rt
.right
, rt
.bottom
);
3390 rt
.left
= x
-SPLIT_WIDTH
/2;
3391 rt
.right
= x
+SPLIT_WIDTH
/2+1;
3392 InvalidateRect(hwnd
, &rt
, FALSE
);
3393 UpdateWindow(child
->left
.hwnd
);
3395 UpdateWindow(child
->right
.hwnd
);
3401 #ifndef _NO_EXTENSIONS
3402 case WM_GETMINMAXINFO
:
3403 DefMDIChildProc(hwnd
, nmsg
, wparam
, lparam
);
3405 {LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
3407 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
3408 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
3410 #endif // _NO_EXTENSIONS
3413 SetCurrentDirectory(child
->path
);
3414 SetFocus(child
->focus_pane
? child
->right
.hwnd
: child
->left
.hwnd
);
3417 case WM_DISPATCH_COMMAND
: {
3418 Pane
* pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
3420 switch(LOWORD(wparam
)) {
3421 case ID_WINDOW_NEW
: {
3422 ChildWnd
* new_child
= alloc_child_window(child
->path
, NULL
, hwnd
);
3424 if (!create_child_window(new_child
))
3430 scan_entry(child
, pane
->cur
, hwnd
);
3434 activate_entry(child
, pane
, hwnd
);
3438 return pane_command(pane
, LOWORD(wparam
));
3444 Pane
* pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
3446 switch(HIWORD(wparam
)) {
3447 case LBN_SELCHANGE
: {
3448 int idx
= ListBox_GetCurSel(pane
->hwnd
);
3449 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, idx
);
3451 if (pane
== &child
->left
)
3452 set_curdir(child
, entry
, hwnd
);
3458 activate_entry(child
, pane
, hwnd
);
3463 #ifndef _NO_EXTENSIONS
3465 NMHDR
* pnmh
= (NMHDR
*) lparam
;
3466 return pane_notify(pnmh
->idFrom
==IDW_HEADER_LEFT
? &child
->left
: &child
->right
, pnmh
);}
3469 #ifdef _SHELL_FOLDERS
3470 case WM_CONTEXTMENU
: {
3474 // first select the current item in the listbox
3475 HWND hpanel
= (HWND
) wparam
;
3476 POINTS
* ppos
= &MAKEPOINTS(lparam
);
3477 POINT pt
; POINTSTOPOINT(pt
, *ppos
);
3478 ScreenToClient(hpanel
, &pt
);
3479 SendMessage(hpanel
, WM_LBUTTONDOWN
, 0, MAKELONG(pt
.x
, pt
.y
));
3480 SendMessage(hpanel
, WM_LBUTTONUP
, 0, MAKELONG(pt
.x
, pt
.y
));
3482 // now create the popup menu using shell namespace and IContextMenu
3483 pane
= GetFocus()==child
->left
.hwnd
? &child
->left
: &child
->right
;
3484 idx
= ListBox_GetCurSel(pane
->hwnd
);
3488 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, idx
);
3490 LPITEMIDLIST pidl_abs
= get_to_absolute_pidl(entry
, hwnd
);
3493 IShellFolder
* parentFolder
;
3494 LPCITEMIDLIST pidlLast
;
3496 // get and use the parent folder to display correct context menu in all cases
3497 if (SUCCEEDED(SHBindToParent(pidl_abs
, &IID_IShellFolder
, (LPVOID
*)&parentFolder
, &pidlLast
))) {
3498 hr
= ShellFolderContextMenu(parentFolder
, hwnd
, 1, &pidlLast
, ppos
->x
, ppos
->y
);
3500 (*parentFolder
->lpVtbl
->Release
)(parentFolder
);
3503 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, pidl_abs
);
3510 if (wparam
!= SIZE_MINIMIZED
)
3511 resize_tree(child
, LOWORD(lparam
), HIWORD(lparam
));
3515 return DefMDIChildProc(hwnd
, nmsg
, wparam
, lparam
);
3522 LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
3524 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(GetParent(hwnd
), GWL_USERDATA
);
3525 Pane
* pane
= (Pane
*) GetWindowLong(hwnd
, GWL_USERDATA
);
3529 #ifndef _NO_EXTENSIONS
3536 child
->focus_pane
= pane
==&child
->right
? 1: 0;
3537 ListBox_SetSel(hwnd
, TRUE
, 1);
3538 /*TODO: check menu items */
3542 if (wparam
== VK_TAB
) {
3543 /*TODO: SetFocus(Globals.hdrivebar) */
3544 SetFocus(child
->focus_pane
? child
->left
.hwnd
: child
->right
.hwnd
);
3548 return CallWindowProc(g_orgTreeWndProc
, hwnd
, nmsg
, wparam
, lparam
);
3552 static void InitInstance(HINSTANCE hinstance
)
3558 INITCOMMONCONTROLSEX icc
= {
3559 sizeof(INITCOMMONCONTROLSEX
),
3565 setlocale(LC_COLLATE
, ""); // set collating rules to local settings for compareName
3567 InitCommonControlsEx(&icc
);
3570 /* register frame window class */
3572 wcFrame
.cbSize
= sizeof(WNDCLASSEX
);
3574 wcFrame
.lpfnWndProc
= FrameWndProc
;
3575 wcFrame
.cbClsExtra
= 0;
3576 wcFrame
.cbWndExtra
= 0;
3577 wcFrame
.hInstance
= hinstance
;
3578 wcFrame
.hIcon
= LoadIcon(hinstance
, MAKEINTRESOURCE(IDI_WINEFILE
));
3579 wcFrame
.hCursor
= LoadCursor(0, IDC_ARROW
);
3580 wcFrame
.hbrBackground
= 0;
3581 wcFrame
.lpszMenuName
= 0;
3582 wcFrame
.lpszClassName
= WINEFILEFRAME
;
3583 wcFrame
.hIconSm
= (HICON
)LoadImage(hinstance
,
3584 MAKEINTRESOURCE(IDI_WINEFILE
),
3586 GetSystemMetrics(SM_CXSMICON
),
3587 GetSystemMetrics(SM_CYSMICON
),
3590 Globals
.hframeClass
= RegisterClassEx(&wcFrame
);
3593 /* register tree windows class */
3595 wcChild
.style
= CS_CLASSDC
|CS_DBLCLKS
|CS_VREDRAW
;
3596 wcChild
.lpfnWndProc
= ChildWndProc
;
3597 wcChild
.cbClsExtra
= 0;
3598 wcChild
.cbWndExtra
= 0;
3599 wcChild
.hInstance
= hinstance
;
3601 wcChild
.hCursor
= LoadCursor(0, IDC_ARROW
);
3602 wcChild
.hbrBackground
= 0;
3603 wcChild
.lpszMenuName
= 0;
3604 wcChild
.lpszClassName
= WINEFILETREE
;
3606 hChildClass
= RegisterClass(&wcChild
);
3609 Globals
.haccel
= LoadAccelerators(hinstance
, MAKEINTRESOURCE(IDA_WINEFILE
));
3611 Globals
.hfont
= CreateFont(-MulDiv(8,GetDeviceCaps(hdc
,LOGPIXELSY
),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("MS Sans Serif"));
3615 Globals
.hInstance
= hinstance
;
3617 #ifdef _SHELL_FOLDERS
3619 CoGetMalloc(MEMCTX_TASK
, &Globals
.iMalloc
);
3620 SHGetDesktopFolder(&Globals
.iDesktop
);
3621 Globals
.cfStrFName
= RegisterClipboardFormat(CFSTR_FILENAME
);
3626 void show_frame(HWND hwndParent
, int cmdshow
)
3628 TCHAR path
[MAX_PATH
];
3630 HMENU hMenuFrame
, hMenuWindow
;
3632 CLIENTCREATESTRUCT ccs
;
3634 if (Globals
.hMainWnd
)
3637 Globals
.hwndParent
= hwndParent
;
3639 hMenuFrame
= LoadMenu(Globals
.hInstance
, MAKEINTRESOURCE(IDM_WINEFILE
));
3640 hMenuWindow
= GetSubMenu(hMenuFrame
, GetMenuItemCount(hMenuFrame
)-2);
3642 Globals
.hMenuFrame
= hMenuFrame
;
3643 Globals
.hMenuView
= GetSubMenu(hMenuFrame
, 3);
3644 Globals
.hMenuOptions
= GetSubMenu(hMenuFrame
, 4);
3646 ccs
.hWindowMenu
= hMenuWindow
;
3647 ccs
.idFirstChild
= IDW_FIRST_CHILD
;
3650 /* create main window */
3651 Globals
.hMainWnd
= CreateWindowEx(0, (LPCTSTR
)(int)Globals
.hframeClass
, TEXT("Wine File"), WS_OVERLAPPEDWINDOW
,
3652 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
3653 hwndParent
, Globals
.hMenuFrame
, Globals
.hInstance
, 0/*lpParam*/);
3656 Globals
.hmdiclient
= CreateWindowEx(0, TEXT("MDICLIENT"), NULL
,
3657 WS_CHILD
|WS_CLIPCHILDREN
|WS_VSCROLL
|WS_HSCROLL
|WS_VISIBLE
|WS_BORDER
,
3659 Globals
.hMainWnd
, 0, Globals
.hInstance
, &ccs
);
3663 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
3667 Globals
.hdrivebar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
3668 IDW_DRIVEBAR
, 2, Globals
.hInstance
, IDB_DRIVEBAR
, &drivebarBtn
,
3669 1, 16, 13, 16, 13, sizeof(TBBUTTON
));
3670 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_DRIVE_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
3672 GetLogicalDriveStrings(BUFFER_LEN
, Globals
.drives
);
3674 drivebarBtn
.fsStyle
= BTNS_BUTTON
;
3676 #ifndef _NO_EXTENSIONS
3678 /* insert unix file system button */
3679 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("/\0"));
3681 drivebarBtn
.idCommand
= ID_DRIVE_UNIX_FS
;
3682 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3683 drivebarBtn
.iString
++;
3685 #ifdef _SHELL_FOLDERS
3686 /* insert shell namespace button */
3687 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Shell\0"));
3689 drivebarBtn
.idCommand
= ID_DRIVE_SHELL_NS
;
3690 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3691 drivebarBtn
.iString
++;
3694 /* register windows drive root strings */
3695 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)Globals
.drives
);
3698 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
3700 for(p
=Globals
.drives
; *p
; ) {
3701 #ifdef _NO_EXTENSIONS
3702 /* insert drive letter */
3703 TCHAR b
[3] = {tolower(*p
)};
3704 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b
);
3706 switch(GetDriveType(p
)) {
3707 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
3708 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
3709 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
3710 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
3711 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
3714 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3715 drivebarBtn
.idCommand
++;
3716 drivebarBtn
.iString
++;
3723 TBBUTTON toolbarBtns
[] = {
3724 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
3725 {0, ID_WINDOW_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
3726 {1, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
3727 {2, ID_WINDOW_TILE_HORZ
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
3728 {3, ID_WINDOW_TILE_VERT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
3730 {4, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
3731 {5, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
3734 Globals
.htoolbar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
,
3735 IDW_TOOLBAR
, 2, Globals
.hInstance
, IDB_TOOLBAR
, toolbarBtns
,
3736 sizeof(toolbarBtns
)/sizeof(TBBUTTON
), 16, 15, 16, 15, sizeof(TBBUTTON
));
3737 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_TOOL_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
3740 Globals
.hstatusbar
= CreateStatusWindow(WS_CHILD
|WS_VISIBLE
, 0, Globals
.hMainWnd
, IDW_STATUSBAR
);
3741 CheckMenuItem(Globals
.hMenuOptions
, ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
3743 /* CreateStatusWindow does not accept WS_BORDER
3744 Globals.hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
3745 WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
3746 Globals.hMainWnd, (HMENU)IDW_STATUSBAR, hinstance, 0);*/
3748 /*TODO: read paths and window placements from registry */
3749 GetCurrentDirectory(MAX_PATH
, path
);
3751 ShowWindow(Globals
.hMainWnd
, cmdshow
);
3753 //#if defined(_SHELL_FOLDERS) && !defined(__WINE__)
3754 // // Shell Namespace as default:
3755 // child = alloc_child_window(path, get_path_pidl(path,Globals.hMainWnd), Globals.hMainWnd);
3757 child
= alloc_child_window(path
, NULL
, Globals
.hMainWnd
);
3760 child
->pos
.showCmd
= SW_SHOWMAXIMIZED
;
3761 child
->pos
.rcNormalPosition
.left
= 0;
3762 child
->pos
.rcNormalPosition
.top
= 0;
3763 child
->pos
.rcNormalPosition
.right
= 320;
3764 child
->pos
.rcNormalPosition
.bottom
= 280;
3766 if (!create_child_window(child
))
3769 SetWindowPlacement(child
->hwnd
, &child
->pos
);
3771 Globals
.himl
= ImageList_LoadBitmap(Globals
.hInstance
, MAKEINTRESOURCE(IDB_IMAGES
), 16, 0, RGB(0,255,0));
3773 Globals
.prescan_node
= FALSE
;
3775 UpdateWindow(Globals
.hMainWnd
);
3780 #ifdef _SHELL_FOLDERS
3781 (*Globals
.iDesktop
->lpVtbl
->Release
)(Globals
.iDesktop
);
3782 (*Globals
.iMalloc
->lpVtbl
->Release
)(Globals
.iMalloc
);
3786 ImageList_Destroy(Globals
.himl
);
3790 /* search for already running win[e]files */
3792 static int g_foundPrevInstance
= 0;
3794 static BOOL CALLBACK
EnumWndProc(HWND hwnd
, LPARAM lparam
)
3798 GetClassName(hwnd
, cls
, 128);
3800 if (!lstrcmp(cls
, (LPCTSTR
)lparam
)) {
3801 g_foundPrevInstance
++;
3808 /* search for window of given class name to allow only one running instance */
3809 int find_window_class(LPCTSTR classname
)
3811 EnumWindows(EnumWndProc
, (LPARAM
)classname
);
3813 if (g_foundPrevInstance
)
3820 int winefile_main(HINSTANCE hinstance
, HWND hwndParent
, int cmdshow
)
3824 InitInstance(hinstance
);
3826 #ifndef _ROS_ // don't maximize if being called from the ROS desktop
3827 if (cmdshow
== SW_SHOWNORMAL
)
3828 /*TODO: read window placement from registry */
3829 cmdshow
= SW_MAXIMIZE
;
3832 show_frame(hwndParent
, cmdshow
);
3834 while(GetMessage(&msg
, 0, 0, 0)) {
3835 if (Globals
.hmdiclient
&& TranslateMDISysAccel(Globals
.hmdiclient
, &msg
))
3838 if (Globals
.hMainWnd
&& TranslateAccelerator(Globals
.hMainWnd
, Globals
.haccel
, &msg
))
3841 TranslateMessage(&msg
);
3842 DispatchMessage(&msg
);
3851 int APIENTRY
WinMain(HINSTANCE hinstance
,
3852 HINSTANCE previnstance
,
3856 #ifdef _NO_EXTENSIONS
3857 if (find_window_class(WINEFILEFRAME
))
3861 winefile_main(hinstance
, 0, cmdshow
);