ReactOS 0.4.15-dev-7907-g95bf896
CDeviceManager Class Reference

#include <MainWindow.h>

Collaboration diagram for CDeviceManager:

Public Member Functions

 CDeviceManager (void)
 
 ~CDeviceManager (void)
 
bool Create (_In_ HWND hWndParent, _In_ HINSTANCE hInst, _In_opt_z_ LPCWSTR lpMachineName, _In_ int nCmdShow)
 

Private Member Functions

bool Initialize (_In_z_ LPCTSTR lpCaption, _In_ int nCmdShow)
 
int Run ()
 
void Uninitialize (void)
 
LRESULT OnCreate (_In_ HWND hwnd)
 
LRESULT OnDestroy (void)
 
LRESULT OnSize (void)
 
LRESULT OnNotify (_In_ LPARAM lParam)
 
LRESULT OnContext (_In_ LPARAM lParam)
 
LRESULT OnCommand (_In_ WPARAM wParam, LPARAM lParam)
 
void OnActivate (void)
 
bool CreateToolBar (void)
 
bool CreateStatusBar (void)
 
void UpdateToolbar (void)
 
bool StatusBarLoadString (_In_ HWND hStatusBar, _In_ INT PartId, _In_ HINSTANCE hInstance, _In_ UINT uID)
 
void UpdateStatusBar (_In_ bool InMenuLoop)
 
bool MainWndMenuHint (_In_ WORD CmdId, _In_ const MENU_HINT *HintArray, _In_ DWORD HintsCount, _In_ UINT DefHintId)
 
bool RefreshView (_In_ ViewType Type, _In_ bool ScanForChanges)
 

Static Private Member Functions

static LRESULT CALLBACK MainWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 

Private Attributes

CAtlStringW m_szMainWndClass
 
CDeviceViewm_DeviceView
 
HWND m_hMainWnd
 
HWND m_hStatusBar
 
HWND m_hToolBar
 
HMENU m_hMenu
 
int m_CmdShow
 
BOOL m_RefreshPending
 

Detailed Description

Definition at line 10 of file MainWindow.h.

Constructor & Destructor Documentation

◆ CDeviceManager()

CDeviceManager::CDeviceManager ( void  )

Definition at line 80 of file MainWindow.cpp.

80 :
84 m_CmdShow(0),
85 m_RefreshPending(false)
86{
87 m_szMainWndClass = L"DevMgmtWndClass";
88}
BOOL m_RefreshPending
Definition: MainWindow.h:19
HWND m_hStatusBar
Definition: MainWindow.h:15
CAtlStringW m_szMainWndClass
Definition: MainWindow.h:12
#define NULL
Definition: types.h:112
#define L(x)
Definition: ntvdm.h:50

◆ ~CDeviceManager()

CDeviceManager::~CDeviceManager ( void  )

Definition at line 90 of file MainWindow.cpp.

91{
92}

Member Function Documentation

◆ Create()

bool CDeviceManager::Create ( _In_ HWND  hWndParent,
_In_ HINSTANCE  hInst,
_In_opt_z_ LPCWSTR  lpMachineName,
_In_ int  nCmdShow 
)

Definition at line 95 of file MainWindow.cpp.

99{
100 CDeviceManager MainWindow;
103 int Ret = 1;
104
105 // Store the instances
107 g_hThisInstance = GetModuleHandleW(L"devmgr.dll");
108
109 // Initialize common controls
110 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
113
114 // Load the application name
115 if (szAppName.LoadStringW(g_hThisInstance, IDS_APPNAME))
116 {
117 // Initialize the main window
118 if (MainWindow.Initialize(szAppName, nCmdShow))
119 {
120 // Run the application
121 Ret = MainWindow.Run();
122
123 // Uninitialize the main window
124 MainWindow.Uninitialize();
125 }
126 }
127
128 return (Ret == 0);
129}
#define IDS_APPNAME
Definition: resource.h:49
void Uninitialize(void)
Definition: MainWindow.cpp:183
bool Initialize(_In_z_ LPCTSTR lpCaption, _In_ int nCmdShow)
Definition: MainWindow.cpp:135
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
HINSTANCE g_hParentInstance
Definition: MainWindow.cpp:26
HINSTANCE g_hThisInstance
Definition: MainWindow.cpp:25
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HINSTANCE hInst
Definition: dxdiag.c:13
CStringT< wchar_t, StrTraitATL< wchar_t, ChTraitsCRT< wchar_t > > > CAtlStringW
Definition: atlstr.h:126
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define ICC_COOL_CLASSES
Definition: commctrl.h:69
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
TCHAR szAppName[128]
Definition: solitaire.cpp:18

Referenced by DeviceManager_ExecuteW().

◆ CreateStatusBar()

bool CDeviceManager::CreateStatusBar ( void  )
private

Definition at line 337 of file MainWindow.cpp.

338{
339 int StatWidths[] = {110, -1}; // widths of status bar
340 bool bRet = FALSE;
341
342 // Create the status bar
345 NULL,
347 0, 0, 0, 0,
351 NULL);
352 if (m_hStatusBar)
353 {
354 // Set the width
357 sizeof(StatWidths) / sizeof(int),
358 (LPARAM)StatWidths) != 0);
359 }
360
361 return bRet;
362}
#define IDC_STATUSBAR
Definition: resource.h:12
#define FALSE
Definition: types.h:117
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define SB_SETPARTS
Definition: commctrl.h:1954
#define SBARS_SIZEGRIP
Definition: commctrl.h:1923
#define STATUSCLASSNAME
Definition: commctrl.h:1939
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by OnCreate().

◆ CreateToolBar()

bool CDeviceManager::CreateToolBar ( void  )
private

Definition at line 287 of file MainWindow.cpp.

288{
289 TBADDBITMAP TbAddBitmap;
290
293
294 // Create the toolbar window
295 m_hToolBar = CreateWindowExW(dwExStyles,
297 NULL,
298 dwStyles,
299 0, 0, 0, 0,
303 NULL);
304 if (m_hToolBar == NULL)
305 return FALSE;
306
307 // Don't show clipped buttons
310 0,
312
314
315 // Set the struct size, the toobar needs this...
318 sizeof(TBBUTTON),
319 0);
320
321 TbAddBitmap.hInst = g_hThisInstance;
322 TbAddBitmap.nID = IDB_TOOLBAR;
324
327
328 if (TRUE)
329 {
331 }
332
333 return TRUE;
334}
#define TRUE
Definition: types.h:120
static TBBUTTON TbButtons[]
Definition: MainWindow.cpp:66
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WS_CHILDWINDOW
Definition: pedump.c:639
#define TB_SETEXTENDEDSTYLE
Definition: commctrl.h:1190
#define TB_AUTOSIZE
Definition: commctrl.h:1137
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define TBSTYLE_EX_HIDECLIPPEDBUTTONS
Definition: commctrl.h:1013
#define CCS_NODIVIDER
Definition: commctrl.h:2248
#define TB_SETBITMAPSIZE
Definition: commctrl.h:1136
#define TBSTYLE_FLAT
Definition: commctrl.h:992
#define TOOLBARCLASSNAME
Definition: commctrl.h:946
#define TBSTYLE_WRAPABLE
Definition: commctrl.h:990
#define TB_ADDBUTTONSW
Definition: commctrl.h:1266
#define TB_ADDBITMAP
Definition: commctrl.h:1056
#define _countof(array)
Definition: sndvol32.h:68
UINT_PTR nID
Definition: commctrl.h:1060
HINSTANCE hInst
Definition: commctrl.h:1059
#define MAKELONG(a, b)
Definition: typedefs.h:249
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WS_EX_RIGHTSCROLLBAR
Definition: winuser.h:401
#define WS_EX_LTRREADING
Definition: winuser.h:393
#define SW_SHOW
Definition: winuser.h:775
#define WS_EX_LEFT
Definition: winuser.h:391
#define IDB_TOOLBAR
Definition: wordpad.h:183
#define IDC_TOOLBAR
Definition: wordpad.h:157

Referenced by OnCreate().

◆ Initialize()

bool CDeviceManager::Initialize ( _In_z_ LPCTSTR  lpCaption,
_In_ int  nCmdShow 
)
private

Definition at line 135 of file MainWindow.cpp.

137{
138 CAtlStringW szCaption;
139 WNDCLASSEXW wc = {0};
140
141 // Store the show window value
142 m_CmdShow = nCmdShow;
143
144 // Setup the window class struct
145 wc.cbSize = sizeof(WNDCLASSEXW);
150 wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
158 0);
159
160 // Register the window
161 if (RegisterClassExW(&wc))
162 {
163 // Create the main window and store the object pointer
166 lpCaption,
170 550,
171 500,
172 NULL,
173 NULL,
175 this);
176 }
177
178 // Return creation result
179 return !!(m_hMainWnd);
180}
#define IDM_MAINMENU
Definition: resources.h:3
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: MainWindow.cpp:714
#define IDI_MAIN_ICON
Definition: resource.h:8
static HICON
Definition: imagelist.c:84
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
LPCWSTR lpszClassName
Definition: winuser.h:3226
LPCWSTR lpszMenuName
Definition: winuser.h:3225
HBRUSH hbrBackground
Definition: winuser.h:3224
WNDPROC lpfnWndProc
Definition: winuser.h:3218
UINT cbSize
Definition: winuser.h:3216
HCURSOR hCursor
Definition: winuser.h:3223
HICON hIconSm
Definition: winuser.h:3227
HINSTANCE hInstance
Definition: winuser.h:3221
HICON hIcon
Definition: winuser.h:3222
#define IMAGE_ICON
Definition: winuser.h:212
#define IDC_ARROW
Definition: winuser.h:687
#define SM_CYSMICON
Definition: winuser.h:1013
#define SM_CXSMICON
Definition: winuser.h:1012
#define LoadIcon
Definition: winuser.h:5813
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define LoadCursor
Definition: winuser.h:5812
#define CW_USEDEFAULT
Definition: winuser.h:225
#define LoadImage
Definition: winuser.h:5815
struct _WNDCLASSEXW WNDCLASSEXW
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
#define COLOR_BTNFACE
Definition: winuser.h:928

Referenced by Create().

◆ MainWndMenuHint()

bool CDeviceManager::MainWndMenuHint ( _In_ WORD  CmdId,
_In_ const MENU_HINT HintArray,
_In_ DWORD  HintsCount,
_In_ UINT  DefHintId 
)
private

Definition at line 205 of file MainWindow.cpp.

209{
210 bool Found = false;
211 const MENU_HINT *LastHint;
212 UINT HintId = DefHintId;
213
214 LastHint = HintArray + HintsCount;
215 while (HintArray != LastHint)
216 {
217 if (HintArray->CmdId == CmdId)
218 {
219 HintId = HintArray->HintId;
220 Found = true;
221 break;
222 }
223 HintArray++;
224 }
225
229 HintId);
230
231 return Found;
232}
return Found
Definition: dirsup.c:1270
bool StatusBarLoadString(_In_ HWND hStatusBar, _In_ INT PartId, _In_ HINSTANCE hInstance, _In_ UINT uID)
Definition: MainWindow.cpp:410
#define SB_SIMPLEID
Definition: precomp.h:15
unsigned int UINT
Definition: ndis.h:50
UINT HintId
Definition: precomp.h:90

◆ MainWndProc()

LRESULT CALLBACK CDeviceManager::MainWndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 714 of file MainWindow.cpp.

718{
720 LRESULT RetCode = 0;
721
722 // Get the object pointer from window context
724 if (This == NULL)
725 {
726 // Check that this isn't a create message
727 if (msg != WM_CREATE)
728 {
729 // Don't handle null info pointer
730 goto HandleDefaultMessage;
731 }
732 }
733
734 switch(msg)
735 {
736 case WM_CREATE:
737 {
738 // Get the object pointer from the create param
739 This = (CDeviceManager *)((LPCREATESTRUCT)lParam)->lpCreateParams;
740
741 // Store the pointer in the window's global user data
743
744 // Call the create handler
745 RetCode = This->OnCreate(hwnd);
746 break;
747 }
748
749 case WM_SIZE:
750 {
751 RetCode = This->OnSize();
752 break;
753 }
754
755 case WM_NOTIFY:
756 {
757 RetCode = This->OnNotify(lParam);
758 break;
759 }
760
761 case WM_CONTEXTMENU:
762 {
763 RetCode = This->OnContext(lParam);
764 break;
765 }
766
767 case WM_MENUSELECT:
768 {
769 if (This->m_hStatusBar != NULL)
770 {
771 if (!This->MainWndMenuHint(LOWORD(wParam),
773 sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]),
775 {
776 This->MainWndMenuHint(LOWORD(wParam),
778 sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]),
780 }
781 }
782
783 break;
784 }
785
786 case WM_COMMAND:
787 {
788 // Handle the command message
789 RetCode = This->OnCommand(wParam, lParam);
790 if (RetCode == -1)
791 {
792 // Hand it off to the default message handler
793 goto HandleDefaultMessage;
794 }
795 break;
796 }
797
798 case WM_DEVICECHANGE:
799 {
801 {
802 //
803 // The OS can send multiple change messages in quick succession. To avoid
804 // refreshing multiple times (and to avoid waiting in the message thread)
805 // we set a timer to run in 500ms, which should leave enough time for all
806 // the messages to come through. Wrap so we don't set multiple timers
807 //
808 if (InterlockedCompareExchange((LONG *)&This->m_RefreshPending, TRUE, FALSE) == FALSE)
809 {
811 }
812 }
813 break;
814 }
815
816 case WM_TIMER:
817 {
818 if (wParam == REFRESH_TIMER)
819 {
820 // Schedule a refresh (this just creates a thread and returns)
821 This->RefreshView(This->m_DeviceView->GetCurrentView(), true);
822
823 // Cleanup the timer
825
826 // Allow more change notifications
827 InterlockedExchange((LONG *)&This->m_RefreshPending, FALSE);
828 }
829 break;
830 }
831
832 case WM_ENTERMENULOOP:
833 {
834 This->UpdateStatusBar(true);
835 break;
836 }
837
838 case WM_EXITMENULOOP:
839 {
840 This->UpdateStatusBar(false);
841 break;
842 }
843
844 case WM_CLOSE:
845 {
846 // Destroy the main window
848 break;
849 }
850
851 case WM_ACTIVATE:
852 {
853 if (LOWORD(hwnd))
854 This->OnActivate();
855 break;
856 }
857
858 case WM_DESTROY:
859 {
860 // Call the destroy handler
861 RetCode = This->OnDestroy();
862 break;
863 }
864
865 default:
866 {
867HandleDefaultMessage:
868 RetCode = DefWindowProc(hwnd, msg, wParam, lParam);
869 break;
870 }
871 }
872
873 return RetCode;
874}
#define InterlockedExchange
Definition: armddk.h:54
#define msg(x)
Definition: auth_time.c:54
static const MENU_HINT SystemMenuHintTable[]
Definition: mainwnd.c:70
static const MENU_HINT MainMenuHintTable[]
Definition: mainwnd.c:40
#define IDS_HINT_BLANK
Definition: resource.h:92
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define DBT_DEVNODES_CHANGED
Definition: dbt.h:28
#define REFRESH_TIMER
Definition: MainWindow.cpp:23
#define InterlockedCompareExchange
Definition: interlocked.h:104
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_NOTIFY
Definition: richedit.h:61
#define DefWindowProc
Definition: ros2win.h:31
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_USERDATA
Definition: treelist.c:63
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_CLOSE
Definition: winuser.h:1621
#define WM_CREATE
Definition: winuser.h:1608
#define WM_SIZE
Definition: winuser.h:1611
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_DEVICECHANGE
Definition: winuser.h:1811
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_ACTIVATE
Definition: winuser.h:1612
#define WM_ENTERMENULOOP
Definition: winuser.h:1804
#define WM_TIMER
Definition: winuser.h:1742
#define WM_EXITMENULOOP
Definition: winuser.h:1805
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define WM_MENUSELECT
Definition: winuser.h:1747
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by Initialize().

◆ OnActivate()

void CDeviceManager::OnActivate ( void  )
private

Definition at line 689 of file MainWindow.cpp.

690{
692}
CDeviceView * m_DeviceView
Definition: MainWindow.h:13
VOID SetFocus()
Definition: DeviceView.cpp:319

◆ OnCommand()

LRESULT CDeviceManager::OnCommand ( _In_ WPARAM  wParam,
LPARAM  lParam 
)
private

Definition at line 575 of file MainWindow.cpp.

577{
578 LRESULT RetCode = 0;
579 WORD Msg;
580
581 // Get the message
582 Msg = LOWORD(wParam);
583
584 switch (Msg)
585 {
586 case IDM_PROPERTIES:
588 case IDM_ENABLE_DRV:
589 case IDM_DISABLE_DRV:
590 case IDM_UPDATE_DRV:
592 case IDM_ADD_HARDWARE:
593 {
595 break;
596 }
597
598 case IDM_ACTIONMENU:
599 {
600 // Create a popup menu with all the actions for the selected node
601 HMENU hMenu = CreatePopupMenu();
602 m_DeviceView->CreateActionMenu(hMenu, true);
603
604 // Calculate where to put the menu
605 RECT rc;
607 LONG Height = rc.bottom - rc.top;
608
609 // Display the menu
610 TrackPopupMenuEx(hMenu,
612 rc.left,
613 rc.top + Height,
615 NULL);
616
617 DestroyMenu(hMenu);
618 break;
619 }
620
621 case IDM_DEVBYTYPE:
622 {
624 break;
625 }
626
627 case IDM_DEVBYCONN:
628 {
630 break;
631 }
632
633 case IDM_SHOWHIDDEN:
634 {
635 // Get the current state
637 if (CurCheckState == MF_CHECKED)
638 {
641 }
642 else if (CurCheckState == MF_UNCHECKED)
643 {
646 }
647 // Refresh the device view
649 break;
650 }
651
652 case IDM_ABOUT:
653 {
655 CAtlStringW szAppAuthors;
656
657 if (!szAppName.LoadStringW(g_hThisInstance, IDS_APPNAME))
658 szAppName = L"ReactOS Device Manager";
659 if (!szAppAuthors.LoadStringW(g_hThisInstance, IDS_APP_AUTHORS))
660 szAppAuthors = L"";
661 ShellAboutW(m_hMainWnd, szAppName, szAppAuthors,
663
664 // Set focus back to the treeview
666 break;
667 }
668
669 case IDM_EXIT:
670 {
671 // Post a close message to the window
673 WM_CLOSE,
674 0,
675 0);
676 break;
677 }
678
679 default:
680 // We didn't handle it
681 RetCode = -1;
682 break;
683 }
684
685 return RetCode;
686}
@ DevicesByConnection
Definition: DeviceView.h:9
@ DevicesByType
Definition: DeviceView.h:8
#define IDM_ABOUT
Definition: resource.h:29
#define IDM_EXIT
Definition: resource.h:27
#define IDS_APP_AUTHORS
Definition: resource.h:120
#define IDM_PROPERTIES
Definition: resources.h:9
bool RefreshView(_In_ ViewType Type, _In_ bool ScanForChanges)
Definition: MainWindow.cpp:244
VOID SetHiddenDevices(_In_ bool ShowHidden)
Definition: DeviceView.h:73
ViewType GetCurrentView()
Definition: DeviceView.h:78
LRESULT OnAction(UINT Action)
Definition: DeviceView.cpp:243
bool CreateActionMenu(_In_ HMENU OwnerMenu, _In_ bool MainMenu)
Definition: DeviceView.cpp:325
struct @1632 Msg[]
#define IDM_UPDATE_DRV
Definition: resource.h:26
#define IDM_SHOWHIDDEN
Definition: resource.h:41
#define IDM_SCAN_HARDWARE
Definition: resource.h:23
#define IDM_DEVBYTYPE
Definition: resource.h:37
#define IDM_UNINSTALL_DRV
Definition: resource.h:27
#define IDM_ENABLE_DRV
Definition: resource.h:24
#define IDM_DISABLE_DRV
Definition: resource.h:25
#define IDM_ACTIONMENU
Definition: resource.h:31
#define IDM_DEVBYCONN
Definition: resource.h:38
#define IDM_ADD_HARDWARE
Definition: resource.h:28
unsigned short WORD
Definition: ntddk_ex.h:93
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define MF_BYCOMMAND
Definition: winuser.h:202
UINT WINAPI GetMenuState(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TPM_RIGHTBUTTON
Definition: winuser.h:2380
#define MF_CHECKED
Definition: winuser.h:132
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
#define MF_UNCHECKED
Definition: winuser.h:204
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI GetMenuItemRect(_In_opt_ HWND, _In_ HMENU, _In_ UINT, _Out_ LPRECT)
BOOL WINAPI DestroyMenu(_In_ HMENU)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2075

◆ OnContext()

LRESULT CDeviceManager::OnContext ( _In_ LPARAM  lParam)
private

Definition at line 569 of file MainWindow.cpp.

570{
572}
LRESULT OnContextMenu(_In_ LPARAM lParam)
Definition: DeviceView.cpp:169

◆ OnCreate()

LRESULT CDeviceManager::OnCreate ( _In_ HWND  hwnd)
private

Definition at line 432 of file MainWindow.cpp.

433{
434 LRESULT RetCode;
435
436 RetCode = -1;
438
439 // Store a handle to the main menu
441
442 // Create the toolbar and statusbar
444 {
445 // Create the device view object
448 {
449 // Do the initial scan
451
452 // Display the window according to the user request
454 RetCode = 0;
455 }
456 }
457
458 return RetCode;
459}
bool CreateStatusBar(void)
Definition: MainWindow.cpp:337
bool CreateToolBar(void)
Definition: MainWindow.cpp:287
bool Initialize()
Definition: DeviceView.cpp:54
HMENU WINAPI GetMenu(_In_ HWND)

◆ OnDestroy()

LRESULT CDeviceManager::OnDestroy ( void  )
private

Definition at line 695 of file MainWindow.cpp.

696{
697 // Uninitialize the device view
699
700 // Kill the object
701 delete m_DeviceView;
703
704 // Clear the user data pointer
706
707 // Break the message loop
709
710 return 0;
711}
bool Uninitialize()
Definition: DeviceView.cpp:94
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

◆ OnNotify()

LRESULT CDeviceManager::OnNotify ( _In_ LPARAM  lParam)
private

Definition at line 497 of file MainWindow.cpp.

498{
499 LPNMHDR NmHdr = (LPNMHDR)lParam;
500 LRESULT Ret = 0;
501
502 switch (NmHdr->code)
503 {
504 case TVN_SELCHANGED:
505 {
506 HMENU hMenu = GetSubMenu(m_hMenu, 1);
507 for (INT i = GetMenuItemCount(hMenu) - 1; i >= 0; i--)
508 {
509 DeleteMenu(hMenu, i, MF_BYPOSITION);
510 }
511 m_DeviceView->CreateActionMenu(hMenu, true);
513 break;
514 }
515
516 case NM_DBLCLK:
517 {
518 Ret = m_DeviceView->OnDoubleClick(NmHdr);
519 break;
520 }
521
522 case NM_RCLICK:
523 {
524 Ret = m_DeviceView->OnRightClick(NmHdr);
525 break;
526 }
527
528 case NM_RETURN:
529 {
531 break;
532 }
533
534 case TTN_GETDISPINFO:
535 {
537 lpttt->hinst = g_hThisInstance;
538
539 UINT_PTR idButton = lpttt->hdr.idFrom;
540 switch (idButton)
541 {
542 case IDM_PROPERTIES:
543 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_PROPERTIES);
544 break;
546 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_SCAN);
547 break;
548 case IDM_ENABLE_DRV:
549 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_ENABLE);
550 break;
551 case IDM_DISABLE_DRV:
552 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_DISABLE);
553 break;
554 case IDM_UPDATE_DRV:
555 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UPDATE);
556 break;
558 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UNINSTALL);
559 break;
560 }
561 break;
562 }
563 }
564
565 return Ret;
566}
#define IDS_TOOLTIP_UNINSTALL
Definition: resource.h:128
void UpdateToolbar(void)
Definition: MainWindow.cpp:364
VOID DisplayPropertySheet()
Definition: DeviceView.cpp:305
LRESULT OnRightClick(_In_ LPNMHDR NmHdr)
Definition: DeviceView.cpp:149
LRESULT OnDoubleClick(_In_ LPNMHDR NmHdr)
Definition: DeviceView.cpp:128
#define IDS_TOOLTIP_PROPERTIES
Definition: resource.h:45
#define IDS_TOOLTIP_SCAN
Definition: resource.h:46
#define IDS_TOOLTIP_DISABLE
Definition: resource.h:48
#define IDS_TOOLTIP_UPDATE
Definition: resource.h:49
#define IDS_TOOLTIP_ENABLE
Definition: resource.h:47
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define TVN_SELCHANGED
Definition: commctrl.h:3735
#define NM_DBLCLK
Definition: commctrl.h:131
#define TTN_GETDISPINFO
Definition: commctrl.h:1878
#define NM_RETURN
Definition: commctrl.h:132
#define NM_RCLICK
Definition: commctrl.h:133
#define LPTOOLTIPTEXT
Definition: commctrl.h:1890
UINT code
Definition: winuser.h:3159
int32_t INT
Definition: typedefs.h:58
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MF_BYPOSITION
Definition: winuser.h:203
struct tagNMHDR * LPNMHDR

◆ OnSize()

LRESULT CDeviceManager::OnSize ( void  )
private

Definition at line 462 of file MainWindow.cpp.

463{
464 RECT rcClient, rcTool, rcStatus;
465 INT lvHeight, iToolHeight, iStatusHeight;
466
467 // Autosize the toolbar
469
470 // Get the toolbar rect and save the height
471 GetWindowRect(m_hToolBar, &rcTool);
472 iToolHeight = rcTool.bottom - rcTool.top;
473
474 // Resize the status bar
476
477 // Get the statusbar rect and save the height
478 GetWindowRect(m_hStatusBar, &rcStatus);
479 iStatusHeight = rcStatus.bottom - rcStatus.top;
480
481 // Get the full client rect
482 GetClientRect(m_hMainWnd, &rcClient);
483
484 // Calculate the remaining height for the treeview
485 lvHeight = rcClient.bottom - iToolHeight - iStatusHeight;
486
487 // Resize the device view
489 iToolHeight,
490 rcClient.right,
491 lvHeight);
492
493 return 0;
494}
LRESULT OnSize(_In_ int x, _In_ int y, _In_ int cx, _In_ int cy)
Definition: DeviceView.cpp:108
LONG right
Definition: windef.h:308
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SendMessage
Definition: winuser.h:5843

◆ RefreshView()

bool CDeviceManager::RefreshView ( _In_ ViewType  Type,
_In_ bool  ScanForChanges 
)
private

Definition at line 244 of file MainWindow.cpp.

246{
247 UINT CheckId = 0;
248
249 // Refreshed the cached view
250 m_DeviceView->Refresh(Type, ScanForChanges, true);
251
252 // Get the menu item id
253 switch (Type)
254 {
255 case DevicesByType:
256 CheckId = IDM_DEVBYTYPE;
257 break;
258
260 CheckId = IDM_DEVBYCONN;
261 break;
262
263 case ResourcesByType:
264 CheckId = IDM_RESBYTYPE;
265 break;
266
268 CheckId = IDM_RESBYCONN;
269 break;
270
271 default:
273 break;
274 }
275
276 // Set the new check item
280 CheckId,
282
283 return true;
284}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
@ ResourcesByType
Definition: DeviceView.h:10
@ ResourcesByConnection
Definition: DeviceView.h:11
Type
Definition: Type.h:7
VOID Refresh(_In_ ViewType Type, _In_ bool ScanForChanges, _In_ bool UpdateView)
Definition: DeviceView.cpp:216
#define IDM_RESBYCONN
Definition: resource.h:40
#define IDM_RESBYTYPE
Definition: resource.h:39
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)

Referenced by OnCommand(), and OnCreate().

◆ Run()

int CDeviceManager::Run ( void  )
private

Definition at line 190 of file MainWindow.cpp.

191{
192 MSG Msg;
193
194 // Pump the message queue
195 while (GetMessageW(&Msg, NULL, 0, 0 ) != 0)
196 {
199 }
200
201 return 0;
202}
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)

Referenced by Create().

◆ StatusBarLoadString()

bool CDeviceManager::StatusBarLoadString ( _In_ HWND  hStatusBar,
_In_ INT  PartId,
_In_ HINSTANCE  hInstance,
_In_ UINT  uID 
)
private

Definition at line 410 of file MainWindow.cpp.

414{
415 CAtlStringW szMessage;
416 bool bRet = false;
417
418 // Load the string
419 if (szMessage.LoadStringW(hInstance, uID))
420 {
421 // Show the string on the status bar
422 bRet = (SendMessageW(hStatusBar,
424 (WPARAM)PartId,
425 (LPARAM)szMessage.GetBuffer()) != 0);
426 }
427
428 return bRet;
429}
HWND hStatusBar
Definition: main.c:36
HINSTANCE hInstance
Definition: charmap.c:19
#define SB_SETTEXT
Definition: commctrl.h:1949
UINT_PTR WPARAM
Definition: windef.h:207

Referenced by MainWndMenuHint().

◆ Uninitialize()

void CDeviceManager::Uninitialize ( void  )
private

Definition at line 183 of file MainWindow.cpp.

184{
185 // Unregister the window class
187}
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)

Referenced by Create().

◆ UpdateStatusBar()

void CDeviceManager::UpdateStatusBar ( _In_ bool  InMenuLoop)
private

Definition at line 235 of file MainWindow.cpp.

236{
238 SB_SIMPLE,
239 (WPARAM)InMenuLoop,
240 0);
241}
#define SB_SIMPLE
Definition: commctrl.h:1958

◆ UpdateToolbar()

void CDeviceManager::UpdateToolbar ( void  )
private

Definition at line 364 of file MainWindow.cpp.

365{
366 WORD State;
367
369
370 // properties button
371 if (Node->HasProperties())
372 {
374 }
375 else
376 {
378 }
382
383 // enable driver button
384 if (Node->GetNodeType() == DeviceNode &&
385 dynamic_cast<CDeviceNode *>(Node)->IsDisabled())
386 {
388 }
389 else
390 {
392 }
394
395 // disable driver button
396 if (Node->GetNodeType() == DeviceNode &&
397 dynamic_cast<CDeviceNode *>(Node)->CanDisable() &&
398 !dynamic_cast<CDeviceNode *>(Node)->IsDisabled())
399 {
401 }
402 else
403 {
405 }
407}
@ DeviceNode
Definition: Node.h:9
virtual bool IsDisabled()
Definition: DeviceNode.cpp:219
bool CanDisable()
Definition: DeviceNode.cpp:202
CNode * GetSelectedNode()
Definition: DeviceView.cpp:341
Definition: Node.h:13
#define TB_SETSTATE
Definition: commctrl.h:1054
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TBSTATE_HIDDEN
Definition: commctrl.h:975
Definition: dlist.c:348
#define MAKELPARAM(l, h)
Definition: winuser.h:4008

Referenced by OnNotify().

Member Data Documentation

◆ m_CmdShow

int CDeviceManager::m_CmdShow
private

Definition at line 18 of file MainWindow.h.

Referenced by Initialize(), and OnCreate().

◆ m_DeviceView

CDeviceView* CDeviceManager::m_DeviceView
private

◆ m_hMainWnd

HWND CDeviceManager::m_hMainWnd
private

◆ m_hMenu

HMENU CDeviceManager::m_hMenu
private

Definition at line 17 of file MainWindow.h.

Referenced by OnCommand(), OnCreate(), OnNotify(), and RefreshView().

◆ m_hStatusBar

HWND CDeviceManager::m_hStatusBar
private

Definition at line 15 of file MainWindow.h.

Referenced by CreateStatusBar(), MainWndMenuHint(), OnSize(), and UpdateStatusBar().

◆ m_hToolBar

HWND CDeviceManager::m_hToolBar
private

Definition at line 16 of file MainWindow.h.

Referenced by CreateToolBar(), OnSize(), and UpdateToolbar().

◆ m_RefreshPending

BOOL CDeviceManager::m_RefreshPending
private

Definition at line 19 of file MainWindow.h.

◆ m_szMainWndClass

CAtlStringW CDeviceManager::m_szMainWndClass
private

Definition at line 12 of file MainWindow.h.

Referenced by CDeviceManager(), Initialize(), and Uninitialize().


The documentation for this class was generated from the following files: