Rudimentiary drivebar support added.

svn path=/trunk/; revision=3358
This commit is contained in:
Robert Dickenson 2002-08-17 17:23:18 +00:00
parent 7376639aea
commit 2cac3f921d
3 changed files with 177 additions and 76 deletions

View file

@ -44,6 +44,7 @@
// Global Variables: // Global Variables:
// //
void ConfigureDriveBar(HWND hDriveBar) void ConfigureDriveBar(HWND hDriveBar)
{ {
static DWORD dwLogicalDrivesSaved; static DWORD dwLogicalDrivesSaved;
@ -53,6 +54,7 @@ void ConfigureDriveBar(HWND hDriveBar)
if (dwLogicalDrives != dwLogicalDrivesSaved) { if (dwLogicalDrives != dwLogicalDrivesSaved) {
TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP}; TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP};
COMBOBOXEXITEM cbei;
int btn = 1; int btn = 1;
PTSTR p; PTSTR p;
int count = SendMessage(hDriveBar, TB_BUTTONCOUNT, 0, 0); int count = SendMessage(hDriveBar, TB_BUTTONCOUNT, 0, 0);
@ -71,8 +73,11 @@ void ConfigureDriveBar(HWND hDriveBar)
drivebarBtn.idCommand = ID_DRIVE_FIRST; drivebarBtn.idCommand = ID_DRIVE_FIRST;
for (p = Globals.drives; *p;) { for (p = Globals.drives; *p;) {
// insert drive letter // insert drive letter
TCHAR b[3] = { tolower(*p) }; // TCHAR b[3] = { tolower(*p) };
SendMessage(hDriveBar, TB_ADDSTRING, 0, (LPARAM)b); // SendMessage(hDriveBar, TB_ADDSTRING, 0, (LPARAM)b);
TCHAR szVolumeNameBuffer[MAX_PATH];
TCHAR vol[MAX_PATH] = { tolower(*p) };
SendMessage(hDriveBar, TB_ADDSTRING, 0, (LPARAM)vol);
switch(GetDriveType(p)) { switch(GetDriveType(p)) {
case DRIVE_REMOVABLE: drivebarBtn.iBitmap = 1; break; case DRIVE_REMOVABLE: drivebarBtn.iBitmap = 1; break;
case DRIVE_CDROM: drivebarBtn.iBitmap = 3; break; case DRIVE_CDROM: drivebarBtn.iBitmap = 3; break;
@ -81,70 +86,80 @@ void ConfigureDriveBar(HWND hDriveBar)
default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2; default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2;
} }
SendMessage(hDriveBar, TB_INSERTBUTTON, btn, (LPARAM)&drivebarBtn); SendMessage(hDriveBar, TB_INSERTBUTTON, btn, (LPARAM)&drivebarBtn);
vol[0] = toupper(vol[0]);
vol[1] = _T(':'); vol[2] = _T('\\'); vol[3] = _T('\0');
if (drivebarBtn.iBitmap != 1 /*DRIVE_REMOVABLE*/ &&
GetVolumeInformation(vol, szVolumeNameBuffer,
sizeof(szVolumeNameBuffer)/sizeof(TCHAR),
NULL, NULL, NULL, NULL, 0) &&
szVolumeNameBuffer[0] != _T('\0')) {
vol[2] = _T(' '); vol[3] = _T('['); vol[4] = _T('\0');
_tcscat(vol, szVolumeNameBuffer);
_tcscat(vol, _T("] "));
} else {
vol[2] = _T(' ');
}
// cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE;
cbei.mask = CBEIF_TEXT/* | CBEIF_IMAGE*/;
cbei.iItem = btn - 1;
cbei.pszText = vol;
cbei.cchTextMax = _tcslen(cbei.pszText);
cbei.iImage = drivebarBtn.iBitmap;
// cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
// cbei.iIndent = IInf[iCnt].iIndent;
SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
drivebarBtn.idCommand++; drivebarBtn.idCommand++;
drivebarBtn.iString++; drivebarBtn.iString++;
while(*p++); 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; ++btn;
} }
dwLogicalDrivesSaved = dwLogicalDrives; dwLogicalDrivesSaved = dwLogicalDrives;
// SendMessage(Globals.hDriveCombo, CB_SHOWDROPDOWN, (WPARAM)TRUE, (LPARAM)0); // SendMessage(Globals.hDriveCombo, CB_SHOWDROPDOWN, (WPARAM)TRUE, (LPARAM)0);
} }
}
/*
#ifndef __GNUC__ #ifndef __GNUC__
{
#define MAX_ITEMS 7
{ typedef struct {
COMBOBOXEXITEM cbei; int iImage;
int iCnt; int iSelectedImage;
int iIndent;
LPTSTR pszText;
} ITEMINFO, *PITEMINFO;
typedef struct { ITEMINFO IInf[] = {
int iImage; { 0, 3, 0, _T("A:")},
int iSelectedImage; { 1, 4, 1, _T("C: [SYSTEM]")},
int iIndent; { 2, 5, 2, _T("D:")},
LPTSTR pszText; { 0, 3, 0, _T("E: [SOFT_RAID_1]")},
} ITEMINFO, *PITEMINFO; { 1, 4, 1, _T("F: [DATAVOL]")},
#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")}, { 2, 5, 2, _T("sixth")},
{ 0, 3, 0, _T("seventh")}, { 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++) { COMBOBOXEXITEM cbei;
int iCnt;
cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE; for (iCnt = 0; iCnt < MAX_ITEMS; iCnt++) {
// cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE;
cbei.mask = CBEIF_TEXT;
cbei.iItem = iCnt; cbei.iItem = iCnt;
cbei.pszText = IInf[iCnt].pszText; cbei.pszText = IInf[iCnt].pszText;
cbei.cchTextMax = sizeof(IInf[iCnt].pszText); // cbei.cchTextMax = sizeof(IInf[iCnt].pszText);
cbei.iImage = IInf[iCnt].iImage; cbei.cchTextMax = _tcslen(IInf[iCnt].pszText);
cbei.iSelectedImage = IInf[iCnt].iSelectedImage; // cbei.iImage = IInf[iCnt].iImage;
cbei.iIndent = IInf[iCnt].iIndent; // cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
} // cbei.iIndent = IInf[iCnt].iIndent;
SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei); SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
} }
#endif }
} }
#endif
*/
void _GetFreeSpaceEx(void) void _GetFreeSpaceEx(void)
{ {

View file

@ -371,6 +371,48 @@ static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
resize_frame_client(hWnd); resize_frame_client(hWnd);
} }
static BOOL cmd_drive_select(HWND hWnd, UINT cmd)
{
TCHAR drv[_MAX_DRIVE];
//TCHAR path[MAX_PATH];
//ChildWnd* pChildWnd;
LPCTSTR root = Globals.drives;
int i;
for (i = cmd - ID_DRIVE_FIRST; i--; root++)
while (*root)
root++;
if (activate_drive_window(root)) {
return TRUE;
}
_tsplitpath(root, drv, 0, 0, 0);
if (!SetCurrentDirectory(drv)) {
display_error(hWnd, GetLastError());
return TRUE;
}
//GetCurrentDirectory(MAX_PATH, path); //@@ letztes Verzeichnis pro Laufwerk speichern
//CreateChildWindow(path);
CreateChildWindow(cmd - ID_DRIVE_FIRST);
// pChildWnd = alloc_child_window(path);
// if (!create_child_window(pChildWnd))
// free(pChildWnd);
return FALSE;
}
static BOOL OnComboBoxCmd(HWND hWnd, WPARAM wParam)
{
int index;
switch (HIWORD(wParam)) {
case CBN_SELCHANGE:
index = SendMessage(Globals.hDriveCombo, CB_GETCURSEL, 0, 0);
cmd_drive_select(hWnd, index + ID_DRIVE_FIRST);
break;
default:
return FALSE;
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// //
// FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG) // FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
@ -388,30 +430,11 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// if (SendMessage(hwndClient, WM_DISPATCH_COMMAND, wParam, lParam)) // if (SendMessage(hwndClient, WM_DISPATCH_COMMAND, wParam, lParam))
// return 0; // return 0;
if ((HWND)lParam == Globals.hDriveCombo) {
return OnComboBoxCmd(hWnd, wParam);
}
if (cmd >= ID_DRIVE_FIRST && cmd <= (ID_DRIVE_FIRST + 0xFF)) { if (cmd >= ID_DRIVE_FIRST && cmd <= (ID_DRIVE_FIRST + 0xFF)) {
TCHAR drv[_MAX_DRIVE]; cmd_drive_select(hWnd, cmd);
//TCHAR path[MAX_PATH];
//ChildWnd* pChildWnd;
LPCTSTR root = Globals.drives;
int i;
for (i = cmd - ID_DRIVE_FIRST; i--; root++)
while (*root)
root++;
if (activate_drive_window(root)) {
return TRUE;
}
_tsplitpath(root, drv, 0, 0, 0);
if (!SetCurrentDirectory(drv)) {
display_error(hWnd, GetLastError());
return TRUE;
}
//GetCurrentDirectory(MAX_PATH, path); //@@ letztes Verzeichnis pro Laufwerk speichern
//CreateChildWindow(path);
CreateChildWindow(cmd - ID_DRIVE_FIRST);
// pChildWnd = alloc_child_window(path);
// if (!create_child_window(pChildWnd))
// free(pChildWnd);
} else { } else {
switch (cmd) { switch (cmd) {
case ID_WINDOW_CLOSEALL: case ID_WINDOW_CLOSEALL:
@ -422,7 +445,6 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (!SendMessage(hChildWnd, WM_QUERYENDSESSION, 0, 0)) if (!SendMessage(hChildWnd, WM_QUERYENDSESSION, 0, 0))
SendMessage(Globals.hMDIClient, WM_MDIDESTROY, (WPARAM)hChildWnd, 0); SendMessage(Globals.hMDIClient, WM_MDIDESTROY, (WPARAM)hChildWnd, 0);
break; break;
case ID_DISK_COPY_DISK: case ID_DISK_COPY_DISK:
CopyDisk(hWnd); CopyDisk(hWnd);
break; break;
@ -699,6 +721,44 @@ typedef struct _TBBUTTON {
return 0; return 0;
} }
static LRESULT OnDriveBoxNotify(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
LPNMHDR nmhdr = (LPNMHDR)lParam;
// if (nmhdr->code == NM_HOVER || nmhdr->code == NM_NCHITTEST) return 0;
// switch (((LPNMHDR)lParam)->code) {
switch (nmhdr->code) {
case NM_OUTOFMEMORY:
case NM_CLICK:
case NM_DBLCLK:
case NM_RETURN:
case NM_RCLICK:
case NM_RDBLCLK:
case NM_SETFOCUS:
case NM_KILLFOCUS:
break;
#if (_WIN32_IE >= 0x0300)
case NM_CUSTOMDRAW:
case NM_HOVER:
break;
#endif
#if (_WIN32_IE >= 0x0400)
case NM_NCHITTEST:
case NM_KEYDOWN:
case NM_RELEASEDCAPTURE:
case NM_SETCURSOR:
case NM_CHAR:
break;
#endif
default:
break;
}
return 0;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// //
// FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG) // FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
@ -731,7 +791,15 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_NOTIFY: case WM_NOTIFY:
if (MsgNotify(hWnd, message, wParam, lParam)) return TRUE; if (((LPNMHDR)lParam)->idFrom == IDW_DRIVEBOX) {
// return OnDriveBoxNotify(hWnd, wParam, lParam);
return OnDriveBoxNotify(hWnd, wParam, lParam);
//return TRUE;
}
if (((LPNMHDR)lParam)->idFrom == IDW_TOOLBAR) {
if (MsgNotify(hWnd, message, wParam, lParam)) return TRUE;
}
// return MsgNotify(hWnd, message, wParam, lParam); // return MsgNotify(hWnd, message, wParam, lParam);
switch (((LPNMHDR)lParam)->code) { switch (((LPNMHDR)lParam)->code) {
#ifdef _MSC_VER #ifdef _MSC_VER

View file

@ -139,9 +139,13 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
INITCOMMONCONTROLSEX icc = { INITCOMMONCONTROLSEX icc = {
sizeof(INITCOMMONCONTROLSEX), sizeof(INITCOMMONCONTROLSEX),
ICC_BAR_CLASSES ICC_BAR_CLASSES | ICC_USEREX_CLASSES
}; };
// icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
// icex.dwICC = ICC_USEREX_CLASSES;
// TCHAR path[MAX_PATH]; // TCHAR path[MAX_PATH];
HDC hdc = GetDC(0); HDC hdc = GetDC(0);
@ -267,13 +271,27 @@ typedef struct _TBBUTTON {
// Create the edit control. Notice that the parent of // Create the edit control. Notice that the parent of
// the toolbar, is used as the parent of the edit control. // the toolbar, is used as the parent of the edit control.
//hWndEdit = CreateWindowEx(0L, WC_COMBOBOXEX, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE //hWndEdit = CreateWindowEx(0L, WC_COMBOBOXEX, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE
Globals.hDriveCombo = CreateWindowEx(0L, _T("ComboBox"), NULL, WS_CHILD | WS_BORDER | WS_VISIBLE #if 0
| CBS_DROPDOWNLIST | ES_LEFT | ES_AUTOVSCROLL | ES_MULTILINE, 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); 10, 0, DRIVEBOX_WIDTH, DRIVEBOX_HEIGHT, Globals.hMainWnd, (HMENU)IDW_DRIVEBOX, hInstance, 0);
#else
Globals.hDriveCombo = CreateWindowEx(0, WC_COMBOBOXEX, NULL,
WS_CHILD | WS_BORDER | WS_VISIBLE | CBS_DROPDOWN,
// No size yet--resize after setting image list.
10, // Vertical position of Combobox
0, // Horizontal position of Combobox
200, // Sets the width of Combobox
100, // Sets the height of Combobox
Globals.hMainWnd,
(HMENU)IDW_DRIVEBOX,
hInstance,
NULL);
#endif
// Set the toolbar window as the parent of the edit control // Set the toolbar window as the parent of the edit control
// window. You must set the toolbar as the parent of the edit // window. You must set the toolbar as the parent of the edit
// control for it to appear embedded in the toolbar. // control for it to appear embedded in the toolbar.
SetParent (Globals.hDriveCombo, Globals.hToolBar); SetParent(Globals.hDriveCombo, Globals.hToolBar);
} }
} }