ReactOS 0.4.17-dev-1190-g4c812f4
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
 
CDeviceView * m_DeviceView
 
HWND m_hMainWnd
 
HWND m_hStatusBar
 
HWND m_hToolBar
 
HMENU m_hMenu
 
int m_CmdShow
 
BOOL m_RefreshPending
 
bool m_ClosePending
 

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 m_ClosePending(false)
87{
88 m_szMainWndClass = L"DevMgmtWndClass";
89}
BOOL m_RefreshPending
Definition: MainWindow.h:19
HWND m_hStatusBar
Definition: MainWindow.h:15
CAtlStringW m_szMainWndClass
Definition: MainWindow.h:12
bool m_ClosePending
Definition: MainWindow.h:20
#define NULL
Definition: types.h:112
#define L(x)
Definition: resources.c:13

◆ ~CDeviceManager()

CDeviceManager::~CDeviceManager ( void  )

Definition at line 91 of file MainWindow.cpp.

92{
93}

Member Function Documentation

◆ Create()

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

Definition at line 96 of file MainWindow.cpp.

100{
101 CDeviceManager MainWindow;
104 int Ret = 1;
105
106 // Store the instances
108 g_hThisInstance = GetModuleHandleW(L"devmgr.dll");
109
110 // Initialize common controls
111 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
114
115 // Load the application name
116 if (szAppName.LoadStringW(g_hThisInstance, IDS_APPNAME))
117 {
118 // Initialize the main window
119 if (MainWindow.Initialize(szAppName, nCmdShow))
120 {
121 // Run the application
122 Ret = MainWindow.Run();
123
124 // Uninitialize the main window
125 MainWindow.Uninitialize();
126 }
127 }
128
129 return (Ret == 0);
130}
#define IDS_APPNAME
Definition: resource.h:52
void Uninitialize(void)
Definition: MainWindow.cpp:184
bool Initialize(_In_z_ LPCTSTR lpCaption, _In_ int nCmdShow)
Definition: MainWindow.cpp:136
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:904
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 338 of file MainWindow.cpp.

339{
340 int StatWidths[] = {110, -1}; // widths of status bar
341 bool bRet = FALSE;
342
343 // Create the status bar
346 NULL,
348 0, 0, 0, 0,
352 NULL);
353 if (m_hStatusBar)
354 {
355 // Set the width
358 sizeof(StatWidths) / sizeof(int),
359 (LPARAM)StatWidths) != 0);
360 }
361
362 return bRet;
363}
#define IDC_STATUSBAR
Definition: resource.h:12
#define FALSE
Definition: types.h:117
LONG_PTR LPARAM
Definition: minwindef.h:175
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define SB_SETPARTS
Definition: commctrl.h:1959
#define SBARS_SIZEGRIP
Definition: commctrl.h:1928
#define STATUSCLASSNAME
Definition: commctrl.h:1944
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 288 of file MainWindow.cpp.

289{
290 TBADDBITMAP TbAddBitmap;
291
294
295 // Create the toolbar window
296 m_hToolBar = CreateWindowExW(dwExStyles,
298 NULL,
299 dwStyles,
300 0, 0, 0, 0,
304 NULL);
305 if (m_hToolBar == NULL)
306 return FALSE;
307
308 // Don't show clipped buttons
311 0,
313
315
316 // Set the struct size, the toobar needs this...
319 sizeof(TBBUTTON),
320 0);
321
322 TbAddBitmap.hInst = g_hThisInstance;
323 TbAddBitmap.nID = IDB_TOOLBAR;
325
328
329 if (TRUE)
330 {
332 }
333
334 return TRUE;
335}
static TBBUTTON TbButtons[]
Definition: CMainWnd.cpp:12
#define IDB_TOOLBAR
Definition: resource.h:19
#define TRUE
Definition: types.h:120
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:2253
#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
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:786
#define WS_EX_LEFT
Definition: winuser.h:391
#define _countof(array)
Definition: sndvol32.h:70
UINT_PTR nID
Definition: commctrl.h:1060
HINSTANCE hInst
Definition: commctrl.h:1059
#define MAKELONG(a, b)
Definition: typedefs.h:249
#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 136 of file MainWindow.cpp.

138{
139 CAtlStringW szCaption;
140 WNDCLASSEXW wc = {0};
141
142 // Store the show window value
143 m_CmdShow = nCmdShow;
144
145 // Setup the window class struct
146 wc.cbSize = sizeof(WNDCLASSEXW);
151 wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
159 0);
160
161 // Register the window
162 if (RegisterClassExW(&wc))
163 {
164 // Create the main window and store the object pointer
167 lpCaption,
171 550,
172 500,
173 NULL,
174 NULL,
176 this);
177 }
178
179 // Return creation result
180 return !!(m_hMainWnd);
181}
#define IDM_MAINMENU
Definition: resources.h:3
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: MainWindow.cpp:721
#define IDI_MAIN_ICON
Definition: resource.h:8
static HICON
Definition: imagelist.c:80
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define IMAGE_ICON
Definition: winuser.h:212
#define IDC_ARROW
Definition: winuser.h:695
#define SM_CYSMICON
Definition: winuser.h:1024
#define SM_CXSMICON
Definition: winuser.h:1023
#define LoadIcon
Definition: winuser.h:5979
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define LoadCursor
Definition: winuser.h:5978
#define CW_USEDEFAULT
Definition: winuser.h:225
#define LoadImage
Definition: winuser.h:5981
struct _WNDCLASSEXW WNDCLASSEXW
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
int WINAPI GetSystemMetrics(_In_ int)
#define COLOR_BTNFACE
Definition: winuser.h:939
LPCWSTR lpszClassName
Definition: winuser.h:3334
LPCWSTR lpszMenuName
Definition: winuser.h:3333
HBRUSH hbrBackground
Definition: winuser.h:3332
WNDPROC lpfnWndProc
Definition: winuser.h:3326
UINT cbSize
Definition: winuser.h:3324
HCURSOR hCursor
Definition: winuser.h:3331
HICON hIconSm
Definition: winuser.h:3335
HINSTANCE hInstance
Definition: winuser.h:3329
HICON hIcon
Definition: winuser.h:3330

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 206 of file MainWindow.cpp.

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

◆ MainWndProc()

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

Definition at line 721 of file MainWindow.cpp.

725{
727 LRESULT RetCode = 0;
728
729 // Get the object pointer from window context
731 if (This == NULL)
732 {
733 // Check that this isn't a create message
734 if (msg != WM_CREATE)
735 {
736 // Don't handle null info pointer
737 goto HandleDefaultMessage;
738 }
739 }
740
741 switch(msg)
742 {
743 case WM_CREATE:
744 {
745 // Get the object pointer from the create param
746 This = (CDeviceManager *)((LPCREATESTRUCT)lParam)->lpCreateParams;
747
748 // Store the pointer in the window's global user data
750
751 // Call the create handler
752 RetCode = This->OnCreate(hwnd);
753 break;
754 }
755
756 case WM_SIZE:
757 {
758 RetCode = This->OnSize();
759 break;
760 }
761
762 case WM_NOTIFY:
763 {
764 RetCode = This->OnNotify(lParam);
765 break;
766 }
767
768 case WM_CONTEXTMENU:
769 {
770 RetCode = This->OnContext(lParam);
771 break;
772 }
773
774 case WM_MENUSELECT:
775 {
776 if (This->m_hStatusBar != NULL)
777 {
778 if (!This->MainWndMenuHint(LOWORD(wParam),
780 sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]),
782 {
783 This->MainWndMenuHint(LOWORD(wParam),
785 sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]),
787 }
788 }
789
790 break;
791 }
792
793 case WM_COMMAND:
794 {
795 // Handle the command message
796 RetCode = This->OnCommand(wParam, lParam);
797 if (RetCode == -1)
798 {
799 // Hand it off to the default message handler
800 goto HandleDefaultMessage;
801 }
802 break;
803 }
804
805 case WM_DEVICECHANGE:
806 {
808 {
809 //
810 // The OS can send multiple change messages in quick succession. To avoid
811 // refreshing multiple times (and to avoid waiting in the message thread)
812 // we set a timer to run in 500ms, which should leave enough time for all
813 // the messages to come through. Wrap so we don't set multiple timers
814 //
815 if (InterlockedCompareExchange((LONG *)&This->m_RefreshPending, TRUE, FALSE) == FALSE)
816 {
818 }
819 }
820 break;
821 }
822
823 case WM_TIMER:
824 {
825 if (wParam == REFRESH_TIMER)
826 {
827 // Schedule a refresh (this just creates a thread and returns)
828 This->RefreshView(This->m_DeviceView->GetCurrentView(), true);
829
830 // Cleanup the timer
832
833 // Allow more change notifications
834 InterlockedExchange((LONG *)&This->m_RefreshPending, FALSE);
835 }
836 break;
837 }
838
840 {
841 This->m_DeviceView->OnRefreshComplete();
842
843 if (This->m_ClosePending && !This->m_DeviceView->IsRefreshing())
845 break;
846 }
847
848 case WM_ENTERMENULOOP:
849 {
850 This->UpdateStatusBar(true);
851 break;
852 }
853
854 case WM_EXITMENULOOP:
855 {
856 This->UpdateStatusBar(false);
857 break;
858 }
859
860 case WM_CLOSE:
861 {
862 // The refresh thread still uses the device view, so close once it posts back
863 if (This->m_DeviceView->IsRefreshing())
864 {
865 This->m_ClosePending = true;
866 break;
867 }
868
869 // Destroy the main window
871 break;
872 }
873
874 case WM_ACTIVATE:
875 {
876 if (LOWORD(hwnd))
877 This->OnActivate();
878 break;
879 }
880
881 case WM_DESTROY:
882 {
883 // Call the destroy handler
884 RetCode = This->OnDestroy();
885 break;
886 }
887
888 default:
889 {
890HandleDefaultMessage:
891 RetCode = DefWindowProc(hwnd, msg, wParam, lParam);
892 break;
893 }
894 }
895
896 return RetCode;
897}
#define WM_REFRESH_COMPLETE
Definition: DeviceView.h:16
#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:119
LONG_PTR LRESULT
Definition: minwindef.h:176
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
#define WM_CLOSE
Definition: winuser.h:1649
#define WM_CREATE
Definition: winuser.h:1636
#define WM_SIZE
Definition: winuser.h:1639
#define WM_COMMAND
Definition: winuser.h:1768
#define WM_DEVICECHANGE
Definition: winuser.h:1839
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_ACTIVATE
Definition: winuser.h:1640
#define WM_ENTERMENULOOP
Definition: winuser.h:1832
#define WM_TIMER
Definition: winuser.h:1770
#define WM_EXITMENULOOP
Definition: winuser.h:1833
#define WM_DESTROY
Definition: winuser.h:1637
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define WM_MENUSELECT
Definition: winuser.h:1775
BOOL WINAPI DestroyWindow(_In_ HWND)
#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

Referenced by Initialize().

◆ OnActivate()

void CDeviceManager::OnActivate ( void  )
private

Definition at line 696 of file MainWindow.cpp.

697{
699}
CDeviceView * m_DeviceView
Definition: MainWindow.h:13
VOID SetFocus()
Definition: DeviceView.cpp:330

◆ OnCommand()

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

Definition at line 576 of file MainWindow.cpp.

578{
579 LRESULT RetCode = 0;
580 WORD Msg;
581
582 // Get the message
583 Msg = LOWORD(wParam);
584
585 switch (Msg)
586 {
587 case IDM_PROPERTIES:
589 case IDM_ENABLE_DRV:
590 case IDM_DISABLE_DRV:
591 case IDM_UPDATE_DRV:
593 case IDM_ADD_HARDWARE:
594 {
596 break;
597 }
598
599 case IDM_ACTIONMENU:
600 {
601 // Create a popup menu with all the actions for the selected node
602 HMENU hMenu = CreatePopupMenu();
603 m_DeviceView->CreateActionMenu(hMenu, true);
604
605 // Calculate where to put the menu
606 RECT rc;
608 LONG Height = rc.bottom - rc.top;
609
610 // Display the menu
611 TrackPopupMenuEx(hMenu,
613 rc.left,
614 rc.top + Height,
616 NULL);
617
618 DestroyMenu(hMenu);
619 break;
620 }
621
622 case IDM_DEVBYTYPE:
623 {
625 break;
626 }
627
628 case IDM_DEVBYCONN:
629 {
631 break;
632 }
633
634 case IDM_RESBYTYPE:
635 {
637 break;
638 }
639
640 case IDM_SHOWHIDDEN:
641 {
642 // Get the current state
644 if (CurCheckState == MF_CHECKED)
645 {
648 }
649 else if (CurCheckState == MF_UNCHECKED)
650 {
653 }
654 // Refresh the device view
656 break;
657 }
658
659 case IDM_ABOUT:
660 {
662 CAtlStringW szAppAuthors;
663
664 if (!szAppName.LoadStringW(g_hThisInstance, IDS_APPNAME))
665 szAppName = L"ReactOS Device Manager";
666 if (!szAppAuthors.LoadStringW(g_hThisInstance, IDS_APP_AUTHORS))
667 szAppAuthors = L"";
668 ShellAboutW(m_hMainWnd, szAppName, szAppAuthors,
670
671 // Set focus back to the treeview
673 break;
674 }
675
676 case IDM_EXIT:
677 {
678 // Post a close message to the window
680 WM_CLOSE,
681 0,
682 0);
683 break;
684 }
685
686 default:
687 // We didn't handle it
688 RetCode = -1;
689 break;
690 }
691
692 return RetCode;
693}
@ DevicesByConnection
Definition: DeviceView.h:11
@ ResourcesByType
Definition: DeviceView.h:12
@ DevicesByType
Definition: DeviceView.h:10
#define IDM_ABOUT
Definition: resource.h:29
#define IDM_EXIT
Definition: resource.h:27
#define IDS_APP_AUTHORS
Definition: resource.h:93
#define IDM_PROPERTIES
Definition: resources.h:9
bool RefreshView(_In_ ViewType Type, _In_ bool ScanForChanges)
Definition: MainWindow.cpp:245
VOID SetHiddenDevices(_In_ bool ShowHidden)
Definition: DeviceView.h:81
ViewType GetCurrentView()
Definition: DeviceView.h:86
LRESULT OnAction(UINT Action)
Definition: DeviceView.cpp:254
bool CreateActionMenu(_In_ HMENU OwnerMenu, _In_ bool MainMenu)
Definition: DeviceView.cpp:336
struct @1898 Msg[]
_Check_return_ _In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS _Out_ UINT _Out_ UINT * Height
Definition: dispmprt.h:1445
#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
#define IDM_RESBYTYPE
Definition: resource.h:39
unsigned short WORD
Definition: ntddk_ex.h:93
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:2416
#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:2444
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29

◆ OnContext()

LRESULT CDeviceManager::OnContext ( _In_ LPARAM  lParam)
private

Definition at line 570 of file MainWindow.cpp.

571{
573}
LRESULT OnContextMenu(_In_ LPARAM lParam)
Definition: DeviceView.cpp:172

◆ OnCreate()

LRESULT CDeviceManager::OnCreate ( _In_ HWND  hwnd)
private

Definition at line 433 of file MainWindow.cpp.

434{
435 LRESULT RetCode;
436
437 RetCode = -1;
439
440 // Store a handle to the main menu
442
443 // Create the toolbar and statusbar
445 {
446 // Create the device view object
449 {
450 // Do the initial scan
452
453 // Display the window according to the user request
455 RetCode = 0;
456 }
457 }
458
459 return RetCode;
460}
bool CreateStatusBar(void)
Definition: MainWindow.cpp:338
bool CreateToolBar(void)
Definition: MainWindow.cpp:288
bool Initialize()
Definition: DeviceView.cpp:57
HMENU WINAPI GetMenu(_In_ HWND)

◆ OnDestroy()

LRESULT CDeviceManager::OnDestroy ( void  )
private

Definition at line 702 of file MainWindow.cpp.

703{
704 // Uninitialize the device view
706
707 // Kill the object
708 delete m_DeviceView;
710
711 // Clear the user data pointer
713
714 // Break the message loop
716
717 return 0;
718}
bool Uninitialize()
Definition: DeviceView.cpp:97
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

◆ OnNotify()

LRESULT CDeviceManager::OnNotify ( _In_ LPARAM  lParam)
private

Definition at line 498 of file MainWindow.cpp.

499{
500 LPNMHDR NmHdr = (LPNMHDR)lParam;
501 LRESULT Ret = 0;
502
503 switch (NmHdr->code)
504 {
505 case TVN_SELCHANGED:
506 {
507 HMENU hMenu = GetSubMenu(m_hMenu, 1);
508 for (INT i = GetMenuItemCount(hMenu) - 1; i >= 0; i--)
509 {
510 DeleteMenu(hMenu, i, MF_BYPOSITION);
511 }
512 m_DeviceView->CreateActionMenu(hMenu, true);
514 break;
515 }
516
517 case NM_DBLCLK:
518 {
519 Ret = m_DeviceView->OnDoubleClick(NmHdr);
520 break;
521 }
522
523 case NM_RCLICK:
524 {
525 Ret = m_DeviceView->OnRightClick(NmHdr);
526 break;
527 }
528
529 case NM_RETURN:
530 {
532 break;
533 }
534
535 case TTN_GETDISPINFO:
536 {
538 lpttt->hinst = g_hThisInstance;
539
540 UINT_PTR idButton = lpttt->hdr.idFrom;
541 switch (idButton)
542 {
543 case IDM_PROPERTIES:
544 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_PROPERTIES);
545 break;
547 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_SCAN);
548 break;
549 case IDM_ENABLE_DRV:
550 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_ENABLE);
551 break;
552 case IDM_DISABLE_DRV:
553 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_DISABLE);
554 break;
555 case IDM_UPDATE_DRV:
556 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UPDATE);
557 break;
559 lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UNINSTALL);
560 break;
561 }
562 break;
563 }
564 }
565
566 return Ret;
567}
#define IDS_TOOLTIP_UNINSTALL
Definition: resource.h:138
void UpdateToolbar(void)
Definition: MainWindow.cpp:365
VOID DisplayPropertySheet()
Definition: DeviceView.cpp:316
LRESULT OnRightClick(_In_ LPNMHDR NmHdr)
Definition: DeviceView.cpp:152
LRESULT OnDoubleClick(_In_ LPNMHDR NmHdr)
Definition: DeviceView.cpp:131
#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:3740
#define NM_DBLCLK
Definition: commctrl.h:131
#define TTN_GETDISPINFO
Definition: commctrl.h:1883
#define NM_RETURN
Definition: commctrl.h:132
#define NM_RCLICK
Definition: commctrl.h:133
#define LPTOOLTIPTEXT
Definition: commctrl.h:1895
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
UINT code
Definition: winuser.h:3267
int32_t INT
Definition: typedefs.h:58

◆ OnSize()

LRESULT CDeviceManager::OnSize ( void  )
private

Definition at line 463 of file MainWindow.cpp.

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

◆ RefreshView()

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

Definition at line 245 of file MainWindow.cpp.

247{
248 UINT CheckId = 0;
249
250 // Refreshed the cached view
251 m_DeviceView->Refresh(Type, ScanForChanges, true);
252
253 // Get the menu item id
254 switch (Type)
255 {
256 case DevicesByType:
257 CheckId = IDM_DEVBYTYPE;
258 break;
259
261 CheckId = IDM_DEVBYCONN;
262 break;
263
264 case ResourcesByType:
265 CheckId = IDM_RESBYTYPE;
266 break;
267
269 CheckId = IDM_RESBYCONN;
270 break;
271
272 default:
274 break;
275 }
276
277 // Set the new check item
281 CheckId,
283
284 return true;
285}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
@ ResourcesByConnection
Definition: DeviceView.h:13
Type
Definition: Type.h:7
VOID Refresh(_In_ ViewType Type, _In_ bool ScanForChanges, _In_ bool UpdateView)
Definition: DeviceView.cpp:219
#define IDM_RESBYCONN
Definition: resource.h:40
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 191 of file MainWindow.cpp.

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

Referenced by Create().

◆ StatusBarLoadString()

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

Definition at line 411 of file MainWindow.cpp.

415{
416 CAtlStringW szMessage;
417 bool bRet = false;
418
419 // Load the string
420 if (szMessage.LoadStringW(hInstance, uID))
421 {
422 // Show the string on the status bar
423 bRet = (SendMessageW(hStatusBar,
425 (WPARAM)PartId,
426 (LPARAM)szMessage.GetBuffer()) != 0);
427 }
428
429 return bRet;
430}
HWND hStatusBar
Definition: main.c:23
HINSTANCE hInstance
Definition: charmap.c:19
UINT_PTR WPARAM
Definition: minwindef.h:174
#define SB_SETTEXT
Definition: commctrl.h:1954
_In_ UINT uID
Definition: shlwapi.h:156

Referenced by MainWndMenuHint().

◆ Uninitialize()

void CDeviceManager::Uninitialize ( void  )
private

Definition at line 184 of file MainWindow.cpp.

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

Referenced by Create().

◆ UpdateStatusBar()

void CDeviceManager::UpdateStatusBar ( _In_ bool  InMenuLoop)
private

Definition at line 236 of file MainWindow.cpp.

237{
239 SB_SIMPLE,
240 (WPARAM)InMenuLoop,
241 0);
242}
#define SB_SIMPLE
Definition: commctrl.h:1963

◆ UpdateToolbar()

void CDeviceManager::UpdateToolbar ( void  )
private

Definition at line 365 of file MainWindow.cpp.

366{
367 WORD State;
368
370
371 // properties button
372 if (Node->HasProperties())
373 {
375 }
376 else
377 {
379 }
383
384 // enable driver button
385 if (Node->GetNodeType() == DeviceNode &&
386 dynamic_cast<CDeviceNode *>(Node)->IsDisabled())
387 {
389 }
390 else
391 {
393 }
395
396 // disable driver button
397 if (Node->GetNodeType() == DeviceNode &&
398 dynamic_cast<CDeviceNode *>(Node)->CanDisable() &&
399 !dynamic_cast<CDeviceNode *>(Node)->IsDisabled())
400 {
402 }
403 else
404 {
406 }
408}
@ DeviceNode
Definition: Node.h:9
virtual bool IsDisabled()
Definition: DeviceNode.cpp:219
bool CanDisable()
Definition: DeviceNode.cpp:202
CNode * GetSelectedNode()
Definition: DeviceView.cpp:352
Definition: Node.h:15
#define TB_SETSTATE
Definition: commctrl.h:1054
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TBSTATE_HIDDEN
Definition: commctrl.h:975
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
Definition: dlist.c:348

Referenced by OnNotify().

Member Data Documentation

◆ m_ClosePending

bool CDeviceManager::m_ClosePending
private

Definition at line 20 of file MainWindow.h.

◆ 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: