mirror of
https://github.com/reactos/reactos.git
synced 2024-12-25 16:50:57 +00:00
Rudimentiary drivebar support added.
svn path=/trunk/; revision=3358
This commit is contained in:
parent
7376639aea
commit
2cac3f921d
3 changed files with 177 additions and 76 deletions
|
@ -44,6 +44,7 @@
|
|||
// Global Variables:
|
||||
//
|
||||
|
||||
|
||||
void ConfigureDriveBar(HWND hDriveBar)
|
||||
{
|
||||
static DWORD dwLogicalDrivesSaved;
|
||||
|
@ -53,6 +54,7 @@ void ConfigureDriveBar(HWND hDriveBar)
|
|||
|
||||
if (dwLogicalDrives != dwLogicalDrivesSaved) {
|
||||
TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP};
|
||||
COMBOBOXEXITEM cbei;
|
||||
int btn = 1;
|
||||
PTSTR p;
|
||||
int count = SendMessage(hDriveBar, TB_BUTTONCOUNT, 0, 0);
|
||||
|
@ -71,8 +73,11 @@ void ConfigureDriveBar(HWND hDriveBar)
|
|||
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);
|
||||
// TCHAR b[3] = { tolower(*p) };
|
||||
// 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)) {
|
||||
case DRIVE_REMOVABLE: drivebarBtn.iBitmap = 1; break;
|
||||
case DRIVE_CDROM: drivebarBtn.iBitmap = 3; break;
|
||||
|
@ -81,70 +86,80 @@ void ConfigureDriveBar(HWND hDriveBar)
|
|||
default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2;
|
||||
}
|
||||
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.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__
|
||||
{
|
||||
#define MAX_ITEMS 7
|
||||
|
||||
{
|
||||
COMBOBOXEXITEM cbei;
|
||||
int iCnt;
|
||||
typedef struct {
|
||||
int iImage;
|
||||
int iSelectedImage;
|
||||
int iIndent;
|
||||
LPTSTR pszText;
|
||||
} ITEMINFO, *PITEMINFO;
|
||||
|
||||
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")},
|
||||
ITEMINFO IInf[] = {
|
||||
{ 0, 3, 0, _T("A:")},
|
||||
{ 1, 4, 1, _T("C: [SYSTEM]")},
|
||||
{ 2, 5, 2, _T("D:")},
|
||||
{ 0, 3, 0, _T("E: [SOFT_RAID_1]")},
|
||||
{ 1, 4, 1, _T("F: [DATAVOL]")},
|
||||
{ 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++) {
|
||||
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.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;
|
||||
}
|
||||
|
||||
|
||||
// cbei.cchTextMax = sizeof(IInf[iCnt].pszText);
|
||||
cbei.cchTextMax = _tcslen(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
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
void _GetFreeSpaceEx(void)
|
||||
{
|
||||
|
|
|
@ -371,6 +371,48 @@ static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
|
|||
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)
|
||||
|
@ -388,30 +430,11 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
// if (SendMessage(hwndClient, WM_DISPATCH_COMMAND, wParam, lParam))
|
||||
// return 0;
|
||||
|
||||
if ((HWND)lParam == Globals.hDriveCombo) {
|
||||
return OnComboBoxCmd(hWnd, wParam);
|
||||
}
|
||||
if (cmd >= ID_DRIVE_FIRST && cmd <= (ID_DRIVE_FIRST + 0xFF)) {
|
||||
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);
|
||||
cmd_drive_select(hWnd, cmd);
|
||||
} else {
|
||||
switch (cmd) {
|
||||
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))
|
||||
SendMessage(Globals.hMDIClient, WM_MDIDESTROY, (WPARAM)hChildWnd, 0);
|
||||
break;
|
||||
|
||||
case ID_DISK_COPY_DISK:
|
||||
CopyDisk(hWnd);
|
||||
break;
|
||||
|
@ -699,6 +721,44 @@ typedef struct _TBBUTTON {
|
|||
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)
|
||||
|
@ -731,7 +791,15 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
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);
|
||||
switch (((LPNMHDR)lParam)->code) {
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -139,9 +139,13 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
|
||||
INITCOMMONCONTROLSEX icc = {
|
||||
sizeof(INITCOMMONCONTROLSEX),
|
||||
ICC_BAR_CLASSES
|
||||
ICC_BAR_CLASSES | ICC_USEREX_CLASSES
|
||||
};
|
||||
|
||||
// icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
// icex.dwICC = ICC_USEREX_CLASSES;
|
||||
|
||||
|
||||
// TCHAR path[MAX_PATH];
|
||||
|
||||
HDC hdc = GetDC(0);
|
||||
|
@ -267,13 +271,27 @@ typedef struct _TBBUTTON {
|
|||
// 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, _T("ComboBox"), NULL, WS_CHILD | WS_BORDER | WS_VISIBLE
|
||||
| CBS_DROPDOWNLIST | ES_LEFT | ES_AUTOVSCROLL | ES_MULTILINE,
|
||||
#if 0
|
||||
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);
|
||||
#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
|
||||
// window. You must set the toolbar as the parent of the edit
|
||||
// control for it to appear embedded in the toolbar.
|
||||
SetParent (Globals.hDriveCombo, Globals.hToolBar);
|
||||
SetParent(Globals.hDriveCombo, Globals.hToolBar);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue