Bug 913953 - Part v: Remove unused HWND subclassing functions; r=ehsan

This commit is contained in:
Ms2ger 2013-09-10 09:03:36 +02:00
parent 2bce033d67
commit 33b7b4f37d
2 changed files with 0 additions and 76 deletions

View File

@ -246,60 +246,6 @@ bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor) {
return true;
}
#pragma warning(push)
#pragma warning(disable:4312 4244)
WNDPROC SetWindowProc(HWND hwnd, WNDPROC proc) {
// The reason we don't return the SetwindowLongPtr() value is that it returns
// the orignal window procedure and not the current one. I don't know if it is
// a bug or an intended feature.
WNDPROC oldwindow_proc =
reinterpret_cast<WNDPROC>(GetWindowLongPtr(hwnd, GWLP_WNDPROC));
SetWindowLongPtr(hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(proc));
return oldwindow_proc;
}
// Maps to the WNDPROC for a window that was active before the subclass was
// installed.
static const wchar_t* const kHandlerKey = L"__ORIGINAL_MESSAGE_HANDLER__";
bool IsSubclassed(HWND window, WNDPROC subclass_proc) {
WNDPROC original_handler =
reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC));
return original_handler == subclass_proc;
}
bool Subclass(HWND window, WNDPROC subclass_proc) {
WNDPROC original_handler =
reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC));
if (original_handler != subclass_proc) {
win_util::SetWindowProc(window, subclass_proc);
SetProp(window, kHandlerKey, (void*)original_handler);
return true;
}
return false;
}
bool Unsubclass(HWND window, WNDPROC subclass_proc) {
WNDPROC current_handler =
reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC));
if (current_handler == subclass_proc) {
HANDLE original_handler = GetProp(window, kHandlerKey);
if (original_handler) {
RemoveProp(window, kHandlerKey);
win_util::SetWindowProc(window,
reinterpret_cast<WNDPROC>(original_handler));
return true;
}
}
return false;
}
WNDPROC GetSuperclassWNDPROC(HWND window) {
return reinterpret_cast<WNDPROC>(GetProp(window, kHandlerKey));
}
#pragma warning(pop)
bool IsShiftPressed() {
return (::GetKeyState(VK_SHIFT) & 0x80) == 0x80;
}

View File

@ -51,28 +51,6 @@ bool GetUserSidString(std::wstring* user_sid);
// The function returns true if it succeeds, false otherwise.
bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor);
// Useful for subclassing a HWND. Returns the previous window procedure.
WNDPROC SetWindowProc(HWND hwnd, WNDPROC wndproc);
// Returns true if the existing window procedure is the same as |subclass_proc|.
bool IsSubclassed(HWND window, WNDPROC subclass_proc);
// Subclasses a window, replacing its existing window procedure with the
// specified one. Returns true if the current window procedure was replaced,
// false if the window has already been subclassed with the specified
// subclass procedure.
bool Subclass(HWND window, WNDPROC subclass_proc);
// Unsubclasses a window subclassed using Subclass. Returns true if
// the window was subclassed with the specified |subclass_proc| and the window
// was successfully unsubclassed, false if the window's window procedure is not
// |subclass_proc|.
bool Unsubclass(HWND window, WNDPROC subclass_proc);
// Retrieves the original WNDPROC of a window subclassed using
// SubclassWindow.
WNDPROC GetSuperclassWNDPROC(HWND window);
// Returns true if the shift key is currently pressed.
bool IsShiftPressed();