Reduced system resource usage.

This commit is contained in:
spx 2011-10-01 06:27:20 +00:00
parent e1aafc9705
commit 6dd79c451d
3 changed files with 6 additions and 39 deletions

View File

@ -71,7 +71,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
HANDLE hMutex = NULL; HANDLE hMutex = NULL;
MSG msg; MSG msg;
BOOL bRet; BOOL bRet;
HWND hWnd;
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
// _CrtSetBreakAlloc(5055); // _CrtSetBreakAlloc(5055);
@ -93,26 +92,11 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
return RetSuccess; 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; 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 // Check that the DLL is available and initialize it
HMODULE module = GetModuleHandle(L"Rainmeter.dll"); HMODULE module = GetModuleHandle(L"Rainmeter.dll");
if (module == NULL || Initialize(hWnd, module, lpCmdLine) == 1) 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) BOOL InitApplication(HINSTANCE hInstance, const WCHAR* WinClass)
{ {
WNDCLASS wc; WNDCLASS wc = {0};
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.style = 0;
wc.lpfnWndProc = (WNDPROC) MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance; 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; wc.lpszClassName = WinClass;
return RegisterClass(&wc); return RegisterClass(&wc);

View File

@ -230,11 +230,10 @@ CMeterWindow::~CMeterWindow()
*/ */
int CMeterWindow::Initialize(CRainmeter& Rainmeter) int CMeterWindow::Initialize(CRainmeter& Rainmeter)
{ {
WNDCLASSEX wc = {sizeof(WNDCLASSEX)};
m_Rainmeter = &Rainmeter; m_Rainmeter = &Rainmeter;
// Register the windowclass // Register the windowclass
WNDCLASSEX wc = {sizeof(WNDCLASSEX)};
wc.style = CS_NOCLOSE | CS_DBLCLKS; wc.style = CS_NOCLOSE | CS_DBLCLKS;
wc.lpfnWndProc = WndProc; wc.lpfnWndProc = WndProc;
wc.hInstance = m_Rainmeter->GetInstance(); wc.hInstance = m_Rainmeter->GetInstance();

View File

@ -53,17 +53,9 @@ CTrayWindow::CTrayWindow(HINSTANCE instance) : m_Instance(instance),
m_TrayPos(), m_TrayPos(),
m_TrayIconEnabled(true) m_TrayIconEnabled(true)
{ {
WNDCLASS wc; WNDCLASS wc = {0};
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WndProc; wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = instance; 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"; wc.lpszClassName = L"RainmeterTrayClass";
RegisterClass(&wc); RegisterClass(&wc);