From aa405ed6f1d7a040cfad4c3596fcd02441646b05 Mon Sep 17 00:00:00 2001 From: Robert Dickenson Date: Sun, 4 Aug 2002 18:40:49 +0000 Subject: [PATCH] Added combobox to drivebar, yet to get working. Whole application needs alot of cleanup. Fixed up makefile plus dependancies and now builds (and runs) with ros-tools. svn path=/trunk/; revision=3315 --- rosapps/winfile/Makefile | 25 +++--- rosapps/winfile/drivebar.c | 162 +++++++++++++++++++++++++++++++++++++ rosapps/winfile/drivebar.h | 38 +++++++++ rosapps/winfile/entries.c | 2 +- rosapps/winfile/framewnd.c | 4 +- rosapps/winfile/main.c | 21 +++-- rosapps/winfile/network.c | 2 +- rosapps/winfile/network.h | 2 +- rosapps/winfile/run.c | 19 +++++ rosapps/winfile/run.h | 17 ---- rosapps/winfile/settings.c | 8 +- rosapps/winfile/shell.c | 2 +- rosapps/winfile/shell.h | 2 +- rosapps/winfile/trace.c | 2 - rosapps/winfile/treeview.c | 4 +- rosapps/winfile/worker.c | 2 +- 16 files changed, 261 insertions(+), 51 deletions(-) create mode 100644 rosapps/winfile/drivebar.c create mode 100644 rosapps/winfile/drivebar.h diff --git a/rosapps/winfile/Makefile b/rosapps/winfile/Makefile index f7e0c231bd5..6a729a2603e 100644 --- a/rosapps/winfile/Makefile +++ b/rosapps/winfile/Makefile @@ -24,10 +24,9 @@ PATH_TO_TOP = .. TARGET = winfile -BASE_CFLAGS = -DGCC -D_WIN32_IE=0x0400 - -RCFLAGS = -DGCC -D_WIN32_IE=0x0400 +BASE_CFLAGS = -D_WIN32_IE=0x0400 +RCFLAGS = -D_WIN32_IE=0x0400 OBJS = about.o \ childwnd.o \ @@ -61,23 +60,25 @@ $(TARGET).exe: $(OBJS) $(TARGET).coff $(NM) --numeric-sort $(TARGET).exe > $(TARGET).sym -about.o: about.c about.h resource.h +main.h: resource.h makefile -main.o: main.c main.h childwnd.h framewnd.h resource.h +about.o: about.c about.h main.h -childwnd.o: childwnd.c childwnd.h resource.h +main.o: main.c main.h childwnd.h framewnd.h main.h -framewnd.o: framewnd.c framewnd.h resource.h +childwnd.o: childwnd.c childwnd.h main.h -debug.o: debug.c debug.h +framewnd.o: framewnd.c framewnd.h main.h -font.o: font.c font.h +debug.o: debug.c debug.h main.h -run.o: run.c run.h +font.o: font.c font.h main.h -setttings.o: setttings.c setttings.h resource.h +run.o: run.c run.h main.h -$(TARGET).o: $(TARGET).c $(TARGET).h resource.h +setttings.o: setttings.c setttings.h main.h + +$(TARGET).o: $(TARGET).c $(TARGET).h main.h makefile clean: diff --git a/rosapps/winfile/drivebar.c b/rosapps/winfile/drivebar.c new file mode 100644 index 00000000000..feeb090df45 --- /dev/null +++ b/rosapps/winfile/drivebar.c @@ -0,0 +1,162 @@ +/* + * ReactOS winfile + * + * drivebar.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include "main.h" +#include "settings.h" +#include "framewnd.h" +#include "childwnd.h" + + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// + +void ConfigureDriveBar(HWND hDriveBar) +{ + static DWORD dwLogicalDrivesSaved; + DWORD dwLogicalDrives = GetLogicalDrives(); + + if (!hDriveBar) return; + + if (dwLogicalDrives != dwLogicalDrivesSaved) { + TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP}; + int btn = 1; + PTSTR p; + int count = SendMessage(hDriveBar, TB_BUTTONCOUNT, 0, 0); + while (count) { + SendMessage(hDriveBar, TB_DELETEBUTTON, (WPARAM)--count, 0); + } + count = SendMessage(Globals.hDriveCombo, CB_GETCOUNT, 0, 0); + while (count) { +// SendMessage(Globals.hDriveCombo, CB_DELETESTRING, (WPARAM)--count, 0); + } + SendMessage(Globals.hDriveCombo, CB_RESETCONTENT, 0, 0); + + memset(Globals.drives, 0, BUFFER_LEN); + GetLogicalDriveStrings(BUFFER_LEN, Globals.drives); + drivebarBtn.fsStyle = TBSTYLE_BUTTON; + drivebarBtn.idCommand = ID_DRIVE_FIRST; + for (p = Globals.drives; *p;) { + // insert drive letter + TCHAR b[3] = { tolower(*p) }; + SendMessage(hDriveBar, TB_ADDSTRING, 0, (LPARAM)b); + switch(GetDriveType(p)) { + case DRIVE_REMOVABLE: drivebarBtn.iBitmap = 1; break; + case DRIVE_CDROM: drivebarBtn.iBitmap = 3; break; + case DRIVE_REMOTE: drivebarBtn.iBitmap = 4; break; + case DRIVE_RAMDISK: drivebarBtn.iBitmap = 5; break; + default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2; + } + SendMessage(hDriveBar, TB_INSERTBUTTON, btn, (LPARAM)&drivebarBtn); + drivebarBtn.idCommand++; + drivebarBtn.iString++; + while(*p++); +// +// SendMessage(Globals.hDriveCombo, CB_INSERTSTRING, btn, (LPARAM)b); +// SendMessage(Globals.hDriveCombo, CB_ADDSTRING, 0, (LPARAM)b); +// SendMessage(Globals.hDriveCombo, WM_SETTEXT, 0, (LPARAM)lpszWord); +// SendMessage(Globals.hDriveCombo, CB_ADDSTRING, 0, (LPARAM)&b); +// + ++btn; + } + dwLogicalDrivesSaved = dwLogicalDrives; + +// SendMessage(Globals.hDriveCombo, CB_SHOWDROPDOWN, (WPARAM)TRUE, (LPARAM)0); + } +#ifndef __GNUC__ + + { + COMBOBOXEXITEM cbei; + int iCnt; + + typedef struct { + int iImage; + int iSelectedImage; + int iIndent; + LPTSTR pszText; + } ITEMINFO, *PITEMINFO; + +#define MAX_ITEMS 15 + + ITEMINFO IInf[] = { + { 0, 3, 0, _T("first")}, + { 1, 4, 1, _T("second")}, + { 2, 5, 2, _T("third")}, + { 0, 3, 0, _T("fourth")}, + { 1, 4, 1, _T("fifth")}, + { 2, 5, 2, _T("sixth")}, + { 0, 3, 0, _T("seventh")}, + { 1, 4, 1, _T("eighth")}, + { 2, 5, 2, _T("ninth")}, + { 0, 3, 0, _T("tenth")}, + { 1, 4, 1, _T("eleventh")}, + { 2, 5, 2, _T("twelfth")}, + { 0, 3, 0, _T("thirteenth")}, + { 1, 4, 1, _T("fourteenth")}, + { 2, 5, 2, _T("fifteenth")} + }; + + for (iCnt = 0; iCnt < MAX_ITEMS; iCnt++) { + + cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE; + cbei.iItem = iCnt; + cbei.pszText = IInf[iCnt].pszText; + cbei.cchTextMax = sizeof(IInf[iCnt].pszText); + cbei.iImage = IInf[iCnt].iImage; + cbei.iSelectedImage = IInf[iCnt].iSelectedImage; + cbei.iIndent = IInf[iCnt].iIndent; + } + + + SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei); + } +#endif +} + +void _GetFreeSpaceEx(void) +{ + BOOL fResult; + TCHAR szDrive[MAX_PATH]; + ULARGE_INTEGER i64FreeBytesToCaller; + ULARGE_INTEGER i64TotalBytes; + ULARGE_INTEGER i64FreeBytes; + + fResult = GetDiskFreeSpaceEx(szDrive, + (PULARGE_INTEGER)&i64FreeBytesToCaller, + (PULARGE_INTEGER)&i64TotalBytes, + (PULARGE_INTEGER)&i64FreeBytes); +} + diff --git a/rosapps/winfile/drivebar.h b/rosapps/winfile/drivebar.h new file mode 100644 index 00000000000..3f70a240e57 --- /dev/null +++ b/rosapps/winfile/drivebar.h @@ -0,0 +1,38 @@ +/* + * ReactOS Application Drivebar support routines + * + * drivebar.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __DRIVEBAR_H__ +#define __DRIVEBAR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +void ConfigureDriveBar(HWND hDriveBar); + + +#ifdef __cplusplus +}; +#endif + +#endif // __DRIVEBAR_H__ diff --git a/rosapps/winfile/entries.c b/rosapps/winfile/entries.c index 4e105a313e1..35fd20d40cd 100644 --- a/rosapps/winfile/entries.c +++ b/rosapps/winfile/entries.c @@ -254,7 +254,7 @@ void scan_entry(ChildWnd* child, Entry* entry) // expand a directory entry BOOL expand_entry(ChildWnd* child, Entry* dir) { - int idx; + int idx = 0; Entry* p; if (!dir || dir->expanded || !dir->down) diff --git a/rosapps/winfile/framewnd.c b/rosapps/winfile/framewnd.c index 943ee025cdf..f91ea135b9e 100644 --- a/rosapps/winfile/framewnd.c +++ b/rosapps/winfile/framewnd.c @@ -598,7 +598,7 @@ static LPTBBUTTON lpSaveButtons; if (lpnmhdr->code == TBN_GETBUTTONINFO) { LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam; - char szBuffer[20]; + TCHAR szBuffer[20]; // int tbButtonNew[20] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 }; TBBUTTON tbButtonNew[] = { @@ -632,7 +632,7 @@ static LPTBBUTTON lpSaveButtons; case TBN_GETBUTTONINFO: { LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam; - char szBuffer[20]; + TCHAR szBuffer[20]; /* typedef struct _TBBUTTON { int iBitmap; diff --git a/rosapps/winfile/main.c b/rosapps/winfile/main.c index 64ef332e76c..873c7008a3d 100644 --- a/rosapps/winfile/main.c +++ b/rosapps/winfile/main.c @@ -170,16 +170,25 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { #define DRIVEBOX_WIDTH 200 #define DRIVEBOX_HEIGHT 8 - +/* +typedef struct _TBBUTTON { + int iBitmap; + int idCommand; + BYTE fsState; + BYTE fsStyle; + DWORD dwData; + INT_PTR iString; +} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON; + */ TBBUTTON toolbarBtns[] = { {DRIVEBOX_WIDTH+10, 0, 0, TBSTYLE_SEP}, {0, 0, 0, TBSTYLE_SEP}, // {1, ID_FILE_OPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_OPEN }, - {2, ID_FILE_MOVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_MOVE}, - {3, ID_FILE_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY}, - {4, ID_FILE_COPY_CLIPBOARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY_CLIPBOARD}, - {5, ID_FILE_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_DELETE}, +// {2, ID_FILE_MOVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_MOVE}, +// {3, ID_FILE_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY}, +// {4, ID_FILE_COPY_CLIPBOARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY_CLIPBOARD}, + {5, ID_FILE_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {6, ID_FILE_RENAME, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {7, ID_FILE_PROPERTIES, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {8, ID_FILE_COMPRESS, TBSTATE_ENABLED, TBSTYLE_BUTTON}, @@ -258,7 +267,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) // Create the edit control. Notice that the parent of // the toolbar, is used as the parent of the edit control. //hWndEdit = CreateWindowEx(0L, WC_COMBOBOXEX, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE - Globals.hDriveCombo = CreateWindowEx(0L, "ComboBox", NULL, WS_CHILD | WS_BORDER | WS_VISIBLE + Globals.hDriveCombo = CreateWindowEx(0L, _T("ComboBox"), NULL, WS_CHILD | WS_BORDER | WS_VISIBLE | CBS_DROPDOWNLIST | ES_LEFT | ES_AUTOVSCROLL | ES_MULTILINE, 10, 0, DRIVEBOX_WIDTH, DRIVEBOX_HEIGHT, Globals.hMainWnd, (HMENU)IDW_DRIVEBOX, hInstance, 0); // Set the toolbar window as the parent of the edit control diff --git a/rosapps/winfile/network.c b/rosapps/winfile/network.c index 7cdfbce1e48..48a9d761d9f 100644 --- a/rosapps/winfile/network.c +++ b/rosapps/winfile/network.c @@ -308,7 +308,7 @@ void NetworkMonitorThreadProc(void *lpParameter) HWND hWnd = (HWND)lpParameter; // Create the event - hNetworkMonitorThreadEvent = CreateEvent(NULL, TRUE, TRUE, "Winfile Network Monitor Event"); + hNetworkMonitorThreadEvent = CreateEvent(NULL, TRUE, TRUE, _T("Winfile Network Monitor Event")); // If we couldn't create the event then exit the thread if (!hNetworkMonitorThreadEvent) diff --git a/rosapps/winfile/network.h b/rosapps/winfile/network.h index c796b3a7d5c..f90e02bcb8a 100644 --- a/rosapps/winfile/network.h +++ b/rosapps/winfile/network.h @@ -1,5 +1,5 @@ /* - * ReactOS Application Debug Routines + * ReactOS Application Network support routines * * network.h * diff --git a/rosapps/winfile/run.c b/rosapps/winfile/run.c index 847ff53b8f3..0d80fccd563 100644 --- a/rosapps/winfile/run.c +++ b/rosapps/winfile/run.c @@ -40,6 +40,25 @@ #include "run.h" +typedef void (WINAPI *RUNFILEDLG)( + HWND hwndOwner, + HICON hIcon, + LPCSTR lpstrDirectory, + LPCSTR lpstrTitle, + LPCSTR lpstrDescription, + UINT uFlags); + +// +// Flags for RunFileDlg +// + +#define RFF_NOBROWSE 0x01 // Removes the browse button. +#define RFF_NODEFAULT 0x02 // No default item selected. +#define RFF_CALCDIRECTORY 0x04 // Calculates the working directory from the file name. +#define RFF_NOLABEL 0x08 // Removes the edit box label. +#define RFF_NOSEPARATEMEM 0x20 // Removes the Separate Memory Space check box (Windows NT only). + + // Show "Run..." dialog void OnFileRun(void) { diff --git a/rosapps/winfile/run.h b/rosapps/winfile/run.h index 9e95fa5ccf2..83a045ee7a4 100644 --- a/rosapps/winfile/run.h +++ b/rosapps/winfile/run.h @@ -39,23 +39,6 @@ extern "C" { void OnFileRun(void); BOOL OpenTarget(HWND hWnd, TCHAR* target); -typedef void (WINAPI *RUNFILEDLG)( - HWND hwndOwner, - HICON hIcon, - LPCSTR lpstrDirectory, - LPCSTR lpstrTitle, - LPCSTR lpstrDescription, - UINT uFlags); - -// -// Flags for RunFileDlg -// - -#define RFF_NOBROWSE 0x01 // Removes the browse button. -#define RFF_NODEFAULT 0x02 // No default item selected. -#define RFF_CALCDIRECTORY 0x04 // Calculates the working directory from the file name. -#define RFF_NOLABEL 0x08 // Removes the edit box label. -#define RFF_NOSEPARATEMEM 0x20 // Removes the Separate Memory Space check box (Windows NT only). #ifdef __cplusplus }; diff --git a/rosapps/winfile/settings.c b/rosapps/winfile/settings.c index a011bde047a..74f08724033 100644 --- a/rosapps/winfile/settings.c +++ b/rosapps/winfile/settings.c @@ -47,7 +47,7 @@ TCHAR ViewTypeMaskStr[MAX_TYPE_MASK_LEN]; void LoadSettings(void) { HKEY hKey; - char szSubKey[] = "Software\\ReactWare\\FileManager"; + TCHAR szSubKey[] = _T("Software\\ReactWare\\FileManager"); /* int i; DWORD dwSize; @@ -154,9 +154,9 @@ void LoadSettings(void) void SaveSettings(void) { HKEY hKey; - char szSubKey1[] = "Software"; - char szSubKey2[] = "Software\\ReactWare"; - char szSubKey3[] = "Software\\ReactWare\\FileManager"; + TCHAR szSubKey1[] = _T("Software"); + TCHAR szSubKey2[] = _T("Software\\ReactWare"); + TCHAR szSubKey3[] = _T("Software\\ReactWare\\FileManager"); // Open (or create) the key hKey = NULL; diff --git a/rosapps/winfile/shell.c b/rosapps/winfile/shell.c index 94f00b5e12e..2b8cb355934 100644 --- a/rosapps/winfile/shell.c +++ b/rosapps/winfile/shell.c @@ -72,7 +72,7 @@ void FormatDisk(HWND hWnd) if (pSHFormatDrive) { UINT OldMode = SetErrorMode(0); // Get the current Error Mode settings. SetErrorMode(OldMode & ~SEM_FAILCRITICALERRORS); // Force O/S to handle - pSHFormatDrive(hWnd, 0 /* A: */, SHFMT_ID_DEFAULT, 0); + pSHFormatDrive(0/*hWnd*/, 0 /* A: */, SHFMT_ID_DEFAULT, 0); SetErrorMode(OldMode); // Put it back the way it was. } FreeLibrary(hShell32); diff --git a/rosapps/winfile/shell.h b/rosapps/winfile/shell.h index 92e7e39ee1b..9769debfd80 100644 --- a/rosapps/winfile/shell.h +++ b/rosapps/winfile/shell.h @@ -1,5 +1,5 @@ /* - * ReactOS Application Debug Routines + * ReactOS Application Shell support routines * * shell.h * diff --git a/rosapps/winfile/trace.c b/rosapps/winfile/trace.c index 894408dd5af..4d471361e78 100644 --- a/rosapps/winfile/trace.c +++ b/rosapps/winfile/trace.c @@ -7,8 +7,6 @@ #include "windows.h" #include "trace.h" -DeclAssertFile; // Should be added at the begining of each .C/.CPP - #ifdef _DEBUG diff --git a/rosapps/winfile/treeview.c b/rosapps/winfile/treeview.c index 29296a15aa2..a6040e5caa3 100644 --- a/rosapps/winfile/treeview.c +++ b/rosapps/winfile/treeview.c @@ -37,8 +37,8 @@ #include #include #include -#include -#define ASSERT assert +//#include +//#define ASSERT assert #include "main.h" #include "treeview.h" diff --git a/rosapps/winfile/worker.c b/rosapps/winfile/worker.c index c98fc128023..c95cee5d146 100644 --- a/rosapps/winfile/worker.c +++ b/rosapps/winfile/worker.c @@ -92,7 +92,7 @@ void MonitorThreadProc(void *lpParameter) HWND hWnd = (HWND)lpParameter; // Create the event - hMonitorThreadEvent = CreateEvent(NULL, TRUE, TRUE, "Winfile Monitor Event"); + hMonitorThreadEvent = CreateEvent(NULL, TRUE, TRUE, _T("Winfile Monitor Event")); // If we couldn't create the event then exit the thread if (!hMonitorThreadEvent)