From 6dd79c451d9e72e0e2ad510c615fd14191094bcd Mon Sep 17 00:00:00 2001 From: spx Date: Sat, 1 Oct 2011 06:27:20 +0000 Subject: [PATCH] Reduced system resource usage. --- Application/Application.cpp | 32 ++++---------------------------- Library/MeterWindow.cpp | 3 +-- Library/TrayWindow.cpp | 10 +--------- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/Application/Application.cpp b/Application/Application.cpp index 54c6c812..1ed5c4f0 100644 --- a/Application/Application.cpp +++ b/Application/Application.cpp @@ -71,7 +71,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd HANDLE hMutex = NULL; MSG msg; BOOL bRet; - HWND hWnd; _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // _CrtSetBreakAlloc(5055); @@ -93,26 +92,11 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd return RetSuccess; } - if (!hPrevInstance) - { - if (!InitApplication(hInstance, WinClass)) return RetError; - } + if (!InitApplication(hInstance, WinClass)) return RetError; - hWnd=InitInstance(hInstance, WinClass, WinName); + HWND hWnd = InitInstance(hInstance, WinClass, WinName); if (!hWnd) return RetError; - // Remove quotes from the commandline - WCHAR Path[MAX_PATH+1] = {0}; - if (lpCmdLine) - { - size_t Pos = 0; - for (size_t i = 0, len = wcslen(lpCmdLine); i <= len && Pos < MAX_PATH; ++i) - { - if (lpCmdLine[i] != L'\"') Path[Pos++] = lpCmdLine[i]; - } - } - - // Check that the DLL is available and initialize it HMODULE module = GetModuleHandle(L"Rainmeter.dll"); if (module == NULL || Initialize(hWnd, module, lpCmdLine) == 1) @@ -149,17 +133,9 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd */ BOOL InitApplication(HINSTANCE hInstance, const WCHAR* WinClass) { - WNDCLASS wc; - - wc.style = 0; - wc.lpfnWndProc = (WNDPROC) MainWndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; + WNDCLASS wc = {0}; + wc.lpfnWndProc = (WNDPROC)MainWndProc; wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_RAINMETER)); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = NULL; wc.lpszClassName = WinClass; return RegisterClass(&wc); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 334dba22..0a10ffc8 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -230,11 +230,10 @@ CMeterWindow::~CMeterWindow() */ int CMeterWindow::Initialize(CRainmeter& Rainmeter) { - WNDCLASSEX wc = {sizeof(WNDCLASSEX)}; - m_Rainmeter = &Rainmeter; // Register the windowclass + WNDCLASSEX wc = {sizeof(WNDCLASSEX)}; wc.style = CS_NOCLOSE | CS_DBLCLKS; wc.lpfnWndProc = WndProc; wc.hInstance = m_Rainmeter->GetInstance(); diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 96469849..986bf709 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -53,17 +53,9 @@ CTrayWindow::CTrayWindow(HINSTANCE instance) : m_Instance(instance), m_TrayPos(), m_TrayIconEnabled(true) { - WNDCLASS wc; - - wc.style = 0; + WNDCLASS wc = {0}; wc.lpfnWndProc = (WNDPROC)WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; wc.hInstance = instance; - wc.hIcon = LoadIcon(instance, MAKEINTRESOURCE(IDI_WINDOW)); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = NULL; wc.lpszClassName = L"RainmeterTrayClass"; RegisterClass(&wc);