From: Ged Murphy Date: Thu, 8 Sep 2011 22:03:08 +0000 (+0000) Subject: [DEVMGMT] X-Git-Tag: backups/reactx@60648^2~18 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=83fe58205288d5e3fd044651f0671807762593dc [DEVMGMT] - Start a new device manager to test the reactos ATL code. - Also, the old one sucks big time and was quickly hacked together. svn path=/trunk/; revision=53648 --- diff --git a/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp b/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp new file mode 100644 index 00000000000..fb6f1ca19ac --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp @@ -0,0 +1,13 @@ +#include "StdAfx.h" +#include "Devices.h" +#include "DeviceView.h" + + +CDeviceView::CDeviceView(void) +{ +} + + +CDeviceView::~CDeviceView(void) +{ +} diff --git a/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h b/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h new file mode 100644 index 00000000000..b936112b040 --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h @@ -0,0 +1,8 @@ +#pragma once +class CDeviceView : public CDevices +{ +public: + CDeviceView(void); + ~CDeviceView(void); +}; + diff --git a/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp b/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp new file mode 100644 index 00000000000..ddc687e1b6e --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp @@ -0,0 +1,12 @@ +#include "StdAfx.h" +#include "Devices.h" + + +CDevices::CDevices(void) +{ +} + + +CDevices::~CDevices(void) +{ +} diff --git a/reactos/base/applications/mscutils/devmgmt_new/Devices.h b/reactos/base/applications/mscutils/devmgmt_new/Devices.h new file mode 100644 index 00000000000..e0735162ba6 --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/Devices.h @@ -0,0 +1,8 @@ +#pragma once +class CDevices +{ +public: + CDevices(void); + ~CDevices(void); +}; + diff --git a/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp b/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp new file mode 100644 index 00000000000..34a7ed72ef2 --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp @@ -0,0 +1,158 @@ +#include "StdAfx.h" +#include "devmgmt.h" +#include "MainWindow.h" + + +CMainWindow::CMainWindow(void) : + m_hMainWnd(NULL), + m_CmdShow(0) +{ + m_szMainWndClass = L"DevMgmtWndClass"; +} + + +CMainWindow::~CMainWindow(void) +{ +} + +BOOL +CMainWindow::StatusBarLoadString(IN HWND hStatusBar, + IN INT PartId, + IN HINSTANCE hInstance, + IN UINT uID) +{ + CAtlString szMessage; + BOOL Ret = FALSE; + + /* Load the string */ + if (szMessage.LoadStringW(hInstance, uID)) + { + /* Send the message to the status bar */ + Ret = (BOOL)SendMessageW(hStatusBar, + SB_SETTEXT, + (WPARAM)PartId, + (LPARAM)szMessage.GetBuffer()); + } + + return Ret; +} + +LRESULT CALLBACK +CMainWindow::MainWndProc(HWND hwnd, + UINT msg, + WPARAM wParam, + LPARAM lParam) +{ + CMainWindow *pThis; + LRESULT Ret = 0; + + /* Get the object pointer from window context */ + pThis = (CMainWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + + /* Check for an invalid pointer */ + if (!pThis) + { + /* Check that this isn't a create message */ + if (msg != WM_CREATE) + { + /* Don't handle null info pointer */ + goto HandleDefaultMessage; + } + } + + switch(msg) + { + case WM_CREATE: + { + /* Get the object pointer from the create param */ + pThis = (CMainWindow *)((LPCREATESTRUCT)lParam)->lpCreateParams; + + /* Store the info pointer in the window's global user data */ + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pThis); + + /* Display the window according to the user request */ + ShowWindow(hwnd, pThis->m_CmdShow); + + break; + } + + default: + { +HandleDefaultMessage: + Ret = DefWindowProc(hwnd, msg, wParam, lParam); + break; + } + } + + return Ret; +} + +BOOL +CMainWindow::Initialize(LPCTSTR lpCaption, + int nCmdShow) +{ + CAtlString szCaption; + WNDCLASSEXW wc = {0}; + + /* Store the show window value */ + m_CmdShow = nCmdShow; + + /* 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.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, + MAKEINTRESOURCE(IDI_MAIN_ICON), + IMAGE_ICON, + 16, + 16, + LR_SHARED); + + /* Register the window */ + if (RegisterClassExW(&wc)) + { + /* Create the main window and store the info pointer */ + m_hMainWnd = CreateWindowExW(WS_EX_WINDOWEDGE, + m_szMainWndClass, + lpCaption, + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + CW_USEDEFAULT, + CW_USEDEFAULT, + 600, + 450, + NULL, + NULL, + g_hInstance, + this); + } + + /* Return creation result */ + return !!(m_hMainWnd); +} + +VOID +CMainWindow::Uninitialize() +{ + /* Unregister the window class */ + UnregisterClassW(m_szMainWndClass, g_hInstance); +} + +INT +CMainWindow::Run() +{ + MSG Msg; + + /* Pump the message queue */ + while (GetMessageW(&Msg, NULL, 0, 0 )) + { + TranslateMessage(&Msg); + DispatchMessageW(&Msg); + } + + return 0; +} \ No newline at end of file diff --git a/reactos/base/applications/mscutils/devmgmt_new/MainWindow.h b/reactos/base/applications/mscutils/devmgmt_new/MainWindow.h new file mode 100644 index 00000000000..16c291a4009 --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/MainWindow.h @@ -0,0 +1,21 @@ +#pragma once +class CMainWindow +{ + CAtlString m_szMainWndClass; + HWND m_hMainWnd; + int m_CmdShow; + +private: + static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + + BOOL StatusBarLoadString(HWND hStatusBar, INT PartId, HINSTANCE hInstance, UINT uID); + +public: + CMainWindow(void); + ~CMainWindow(void); + + BOOL Initialize(LPCTSTR lpCaption, int nCmdShow); + INT Run(); + VOID Uninitialize(); +}; + diff --git a/reactos/base/applications/mscutils/devmgmt_new/Resource.h b/reactos/base/applications/mscutils/devmgmt_new/Resource.h new file mode 100644 index 00000000000..ab547c3a5fa --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/Resource.h @@ -0,0 +1,64 @@ +#define IDC_STATIC -1 + +#define IDI_MAIN_ICON 50 +#define IDB_ROOT_IMAGE 51 + +/* windows */ +#define IDC_TREEVIEW 1000 +#define IDC_TOOLBAR 1001 +#define IDC_STATUSBAR 1002 + +/* commands */ +#define IDC_PROP 2000 +#define IDC_REFRESH 2001 +#define IDC_PRINT 2002 +#define IDC_PROGHELP 2003 +#define IDC_EXIT 2004 +#define IDC_ABOUT 4031 + +/* menus */ +#define IDR_MAINMENU 102 +#define IDR_POPUP 103 +#define IDC_DEVBYTYPE 104 + +/* tooltips */ +#define IDS_TOOLTIP_PROP 6000 +#define IDS_TOOLTIP_REFRESH 6001 +#define IDS_TOOLTIP_HELP 6002 +#define IDS_TOOLTIP_EXIT 6003 + +/* button bitmaps */ +#define IDB_PROP 10000 +#define IDB_REFRESH 10001 +#define IDB_HELP 10002 +#define IDB_EXIT 10003 + +/* toolbar buttons */ +#define TBICON_PROP 0 +#define TBICON_REFRESH 1 +#define TBICON_HELP 2 +#define TBICON_EXIT 3 + +/* about box info */ +#define IDD_ABOUTBOX 200 +#define IDC_LICENSE_EDIT 201 +#define IDS_APPNAME 202 +#define IDS_LICENSE 203 + + +/* menu hints */ +#define IDS_HINT_BLANK 20000 +#define IDS_HINT_REFRESH 20002 +#define IDS_HINT_PROP 20003 +#define IDS_HINT_HELP 20004 +#define IDS_HINT_ABOUT 20005 +#define IDS_HINT_EXIT 20006 + +/* system menu hints */ +#define IDS_HINT_SYS_RESTORE 21001 +#define IDS_HINT_SYS_MOVE 21002 +#define IDS_HINT_SYS_SIZE 21003 +#define IDS_HINT_SYS_MINIMIZE 21004 +#define IDS_HINT_SYS_MAXIMIZE 21005 +#define IDS_HINT_SYS_CLOSE 21006 + diff --git a/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp b/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp new file mode 100644 index 00000000000..7795c771a92 --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp @@ -0,0 +1,58 @@ +#include "stdafx.h" +#include "devmgmt.h" +#include "MainWindow.h" + +HINSTANCE g_hInstance = NULL; +HANDLE ProcessHeap = NULL; + +int WINAPI +wWinMain(HINSTANCE hThisInstance, + HINSTANCE hPrevInstance, + LPWSTR lpCmdLine, + int nCmdShow) +{ + CMainWindow MainWindow; + INITCOMMONCONTROLSEX icex; + HANDLE hMutex; + CAtlString szAppName; + + int Ret = 1; + + /* Check if the app is already running */ + hMutex = CreateMutexW(NULL, TRUE, L"devmgmt_mutex"); + if (hMutex == NULL || GetLastError() == ERROR_ALREADY_EXISTS) + { + /* Cleanup and exit */ + if (hMutex) CloseHandle(hMutex); + return 0; + } + + /* Store the global values */ + g_hInstance = hThisInstance; + ProcessHeap = GetProcessHeap(); + + /* 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_hInstance, IDS_APPNAME)) + { + /* Initialize the main window */ + if (MainWindow.Initialize(szAppName, + nCmdShow)) + { + /* Run the application */ + Ret = MainWindow.Run(); + + /* Uninitialize the main window */ + MainWindow.Uninitialize(); + } + } + + /* Delete the app mutex */ + CloseHandle(hMutex); + + return Ret; +} diff --git a/reactos/base/applications/mscutils/devmgmt_new/devmgmt.h b/reactos/base/applications/mscutils/devmgmt_new/devmgmt.h new file mode 100644 index 00000000000..f8abae2728a --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/devmgmt.h @@ -0,0 +1,9 @@ +#pragma once +#define WIN32_LEAN_AND_MEAN +#include +#pragma once +#include "resource.h" + +extern HINSTANCE g_hInstance; +extern HANDLE ProcessHeap; + diff --git a/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc b/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc new file mode 100644 index 00000000000..ec5d1382349 Binary files /dev/null and b/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc differ diff --git a/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln b/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln new file mode 100644 index 00000000000..9efc23a2901 --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "devmgmt_new", "devmgmt_new.vcxproj", "{A5AB2C1A-A085-4A2A-951C-F3CF22DA2890}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5AB2C1A-A085-4A2A-951C-F3CF22DA2890}.Debug|Win32.ActiveCfg = Debug|Win32 + {A5AB2C1A-A085-4A2A-951C-F3CF22DA2890}.Debug|Win32.Build.0 = Debug|Win32 + {A5AB2C1A-A085-4A2A-951C-F3CF22DA2890}.Release|Win32.ActiveCfg = Release|Win32 + {A5AB2C1A-A085-4A2A-951C-F3CF22DA2890}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj b/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj new file mode 100644 index 00000000000..86c0a055e96 --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj @@ -0,0 +1,102 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {A5AB2C1A-A085-4A2A-951C-F3CF22DA2890} + Win32Proj + devmgmt_new + + + + Application + true + Unicode + Static + + + Application + false + true + Unicode + Static + + + + + + + + + + + + + true + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + + + Windows + true + comctl32.lib;%(AdditionalDependencies) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/reactos/base/applications/mscutils/devmgmt_new/rsrc.rc b/reactos/base/applications/mscutils/devmgmt_new/rsrc.rc new file mode 100644 index 00000000000..f512433568f --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/rsrc.rc @@ -0,0 +1,36 @@ +#include +#include "resource.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +IDI_MAIN_ICON ICON "res/computer.ico" +IDB_ROOT_IMAGE BITMAP "res/root.bmp" + +/* main toolbar icons */ +IDB_PROP BITMAP DISCARDABLE "res/properties.bmp" +IDB_REFRESH BITMAP DISCARDABLE "res/refresh.bmp" +IDB_HELP BITMAP DISCARDABLE "res/help.bmp" +IDB_EXIT BITMAP DISCARDABLE "res/exit.bmp" + +#include "lang/bg-BG.rc" +#include "lang/de-DE.rc" +#include "lang/el-GR.rc" +#include "lang/en-US.rc" +#include "lang/es-ES.rc" +#include "lang/fr-FR.rc" +#include "lang/id-ID.rc" +#include "lang/it-IT.rc" +#include "lang/ja-JP.rc" +#include "lang/ko-KR.rc" +#include "lang/no-NO.rc" +#include "lang/ro-RO.rc" +#include "lang/sk-SK.rc" +#include "lang/sv-SE.rc" +#include "lang/th-TH.rc" + +// UTF-8 +#pragma code_page(65001) +#include "lang/pl-PL.rc" +#include "lang/ru-RU.rc" +#include "lang/uk-UA.rc" +#include "lang/zh-CN.rc" diff --git a/reactos/base/applications/mscutils/devmgmt_new/stdafx.cpp b/reactos/base/applications/mscutils/devmgmt_new/stdafx.cpp new file mode 100644 index 00000000000..fd4f341c7b2 --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/reactos/base/applications/mscutils/devmgmt_new/stdafx.h b/reactos/base/applications/mscutils/devmgmt_new/stdafx.h new file mode 100644 index 00000000000..c8036cf787e --- /dev/null +++ b/reactos/base/applications/mscutils/devmgmt_new/stdafx.h @@ -0,0 +1,13 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit + +#include +#include