Author: gedmurphy
Date: Wed Jul 8 06:43:16 2015
New Revision: 68378
URL:
http://svn.reactos.org/svn/reactos?rev=68378&view=rev
Log:
[DEV[DEVMGR]
- Use the correct HINSTANCE in the dll. Fixes loading strings for tooltips, etc.
- Rename CMainWindow to CDeviceManager
- Fixup the decelerations and add missing SAL decoration
Modified:
trunk/reactos/dll/win32/devmgr_new/devmgmt/DeviceView.cpp
trunk/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.cpp
trunk/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.h
trunk/reactos/dll/win32/devmgr_new/devmgmt/RootNode.cpp
trunk/reactos/dll/win32/devmgr_new/devmgmt/devmgmt.h
Modified: trunk/reactos/dll/win32/devmgr_new/devmgmt/DeviceView.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/devmg…
==============================================================================
--- trunk/reactos/dll/win32/devmgr_new/devmgmt/DeviceView.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr_new/devmgmt/DeviceView.cpp [iso-8859-1] Wed Jul 8
06:43:16 2015
@@ -78,7 +78,7 @@
0, 0, 0, 0,
m_hMainWnd,
(HMENU)IDC_TREEVIEW,
- g_hInstance,
+ g_hThisInstance,
NULL);
if (m_hTreeView)
{
@@ -719,7 +719,7 @@
if (Enable == false)
{
CAtlStringW str;
- if (str.LoadStringW(g_hInstance, IDS_CONFIRM_DISABLE))
+ if (str.LoadStringW(g_hThisInstance, IDS_CONFIRM_DISABLE))
{
if (MessageBoxW(m_hMainWnd,
str,
@@ -840,7 +840,7 @@
if (DeviceNode->CanUpdate())
{
- String.LoadStringW(g_hInstance, IDS_MENU_UPDATE);
+ String.LoadStringW(g_hThisInstance, IDS_MENU_UPDATE);
MenuItemInfo.wID = IDC_UPDATE_DRV;
MenuItemInfo.dwTypeData = String.GetBuffer();
InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
@@ -849,7 +849,7 @@
if (DeviceNode->IsDisabled())
{
- String.LoadStringW(g_hInstance, IDS_MENU_ENABLE);
+ String.LoadStringW(g_hThisInstance, IDS_MENU_ENABLE);
MenuItemInfo.wID = IDC_ENABLE_DRV;
MenuItemInfo.dwTypeData = String.GetBuffer();
InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
@@ -858,7 +858,7 @@
if (DeviceNode->CanDisable() && !DeviceNode->IsDisabled())
{
- String.LoadStringW(g_hInstance, IDS_MENU_DISABLE);
+ String.LoadStringW(g_hThisInstance, IDS_MENU_DISABLE);
MenuItemInfo.wID = IDC_DISABLE_DRV;
MenuItemInfo.dwTypeData = String.GetBuffer();
InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
@@ -867,7 +867,7 @@
if (DeviceNode->CanUninstall())
{
- String.LoadStringW(g_hInstance, IDS_MENU_UNINSTALL);
+ String.LoadStringW(g_hThisInstance, IDS_MENU_UNINSTALL);
MenuItemInfo.wID = IDC_UNINSTALL_DRV;
MenuItemInfo.dwTypeData = String.GetBuffer();
InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
@@ -879,7 +879,7 @@
}
// All nodes have the scan option
- String.LoadStringW(g_hInstance, IDS_MENU_SCAN);
+ String.LoadStringW(g_hThisInstance, IDS_MENU_SCAN);
MenuItemInfo.wID = IDC_SCAN_HARDWARE;
MenuItemInfo.dwTypeData = String.GetBuffer();
InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
@@ -887,7 +887,7 @@
if ((Node->GetNodeType() == RootNode) || (MainMenu == true))
{
- String.LoadStringW(g_hInstance, IDS_MENU_ADD);
+ String.LoadStringW(g_hThisInstance, IDS_MENU_ADD);
MenuItemInfo.wID = IDC_ADD_HARDWARE;
MenuItemInfo.dwTypeData = String.GetBuffer();
InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
@@ -899,7 +899,7 @@
InsertMenuItemW(OwnerMenu, i, TRUE, &MenuSeperator);
i++;
- String.LoadStringW(g_hInstance, IDS_MENU_PROPERTIES);
+ String.LoadStringW(g_hThisInstance, IDS_MENU_PROPERTIES);
MenuItemInfo.wID = IDC_PROPERTIES;
MenuItemInfo.dwTypeData = String.GetBuffer();
InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
Modified: trunk/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/devmg…
==============================================================================
--- trunk/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.cpp [iso-8859-1] Wed Jul 8
06:43:16 2015
@@ -21,6 +21,8 @@
#define BTN_UPDATE_DRV 4
#define BTN_UNINSTALL_DRV 5
+HINSTANCE g_hThisInstance = NULL;
+HINSTANCE g_hParentInstance = NULL;
// menu hints
static const MENU_HINT MainMenuHintTable[] =
@@ -75,8 +77,7 @@
/* PUBLIC METHODS **********************************************/
-CMainWindow::CMainWindow(void) :
- m_ToolbarhImageList(NULL),
+CDeviceManager::CDeviceManager(void) :
m_hMainWnd(NULL),
m_hStatusBar(NULL),
m_hToolBar(NULL),
@@ -85,15 +86,55 @@
m_szMainWndClass = L"DevMgmtWndClass";
}
-CMainWindow::~CMainWindow(void)
-{
- // Destroy any previous list
- if (m_ToolbarhImageList) ImageList_Destroy(m_ToolbarhImageList);
-}
+CDeviceManager::~CDeviceManager(void)
+{
+}
+
bool
-CMainWindow::Initialize(LPCTSTR lpCaption,
- int nCmdShow)
+CDeviceManager::Create(_In_ HWND /*hWndParent*/,
+ _In_ HINSTANCE hInst,
+ _In_opt_z_ LPCWSTR /*lpMachineName*/,
+ _In_ int nCmdShow)
+{
+ CDeviceManager MainWindow;
+ INITCOMMONCONTROLSEX icex;
+ CAtlStringW szAppName;
+ int Ret = 1;
+
+ // Store the instances
+ g_hParentInstance = hInst;
+ g_hThisInstance = GetModuleHandleW(L"devmgr.dll");
+
+ // Initialize common controls
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ // Load the application name
+ if (szAppName.LoadStringW(g_hThisInstance, IDS_APPNAME))
+ {
+ // Initialize the main window
+ if (MainWindow.Initialize(szAppName, nCmdShow))
+ {
+ // Run the application
+ Ret = MainWindow.Run();
+
+ // Uninitialize the main window
+ MainWindow.Uninitialize();
+ }
+ }
+
+ return (Ret == 0);
+}
+
+
+
+/* PRIVATE METHODS **********************************************/
+
+bool
+CDeviceManager::Initialize(_In_z_ LPCTSTR lpCaption,
+ _In_ int nCmdShow)
{
CAtlStringW szCaption;
WNDCLASSEXW wc = {0};
@@ -104,13 +145,13 @@
// Setup the window class struct
wc.cbSize = sizeof(WNDCLASSEXW);
wc.lpfnWndProc = MainWndProc;
- wc.hInstance = g_hInstance;
- wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCEW(IDI_MAIN_ICON));
+ wc.hInstance = g_hThisInstance;
+ wc.hIcon = LoadIcon(g_hThisInstance, MAKEINTRESOURCEW(IDI_MAIN_ICON));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszMenuName = MAKEINTRESOURCEW(IDR_MAINMENU);
wc.lpszClassName = m_szMainWndClass;
- wc.hIconSm = (HICON)LoadImage(g_hInstance,
+ wc.hIconSm = (HICON)LoadImage(g_hThisInstance,
MAKEINTRESOURCE(IDI_MAIN_ICON),
IMAGE_ICON,
16,
@@ -131,7 +172,7 @@
500,
NULL,
NULL,
- g_hInstance,
+ g_hThisInstance,
this);
}
@@ -140,14 +181,14 @@
}
void
-CMainWindow::Uninitialize()
+CDeviceManager::Uninitialize(void)
{
// Unregister the window class
- UnregisterClassW(m_szMainWndClass, g_hInstance);
+ UnregisterClassW(m_szMainWndClass, g_hThisInstance);
}
int
-CMainWindow::Run()
+CDeviceManager::Run(void)
{
MSG Msg;
@@ -161,14 +202,11 @@
return 0;
}
-
-/* PRIVATE METHODS **********************************************/
-
bool
-CMainWindow::MainWndMenuHint(WORD CmdId,
- const MENU_HINT *HintArray,
- DWORD HintsCount,
- UINT DefHintId)
+CDeviceManager::MainWndMenuHint(_In_ WORD CmdId,
+ _In_ const MENU_HINT *HintArray,
+ _In_ DWORD HintsCount,
+ _In_ UINT DefHintId)
{
bool Found = false;
const MENU_HINT *LastHint;
@@ -188,16 +226,14 @@
StatusBarLoadString(m_hStatusBar,
SB_SIMPLEID,
- g_hInstance,
+ g_hThisInstance,
HintId);
return Found;
}
void
-CMainWindow::UpdateStatusBar(
- _In_ bool InMenuLoop
- )
+CDeviceManager::UpdateStatusBar(_In_ bool InMenuLoop)
{
SendMessageW(m_hStatusBar,
SB_SIMPLE,
@@ -206,7 +242,7 @@
}
bool
-CMainWindow::RefreshView(ViewType Type)
+CDeviceManager::RefreshView(_In_ ViewType Type)
{
UINT CheckId = 0;
BOOL bSuccess;
@@ -235,7 +271,7 @@
}
bool
-CMainWindow::CreateToolBar()
+CDeviceManager::CreateToolBar(void)
{
TBADDBITMAP TbAddBitmap;
INT Index;
@@ -251,7 +287,7 @@
0, 0, 0, 0,
m_hMainWnd,
(HMENU)IDC_TOOLBAR,
- g_hInstance,
+ g_hThisInstance,
NULL);
if (m_hToolBar == NULL) return FALSE;
@@ -269,7 +305,7 @@
sizeof(TBBUTTON),
0);
- TbAddBitmap.hInst = g_hInstance;
+ TbAddBitmap.hInst = g_hThisInstance;
TbAddBitmap.nID = IDB_TOOLBAR;
Index = SendMessageW(m_hToolBar, TB_ADDBITMAP, _countof(TbButtons),
(LPARAM)&TbAddBitmap);
@@ -285,7 +321,7 @@
}
bool
-CMainWindow::CreateStatusBar()
+CDeviceManager::CreateStatusBar(void)
{
int StatWidths[] = {110, -1}; // widths of status bar
bool bRet = FALSE;
@@ -298,7 +334,7 @@
0, 0, 0, 0,
m_hMainWnd,
(HMENU)IDC_STATUSBAR,
- g_hInstance,
+ g_hThisInstance,
NULL);
if (m_hStatusBar)
{
@@ -312,7 +348,7 @@
return bRet;
}
-void CMainWindow::UpdateToolbar()
+void CDeviceManager::UpdateToolbar()
{
WORD State;
@@ -367,10 +403,10 @@
bool
-CMainWindow::StatusBarLoadString(IN HWND hStatusBar,
- IN INT PartId,
- IN HINSTANCE hInstance,
- IN UINT uID)
+CDeviceManager::StatusBarLoadString(_In_ HWND hStatusBar,
+ _In_ INT PartId,
+ _In_ HINSTANCE hInstance,
+ _In_ UINT uID)
{
CAtlStringW szMessage;
bool bRet = false;
@@ -389,7 +425,7 @@
}
LRESULT
-CMainWindow::OnCreate(HWND hwnd)
+CDeviceManager::OnCreate(_In_ HWND hwnd)
{
LRESULT RetCode;
@@ -422,7 +458,7 @@
}
LRESULT
-CMainWindow::OnSize()
+CDeviceManager::OnSize(void)
{
RECT rcClient, rcTool, rcStatus;
INT lvHeight, iToolHeight, iStatusHeight;
@@ -457,7 +493,7 @@
}
LRESULT
-CMainWindow::OnNotify(LPARAM lParam)
+CDeviceManager::OnNotify(_In_ LPARAM lParam)
{
LPNMHDR NmHdr = (LPNMHDR)lParam;
LRESULT Ret;
@@ -491,6 +527,7 @@
case TTN_GETDISPINFO:
{
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam;
+ lpttt->hinst = g_hThisInstance;
UINT_PTR idButton = lpttt->hdr.idFrom;
switch (idButton)
@@ -502,18 +539,19 @@
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_SCAN);
break;
case IDC_ENABLE_DRV:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ENABLE);
+ lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_ENABLE);
break;
case IDC_DISABLE_DRV:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_DISABLE);
+ lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_DISABLE);
break;
case IDC_UPDATE_DRV:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_UPDATE);
+ lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UPDATE);
break;
case IDC_UNINSTALL_DRV:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_UNINSTALL);
+ lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UNINSTALL);
break;
}
+ idButton = idButton;
break;
}
}
@@ -522,14 +560,14 @@
}
LRESULT
-CMainWindow::OnContext(LPARAM lParam)
+CDeviceManager::OnContext(_In_ LPARAM lParam)
{
return m_DeviceView->OnContextMenu(lParam);
}
LRESULT
-CMainWindow::OnCommand(WPARAM wParam,
- LPARAM /*lParam*/)
+CDeviceManager::OnCommand(_In_ WPARAM wParam,
+ _In_ LPARAM /*lParam*/)
{
LRESULT RetCode = 0;
WORD Msg;
@@ -641,7 +679,7 @@
}
LRESULT
-CMainWindow::OnDestroy()
+CDeviceManager::OnDestroy(void)
{
// Uninitialize the device view
m_DeviceView->Uninitialize();
@@ -660,16 +698,16 @@
}
LRESULT CALLBACK
-CMainWindow::MainWndProc(HWND hwnd,
- UINT msg,
- WPARAM wParam,
- LPARAM lParam)
-{
- CMainWindow *This;
+CDeviceManager::MainWndProc(_In_ HWND hwnd,
+ _In_ UINT msg,
+ _In_ WPARAM wParam,
+ _In_ LPARAM lParam)
+{
+ CDeviceManager *This;
LRESULT RetCode = 0;
// Get the object pointer from window context
- This = (CMainWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ This = (CDeviceManager *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (This == NULL)
{
// Check that this isn't a create message
@@ -685,7 +723,7 @@
case WM_CREATE:
{
// Get the object pointer from the create param
- This = (CMainWindow *)((LPCREATESTRUCT)lParam)->lpCreateParams;
+ This = (CDeviceManager *)((LPCREATESTRUCT)lParam)->lpCreateParams;
// Store the pointer in the window's global user data
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)This);
@@ -783,49 +821,15 @@
}
-//////// MOVE ME ////////////////
-
-HINSTANCE g_hInstance = NULL;
-HANDLE ProcessHeap = NULL;
-
-
+#if 1 // test
BOOL
WINAPI
-DeviceManager_ExecuteW(HWND /*hWndParent*/,
+DeviceManager_ExecuteW(HWND hWndParent,
HINSTANCE hInst,
- LPCWSTR /*lpMachineName*/,
+ LPCWSTR lpMachineName,
int nCmdShow)
{
- CMainWindow MainWindow;
- INITCOMMONCONTROLSEX icex;
- CAtlStringW szAppName;
- int Ret = 1;
-
- // Store the global values
- g_hInstance = hInst;
- ProcessHeap = GetProcessHeap();
-
- // Initialize common controls
- icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
- InitCommonControlsEx(&icex);
-
- //__debugbreak();
- g_hInstance = GetModuleHandle(L"devmgr.dll");
-
- // Load the application name
- if (szAppName.LoadStringW(g_hInstance, IDS_APPNAME))
- {
- // Initialize the main window
- if (MainWindow.Initialize(szAppName, nCmdShow))
- {
- // Run the application
- Ret = MainWindow.Run();
-
- // Uninitialize the main window
- MainWindow.Uninitialize();
- }
- }
-
- return Ret;
-}
+ CDeviceManager DevMgr;
+ return DevMgr.Create(hWndParent, hInst, lpMachineName, nCmdShow);
+}
+#endif
Modified: trunk/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/devmg…
==============================================================================
--- trunk/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.h [iso-8859-1] Wed Jul 8
06:43:16 2015
@@ -7,25 +7,27 @@
UINT HintId;
} MENU_HINT, *PMENU_HINT;
-class CMainWindow
+class CDeviceManager
{
CAtlStringW m_szMainWndClass;
CDeviceView *m_DeviceView;
HWND m_hMainWnd;
HWND m_hStatusBar;
HWND m_hToolBar;
- HIMAGELIST m_ToolbarhImageList;
HMENU m_hMenu;
HMENU m_hActionMenu;
int m_CmdShow;
public:
- CMainWindow(void);
- ~CMainWindow(void);
+ CDeviceManager(void);
+ ~CDeviceManager(void);
- bool Initialize(LPCTSTR lpCaption, int nCmdShow);
- int Run();
- void Uninitialize();
+ bool Create(
+ _In_ HWND hWndParent,
+ _In_ HINSTANCE hInst,
+ _In_opt_z_ LPCWSTR lpMachineName,
+ _In_ int nCmdShow
+ );
private:
static LRESULT CALLBACK MainWndProc(
@@ -35,24 +37,44 @@
LPARAM lParam
);
- LRESULT OnCreate(HWND hwnd);
- LRESULT OnDestroy();
- LRESULT OnSize();
- LRESULT OnNotify(LPARAM lParam);
- LRESULT OnContext(LPARAM lParam);
- LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
-
- bool CreateToolBar();
- bool CreateStatusBar();
-
- void UpdateToolbar(
+ 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
+ );
+
+ bool CreateToolBar(void);
+ bool CreateStatusBar(void);
+
+ void UpdateToolbar(void);
+
bool StatusBarLoadString(
- HWND hStatusBar,
- INT PartId,
- HINSTANCE hInstance,
- UINT uID
+ _In_ HWND hStatusBar,
+ _In_ INT PartId,
+ _In_ HINSTANCE hInstance,
+ _In_ UINT uID
);
void UpdateStatusBar(
@@ -60,14 +82,14 @@
);
bool MainWndMenuHint(
- WORD CmdId,
- const MENU_HINT *HintArray,
- DWORD HintsCount,
- UINT DefHintId
+ _In_ WORD CmdId,
+ _In_ const MENU_HINT *HintArray,
+ _In_ DWORD HintsCount,
+ _In_ UINT DefHintId
);
bool RefreshView(
- ViewType Type
+ _In_ ViewType Type
);
};
Modified: trunk/reactos/dll/win32/devmgr_new/devmgmt/RootNode.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/devmg…
==============================================================================
--- trunk/reactos/dll/win32/devmgr_new/devmgmt/RootNode.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr_new/devmgmt/RootNode.cpp [iso-8859-1] Wed Jul 8
06:43:16 2015
@@ -29,8 +29,8 @@
// Load the bitmap we'll be using as the root image
HBITMAP hRootImage;
- hRootImage = LoadBitmapW(g_hInstance,
- MAKEINTRESOURCEW(IDB_ROOT_IMAGE));
+ hRootImage = LoadBitmapW(g_hThisInstance,
+ MAKEINTRESOURCEW(IDB_ROOT_IMAGE));
if (hRootImage == NULL) return FALSE;
// Add this bitmap to the device image list. This is a bit hacky, but it's safe
Modified: trunk/reactos/dll/win32/devmgr_new/devmgmt/devmgmt.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/devmg…
==============================================================================
--- trunk/reactos/dll/win32/devmgr_new/devmgmt/devmgmt.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr_new/devmgmt/devmgmt.h [iso-8859-1] Wed Jul 8 06:43:16
2015
@@ -4,6 +4,6 @@
#pragma once
#include "..\resource.h"
-extern HINSTANCE g_hInstance;
-extern HANDLE ProcessHeap;
+extern HINSTANCE g_hThisInstance;
+extern HINSTANCE g_hParentInstance;