Author: gedmurphy
Date: Tue Oct 3 23:55:15 2006
New Revision: 24380
URL:
http://svn.reactos.org/svn/reactos?rev=24380&view=rev
Log:
- 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
Modified:
trunk/reactos/base/applications/devmgmt/En.rc
trunk/reactos/base/applications/devmgmt/enumdevices.c
trunk/reactos/base/applications/devmgmt/mainwnd.c
trunk/reactos/base/applications/devmgmt/precomp.h
Modified: trunk/reactos/base/applications/devmgmt/En.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/…
==============================================================================
--- trunk/reactos/base/applications/devmgmt/En.rc (original)
+++ trunk/reactos/base/applications/devmgmt/En.rc Tue Oct 3 23:55:15 2006
@@ -8,7 +8,7 @@
BEGIN
MENUITEM "Print", IDC_PRINT, GRAYED
MENUITEM SEPARATOR
- MENUITEM "Properties...", IDC_PROP
+ MENUITEM "Properties", IDC_PROP
MENUITEM SEPARATOR
MENUITEM "Help", IDC_PROGHELP, GRAYED
END
@@ -30,7 +30,7 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM "Properties...", IDC_PROP, GRAYED
+ MENUITEM "Properties", IDC_PROP
MENUITEM SEPARATOR
MENUITEM "Help", IDC_PROGHELP
END
Modified: trunk/reactos/base/applications/devmgmt/enumdevices.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/…
==============================================================================
--- trunk/reactos/base/applications/devmgmt/enumdevices.c (original)
+++ trunk/reactos/base/applications/devmgmt/enumdevices.c Tue Oct 3 23:55:15 2006
@@ -9,9 +9,15 @@
#include "precomp.h"
-
static SP_CLASSIMAGELIST_DATA ImageListData;
static HDEVINFO hDevInfo;
+
+
+VOID OpenPropSheet(HTREEITEM hItem)
+{
+ DisplayString(_T("Device Propsheet not yet implemented"));
+}
+
static HTREEITEM
InsertIntoTreeView(HWND hTV,
@@ -91,12 +97,12 @@
/* FIXME: can we do this?
* Set the blank icon: IDI_SETUPAPI_BLANK = 41
* it'll be image 24 in the imagelist */
- *ClassImage = 41;
+ *ClassImage = 24;
}
/* Get device info for all devices of a particular class */
hDevInfo = SetupDiGetClassDevs(&ClassGuid,
- 0,
+ NULL,
NULL,
DIGCF_PRESENT);
if (hDevInfo == INVALID_HANDLE_VALUE)
Modified: trunk/reactos/base/applications/devmgmt/mainwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/…
==============================================================================
--- trunk/reactos/base/applications/devmgmt/mainwnd.c (original)
+++ trunk/reactos/base/applications/devmgmt/mainwnd.c Tue Oct 3 23:55:15 2006
@@ -11,6 +11,7 @@
static const TCHAR szMainWndClass[] = TEXT("DevMgmtWndClass");
+
/* Toolbar buttons */
TBBUTTON Buttons [] =
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
@@ -39,6 +40,7 @@
{IDC_PROGHELP, IDS_HINT_HELP},
{IDC_ABOUT, IDS_HINT_ABOUT}
};
+
/* system menu hints */
static const MENU_HINT SystemMenuHintTable[] = {
{SC_RESTORE, IDS_HINT_SYS_RESTORE},
@@ -153,11 +155,11 @@
Info->hTreeView = CreateWindowEx(0,
WC_TREEVIEW,
NULL,
- WS_CHILD | WS_VISIBLE | WS_BORDER |
- TVS_HASLINES | TVS_HASBUTTONS | TVS_SHOWSELALWAYS
| TVS_LINESATROOT,
+ WS_CHILD | WS_VISIBLE | WS_BORDER | TVS_HASLINES |
+ TVS_HASBUTTONS | TVS_SHOWSELALWAYS |
TVS_LINESATROOT,
0, 0, 0, 0,
Info->hMainWnd,
- (HMENU) IDC_TREEVIEW,
+ (HMENU)IDC_TREEVIEW,
hInstance,
NULL);
if (Info->hTreeView == NULL)
@@ -200,6 +202,7 @@
static VOID
InitMainWnd(PMAIN_WND_INFO Info)
{
+ HMENU hMenu;
HTREEITEM hRoot;
if (!CreateToolbar(Info))
@@ -213,16 +216,123 @@
if (!CreateStatusBar(Info))
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 */
Info->hShortcutMenu = LoadMenu(hInstance,
MAKEINTRESOURCE(IDR_POPUP));
Info->hShortcutMenu = GetSubMenu(Info->hShortcutMenu,
0);
-
+ SetMenuDefaultItem(Info->hShortcutMenu, IDC_PROP, FALSE);
+
+ /* emum all devices */
hRoot = InitTreeView(Info);
if (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;
+ }
}
@@ -237,7 +347,8 @@
{
case IDC_PROP:
{
- // call builtin driver prop sheet
+ HTREEITEM hSelected = TreeView_GetSelection(Info->hTreeView);
+ OpenPropSheet(hSelected);
}
break;
@@ -360,88 +471,14 @@
case WM_NOTIFY:
{
- LPNMHDR pnmhdr = (LPNMHDR)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;
- }
+ OnNotify(Info, lParam);
}
break;
case WM_CONTEXTMENU:
- {
- POINT pt;
- 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);
- }
- }
+ {
+ OnContext(Info, lParam);
+ }
break;
case WM_COMMAND:
Modified: trunk/reactos/base/applications/devmgmt/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/…
==============================================================================
--- trunk/reactos/base/applications/devmgmt/precomp.h (original)
+++ trunk/reactos/base/applications/devmgmt/precomp.h Tue Oct 3 23:55:15 2006
@@ -15,7 +15,7 @@
#pragma warning(disable : 4100)
#endif
-#define MAX_DEV_LEN 1000
+#define MAX_DEV_LEN 256
typedef struct _MAIN_WND_INFO
{
@@ -36,7 +36,7 @@
BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
-/* servman.c */
+/* devmgmt.c */
extern HINSTANCE hInstance;
extern HANDLE ProcessHeap;
@@ -53,6 +53,7 @@
/* enumdevices.c */
+VOID OpenPropSheet(HTREEITEM hItem);
HTREEITEM InitTreeView(PMAIN_WND_INFO Info);
VOID ListDevicesByType(PMAIN_WND_INFO Info, HTREEITEM hRoot);