mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Implement the context menu (mouse only at the moment) makeing it accessable when the cursor over the item only
- open the propsheet when double clicking child items - make 'properties' bold svn path=/trunk/; revision=24380
This commit is contained in:
parent
21dd51fc8b
commit
a2d3c5fe33
4 changed files with 133 additions and 89 deletions
|
@ -8,7 +8,7 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "Print", IDC_PRINT, GRAYED
|
MENUITEM "Print", IDC_PRINT, GRAYED
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Properties...", IDC_PROP
|
MENUITEM "Properties", IDC_PROP
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Help", IDC_PROGHELP, GRAYED
|
MENUITEM "Help", IDC_PROGHELP, GRAYED
|
||||||
END
|
END
|
||||||
|
@ -30,7 +30,7 @@ IDR_POPUP MENU
|
||||||
BEGIN
|
BEGIN
|
||||||
POPUP "popup"
|
POPUP "popup"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "Properties...", IDC_PROP, GRAYED
|
MENUITEM "Properties", IDC_PROP
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Help", IDC_PROGHELP
|
MENUITEM "Help", IDC_PROGHELP
|
||||||
END
|
END
|
||||||
|
|
|
@ -9,10 +9,16 @@
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
|
|
||||||
static SP_CLASSIMAGELIST_DATA ImageListData;
|
static SP_CLASSIMAGELIST_DATA ImageListData;
|
||||||
static HDEVINFO hDevInfo;
|
static HDEVINFO hDevInfo;
|
||||||
|
|
||||||
|
|
||||||
|
VOID OpenPropSheet(HTREEITEM hItem)
|
||||||
|
{
|
||||||
|
DisplayString(_T("Device Propsheet not yet implemented"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static HTREEITEM
|
static HTREEITEM
|
||||||
InsertIntoTreeView(HWND hTV,
|
InsertIntoTreeView(HWND hTV,
|
||||||
HTREEITEM hRoot,
|
HTREEITEM hRoot,
|
||||||
|
@ -91,12 +97,12 @@ EnumDeviceClasses(INT ClassIndex,
|
||||||
/* FIXME: can we do this?
|
/* FIXME: can we do this?
|
||||||
* Set the blank icon: IDI_SETUPAPI_BLANK = 41
|
* Set the blank icon: IDI_SETUPAPI_BLANK = 41
|
||||||
* it'll be image 24 in the imagelist */
|
* it'll be image 24 in the imagelist */
|
||||||
*ClassImage = 41;
|
*ClassImage = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get device info for all devices of a particular class */
|
/* Get device info for all devices of a particular class */
|
||||||
hDevInfo = SetupDiGetClassDevs(&ClassGuid,
|
hDevInfo = SetupDiGetClassDevs(&ClassGuid,
|
||||||
0,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
DIGCF_PRESENT);
|
DIGCF_PRESENT);
|
||||||
if (hDevInfo == INVALID_HANDLE_VALUE)
|
if (hDevInfo == INVALID_HANDLE_VALUE)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
static const TCHAR szMainWndClass[] = TEXT("DevMgmtWndClass");
|
static const TCHAR szMainWndClass[] = TEXT("DevMgmtWndClass");
|
||||||
|
|
||||||
|
|
||||||
/* Toolbar buttons */
|
/* Toolbar buttons */
|
||||||
TBBUTTON Buttons [] =
|
TBBUTTON Buttons [] =
|
||||||
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
||||||
|
@ -39,6 +40,7 @@ static const MENU_HINT MainMenuHintTable[] = {
|
||||||
{IDC_PROGHELP, IDS_HINT_HELP},
|
{IDC_PROGHELP, IDS_HINT_HELP},
|
||||||
{IDC_ABOUT, IDS_HINT_ABOUT}
|
{IDC_ABOUT, IDS_HINT_ABOUT}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* system menu hints */
|
/* system menu hints */
|
||||||
static const MENU_HINT SystemMenuHintTable[] = {
|
static const MENU_HINT SystemMenuHintTable[] = {
|
||||||
{SC_RESTORE, IDS_HINT_SYS_RESTORE},
|
{SC_RESTORE, IDS_HINT_SYS_RESTORE},
|
||||||
|
@ -153,11 +155,11 @@ CreateTreeView(PMAIN_WND_INFO Info)
|
||||||
Info->hTreeView = CreateWindowEx(0,
|
Info->hTreeView = CreateWindowEx(0,
|
||||||
WC_TREEVIEW,
|
WC_TREEVIEW,
|
||||||
NULL,
|
NULL,
|
||||||
WS_CHILD | WS_VISIBLE | WS_BORDER |
|
WS_CHILD | WS_VISIBLE | WS_BORDER | TVS_HASLINES |
|
||||||
TVS_HASLINES | TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT,
|
TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
Info->hMainWnd,
|
Info->hMainWnd,
|
||||||
(HMENU) IDC_TREEVIEW,
|
(HMENU)IDC_TREEVIEW,
|
||||||
hInstance,
|
hInstance,
|
||||||
NULL);
|
NULL);
|
||||||
if (Info->hTreeView == NULL)
|
if (Info->hTreeView == NULL)
|
||||||
|
@ -200,6 +202,7 @@ CreateStatusBar(PMAIN_WND_INFO Info)
|
||||||
static VOID
|
static VOID
|
||||||
InitMainWnd(PMAIN_WND_INFO Info)
|
InitMainWnd(PMAIN_WND_INFO Info)
|
||||||
{
|
{
|
||||||
|
HMENU hMenu;
|
||||||
HTREEITEM hRoot;
|
HTREEITEM hRoot;
|
||||||
|
|
||||||
if (!CreateToolbar(Info))
|
if (!CreateToolbar(Info))
|
||||||
|
@ -214,18 +217,125 @@ InitMainWnd(PMAIN_WND_INFO Info)
|
||||||
if (!CreateStatusBar(Info))
|
if (!CreateStatusBar(Info))
|
||||||
DisplayString(_T("error creating status bar"));
|
DisplayString(_T("error creating status bar"));
|
||||||
|
|
||||||
|
/* make 'properties' bold */
|
||||||
|
hMenu = GetMenu(Info->hMainWnd);
|
||||||
|
hMenu = GetSubMenu(hMenu, 1);
|
||||||
|
SetMenuDefaultItem(hMenu, IDC_PROP, FALSE);
|
||||||
|
|
||||||
/* Create Popup Menu */
|
/* Create Popup Menu */
|
||||||
Info->hShortcutMenu = LoadMenu(hInstance,
|
Info->hShortcutMenu = LoadMenu(hInstance,
|
||||||
MAKEINTRESOURCE(IDR_POPUP));
|
MAKEINTRESOURCE(IDR_POPUP));
|
||||||
Info->hShortcutMenu = GetSubMenu(Info->hShortcutMenu,
|
Info->hShortcutMenu = GetSubMenu(Info->hShortcutMenu,
|
||||||
0);
|
0);
|
||||||
|
SetMenuDefaultItem(Info->hShortcutMenu, IDC_PROP, FALSE);
|
||||||
|
|
||||||
|
/* emum all devices */
|
||||||
hRoot = InitTreeView(Info);
|
hRoot = InitTreeView(Info);
|
||||||
if (hRoot)
|
if (hRoot)
|
||||||
ListDevicesByType(Info, hRoot);
|
ListDevicesByType(Info, hRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
OnContext(PMAIN_WND_INFO Info,
|
||||||
|
LPARAM lParam)
|
||||||
|
{
|
||||||
|
HTREEITEM hSelected;
|
||||||
|
POINT pt;
|
||||||
|
RECT rc;
|
||||||
|
|
||||||
|
INT xPos = GET_X_LPARAM(lParam);
|
||||||
|
INT yPos = GET_Y_LPARAM(lParam);
|
||||||
|
|
||||||
|
hSelected = TreeView_GetSelection(Info->hTreeView);
|
||||||
|
|
||||||
|
if (TreeView_GetItemRect(Info->hTreeView,
|
||||||
|
hSelected,
|
||||||
|
&rc,
|
||||||
|
TRUE))
|
||||||
|
{
|
||||||
|
if (GetCursorPos(&pt) &&
|
||||||
|
ScreenToClient(Info->hTreeView, &pt) &&
|
||||||
|
PtInRect(&rc, pt))
|
||||||
|
{
|
||||||
|
TrackPopupMenuEx(Info->hShortcutMenu,
|
||||||
|
TPM_RIGHTBUTTON,
|
||||||
|
xPos,
|
||||||
|
yPos,
|
||||||
|
Info->hMainWnd,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
OnNotify(PMAIN_WND_INFO Info,
|
||||||
|
LPARAM lParam)
|
||||||
|
{
|
||||||
|
|
||||||
|
LPNMHDR pnmhdr = (LPNMHDR)lParam;
|
||||||
|
|
||||||
|
switch (pnmhdr->code)
|
||||||
|
{
|
||||||
|
case NM_DBLCLK:
|
||||||
|
{
|
||||||
|
HTREEITEM hSelected = TreeView_GetSelection(Info->hTreeView);
|
||||||
|
|
||||||
|
if (!TreeView_GetChild(Info->hTreeView,
|
||||||
|
hSelected))
|
||||||
|
{
|
||||||
|
OpenPropSheet(hSelected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NM_RCLICK:
|
||||||
|
{
|
||||||
|
TV_HITTESTINFO HitTest;
|
||||||
|
|
||||||
|
if (GetCursorPos(&HitTest.pt) &&
|
||||||
|
ScreenToClient(Info->hTreeView, &HitTest.pt))
|
||||||
|
{
|
||||||
|
if (TreeView_HitTest(Info->hTreeView, &HitTest))
|
||||||
|
TreeView_SelectItem(Info->hTreeView, HitTest.hItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TTN_GETDISPINFO:
|
||||||
|
{
|
||||||
|
LPTOOLTIPTEXT lpttt;
|
||||||
|
UINT idButton;
|
||||||
|
|
||||||
|
lpttt = (LPTOOLTIPTEXT)lParam;
|
||||||
|
|
||||||
|
idButton = (UINT)lpttt->hdr.idFrom;
|
||||||
|
switch (idButton)
|
||||||
|
{
|
||||||
|
case IDC_PROP:
|
||||||
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PROP);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDC_REFRESH:
|
||||||
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDC_PROGHELP:
|
||||||
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_HELP);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDC_EXIT:
|
||||||
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EXIT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
MainWndCommand(PMAIN_WND_INFO Info,
|
MainWndCommand(PMAIN_WND_INFO Info,
|
||||||
WORD CmdId,
|
WORD CmdId,
|
||||||
|
@ -237,7 +347,8 @@ MainWndCommand(PMAIN_WND_INFO Info,
|
||||||
{
|
{
|
||||||
case IDC_PROP:
|
case IDC_PROP:
|
||||||
{
|
{
|
||||||
// call builtin driver prop sheet
|
HTREEITEM hSelected = TreeView_GetSelection(Info->hTreeView);
|
||||||
|
OpenPropSheet(hSelected);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -360,88 +471,14 @@ MainWndProc(HWND hwnd,
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
{
|
{
|
||||||
LPNMHDR pnmhdr = (LPNMHDR)lParam;
|
OnNotify(Info, lParam);
|
||||||
|
|
||||||
switch (pnmhdr->code)
|
|
||||||
{
|
|
||||||
case NM_DBLCLK:
|
|
||||||
{
|
|
||||||
POINT pt;
|
|
||||||
RECT rect;
|
|
||||||
|
|
||||||
GetCursorPos(&pt);
|
|
||||||
GetWindowRect(Info->hTreeView, &rect);
|
|
||||||
|
|
||||||
if (PtInRect(&rect, pt))
|
|
||||||
{
|
|
||||||
SendMessage(hwnd,
|
|
||||||
WM_COMMAND,
|
|
||||||
//ID_PROP,
|
|
||||||
MAKEWPARAM((WORD)IDC_PROP, (WORD)0),
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//OpenPropSheet(Info);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TTN_GETDISPINFO:
|
|
||||||
{
|
|
||||||
LPTOOLTIPTEXT lpttt;
|
|
||||||
UINT idButton;
|
|
||||||
|
|
||||||
lpttt = (LPTOOLTIPTEXT)lParam;
|
|
||||||
|
|
||||||
/* Specify the resource identifier of the descriptive
|
|
||||||
* text for the given button. */
|
|
||||||
idButton = (UINT)lpttt->hdr.idFrom;
|
|
||||||
switch (idButton)
|
|
||||||
{
|
|
||||||
case IDC_PROP:
|
|
||||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PROP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IDC_REFRESH:
|
|
||||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IDC_PROGHELP:
|
|
||||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_HELP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IDC_EXIT:
|
|
||||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EXIT);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CONTEXTMENU:
|
case WM_CONTEXTMENU:
|
||||||
{
|
{
|
||||||
POINT pt;
|
OnContext(Info, lParam);
|
||||||
RECT lvRect;
|
}
|
||||||
|
|
||||||
INT xPos = GET_X_LPARAM(lParam);
|
|
||||||
INT yPos = GET_Y_LPARAM(lParam);
|
|
||||||
|
|
||||||
GetCursorPos(&pt);
|
|
||||||
|
|
||||||
/* display popup when cursor is in the list view */
|
|
||||||
GetWindowRect(Info->hTreeView, &lvRect);
|
|
||||||
if (PtInRect(&lvRect, pt))
|
|
||||||
{
|
|
||||||
TrackPopupMenuEx(Info->hShortcutMenu,
|
|
||||||
TPM_RIGHTBUTTON,
|
|
||||||
xPos,
|
|
||||||
yPos,
|
|
||||||
Info->hMainWnd,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#pragma warning(disable : 4100)
|
#pragma warning(disable : 4100)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_DEV_LEN 1000
|
#define MAX_DEV_LEN 256
|
||||||
|
|
||||||
typedef struct _MAIN_WND_INFO
|
typedef struct _MAIN_WND_INFO
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ typedef struct _MAIN_WND_INFO
|
||||||
BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
|
||||||
/* servman.c */
|
/* devmgmt.c */
|
||||||
extern HINSTANCE hInstance;
|
extern HINSTANCE hInstance;
|
||||||
extern HANDLE ProcessHeap;
|
extern HANDLE ProcessHeap;
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ HWND CreateMainWindow(LPCTSTR lpCaption, int nCmdShow);
|
||||||
|
|
||||||
|
|
||||||
/* enumdevices.c */
|
/* enumdevices.c */
|
||||||
|
VOID OpenPropSheet(HTREEITEM hItem);
|
||||||
HTREEITEM InitTreeView(PMAIN_WND_INFO Info);
|
HTREEITEM InitTreeView(PMAIN_WND_INFO Info);
|
||||||
VOID ListDevicesByType(PMAIN_WND_INFO Info, HTREEITEM hRoot);
|
VOID ListDevicesByType(PMAIN_WND_INFO Info, HTREEITEM hRoot);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue