reverting formatting of files

This commit is contained in:
Alekhya Kommuru 2020-01-17 14:38:41 -08:00
parent 8132bbac2e
commit 653a84d3a9
2 changed files with 35 additions and 47 deletions

View File

@ -14,10 +14,9 @@ std::optional<POINT> get_mouse_pos();
// Gets active window, filtering out all "non standard" windows like the taskbar, etc. // Gets active window, filtering out all "non standard" windows like the taskbar, etc.
HWND get_filtered_active_window(); HWND get_filtered_active_window();
// Gets window ancestor (usualy the window we want to do stuff with), filtering out all "non standard" windows like the taskbar, etc. and provide the app process path // Gets window ancestor (usualy the window we want to do stuff with), filtering out all "non standard" windows like the taskbar, etc. and provide the app process path
struct WindowAndProcPath struct WindowAndProcPath {
{ HWND hwnd = nullptr;
HWND hwnd = nullptr; std::wstring process_path;
std::wstring process_path;
}; };
WindowAndProcPath get_filtered_base_window_and_path(HWND window); WindowAndProcPath get_filtered_base_window_and_path(HWND window);
@ -33,18 +32,17 @@ int run_message_loop();
void show_last_error_message(LPCWSTR lpszFunction, DWORD dw); void show_last_error_message(LPCWSTR lpszFunction, DWORD dw);
enum WindowState enum WindowState {
{ UNKNONW,
UNKNONW, MINIMIZED,
MINIMIZED, MAXIMIZED,
MAXIMIZED, SNAPED_TOP_LEFT,
SNAPED_TOP_LEFT, SNAPED_LEFT,
SNAPED_LEFT, SNAPED_BOTTOM_LEFT,
SNAPED_BOTTOM_LEFT, SNAPED_TOP_RIGHT,
SNAPED_TOP_RIGHT, SNAPED_RIGHT,
SNAPED_RIGHT, SNAPED_BOTTOM_RIGHT,
SNAPED_BOTTOM_RIGHT, RESTORED
RESTORED
}; };
WindowState get_window_state(HWND hwnd); WindowState get_window_state(HWND hwnd);

View File

@ -1,10 +1,8 @@
#include "stdafx.h" #include "stdafx.h"
#include <commctrl.h> #include <commctrl.h>
#include "Settings.h" #include "Settings.h"
#include "PowerRenameInterfaces.h" #include "PowerRenameInterfaces.h"
// Note: Not moving these strings to the resource file as these are internal and used as IDs
const wchar_t c_rootRegPath[] = L"Software\\Microsoft\\PowerRename"; const wchar_t c_rootRegPath[] = L"Software\\Microsoft\\PowerRename";
const wchar_t c_mruSearchRegPath[] = L"SearchMRU"; const wchar_t c_mruSearchRegPath[] = L"SearchMRU";
const wchar_t c_mruReplaceRegPath[] = L"ReplaceMRU"; const wchar_t c_mruReplaceRegPath[] = L"ReplaceMRU";
@ -167,15 +165,15 @@ bool CSettings::GetRegStringValue(_In_ PCWSTR valueName, __out_ecount(cchBuf) PW
return (SUCCEEDED(HRESULT_FROM_WIN32(SHGetValue(HKEY_CURRENT_USER, c_rootRegPath, valueName, &type, value, &cb) == ERROR_SUCCESS))); return (SUCCEEDED(HRESULT_FROM_WIN32(SHGetValue(HKEY_CURRENT_USER, c_rootRegPath, valueName, &type, value, &cb) == ERROR_SUCCESS)));
} }
typedef int(CALLBACK* MRUCMPPROC)(LPCWSTR, LPCWSTR);
typedef struct typedef int (CALLBACK* MRUCMPPROC)(LPCWSTR, LPCWSTR);
{
DWORD cbSize; typedef struct {
UINT uMax; DWORD cbSize;
UINT fFlags; UINT uMax;
HKEY hKey; UINT fFlags;
LPCTSTR lpszSubKey; HKEY hKey;
LPCTSTR lpszSubKey;
MRUCMPPROC lpfnCompare; MRUCMPPROC lpfnCompare;
} MRUINFO; } MRUINFO;
@ -190,21 +188,15 @@ class CRenameMRU :
{ {
public: public:
// IUnknown // IUnknown
IFACEMETHODIMP_(ULONG) IFACEMETHODIMP_(ULONG) AddRef();
AddRef(); IFACEMETHODIMP_(ULONG) Release();
IFACEMETHODIMP_(ULONG)
Release();
IFACEMETHODIMP QueryInterface(_In_ REFIID riid, _Outptr_ void** ppv); IFACEMETHODIMP QueryInterface(_In_ REFIID riid, _Outptr_ void** ppv);
// IEnumString // IEnumString
IFACEMETHODIMP Next(__in ULONG celt, __out_ecount_part(celt, *pceltFetched) LPOLESTR* rgelt, __out_opt ULONG* pceltFetched); IFACEMETHODIMP Next(__in ULONG celt, __out_ecount_part(celt, *pceltFetched) LPOLESTR* rgelt, __out_opt ULONG* pceltFetched);
IFACEMETHODIMP Skip(__in ULONG) { return E_NOTIMPL; } IFACEMETHODIMP Skip(__in ULONG) { return E_NOTIMPL; }
IFACEMETHODIMP Reset(); IFACEMETHODIMP Reset();
IFACEMETHODIMP Clone(__deref_out IEnumString** ppenum) IFACEMETHODIMP Clone(__deref_out IEnumString** ppenum) { *ppenum = nullptr; return E_NOTIMPL; }
{
*ppenum = nullptr;
return E_NOTIMPL;
}
// IPowerRenameMRU // IPowerRenameMRU
IFACEMETHODIMP AddMRUString(_In_ PCWSTR entry); IFACEMETHODIMP AddMRUString(_In_ PCWSTR entry);
@ -221,20 +213,19 @@ private:
int _EnumMRUList(_In_ int nItem, _Out_ void* lpData, _In_ UINT uLen); int _EnumMRUList(_In_ int nItem, _Out_ void* lpData, _In_ UINT uLen);
void _FreeMRUList(); void _FreeMRUList();
long m_refCount = 0; long m_refCount = 0;
HKEY m_hKey = NULL; HKEY m_hKey = NULL;
ULONG m_maxMRUSize = 0; ULONG m_maxMRUSize = 0;
ULONG m_mruIndex = 0; ULONG m_mruIndex = 0;
ULONG m_mruSize = 0; ULONG m_mruSize = 0;
HANDLE m_mruHandle = NULL; HANDLE m_mruHandle = NULL;
HMODULE m_hComctl32Dll = NULL; HMODULE m_hComctl32Dll = NULL;
PWSTR m_regPath = nullptr; PWSTR m_regPath = nullptr;
}; };
CRenameMRU::CRenameMRU() : CRenameMRU::CRenameMRU() :
m_refCount(1) m_refCount(1)
{ {}
}
CRenameMRU::~CRenameMRU() CRenameMRU::~CRenameMRU()
{ {
@ -277,14 +268,12 @@ HRESULT CRenameMRU::CreateInstance(_In_ PCWSTR regPathMRU, _In_ ULONG maxMRUSize
} }
// IUnknown // IUnknown
IFACEMETHODIMP_(ULONG) IFACEMETHODIMP_(ULONG) CRenameMRU::AddRef()
CRenameMRU::AddRef()
{ {
return InterlockedIncrement(&m_refCount); return InterlockedIncrement(&m_refCount);
} }
IFACEMETHODIMP_(ULONG) IFACEMETHODIMP_(ULONG) CRenameMRU::Release()
CRenameMRU::Release()
{ {
long refCount = InterlockedDecrement(&m_refCount); long refCount = InterlockedDecrement(&m_refCount);
@ -475,6 +464,7 @@ void CRenameMRU::_FreeMRUList()
{ {
pfnFreeMRUList(m_mruHandle); pfnFreeMRUList(m_mruHandle);
} }
} }
m_mruHandle = NULL; m_mruHandle = NULL;
} }