Add PhGetWindowContextEx, PhSetWindowContextEx, PhRemoveWindowContextEx
This commit is contained in:
+4
-4
@@ -6,7 +6,7 @@
|
||||
* Authors:
|
||||
*
|
||||
* wj32 2010
|
||||
* dmex 2017-2021
|
||||
* dmex 2017-2023
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -142,12 +142,12 @@ LRESULT CALLBACK PhpColorBoxWndProc(
|
||||
{
|
||||
PPHP_COLORBOX_CONTEXT context;
|
||||
|
||||
context = PhGetWindowContext(hwnd, MAXCHAR);
|
||||
context = PhGetWindowContextEx(hwnd);
|
||||
|
||||
if (uMsg == WM_CREATE)
|
||||
{
|
||||
PhpCreateColorBoxContext(&context);
|
||||
PhSetWindowContext(hwnd, MAXCHAR, context);
|
||||
PhSetWindowContextEx(hwnd, context);
|
||||
}
|
||||
|
||||
if (!context)
|
||||
@@ -162,7 +162,7 @@ LRESULT CALLBACK PhpColorBoxWndProc(
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
{
|
||||
PhRemoveWindowContext(hwnd, MAXCHAR);
|
||||
PhRemoveWindowContextEx(hwnd);
|
||||
PhpFreeColorBoxContext(context);
|
||||
}
|
||||
break;
|
||||
|
||||
+3
-3
@@ -945,12 +945,12 @@ LRESULT CALLBACK PhpGraphWndProc(
|
||||
{
|
||||
PPHP_GRAPH_CONTEXT context;
|
||||
|
||||
context = PhGetWindowContext(hwnd, MAXCHAR);
|
||||
context = PhGetWindowContextEx(hwnd);
|
||||
|
||||
if (uMsg == WM_CREATE)
|
||||
{
|
||||
PhpCreateGraphContext(&context);
|
||||
PhSetWindowContext(hwnd, MAXCHAR, context);
|
||||
PhSetWindowContextEx(hwnd, context);
|
||||
}
|
||||
|
||||
if (!context)
|
||||
@@ -994,7 +994,7 @@ LRESULT CALLBACK PhpGraphWndProc(
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
{
|
||||
PhRemoveWindowContext(hwnd, MAXCHAR);
|
||||
PhRemoveWindowContextEx(hwnd);
|
||||
|
||||
if (context->TooltipHandle)
|
||||
DestroyWindow(context->TooltipHandle);
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@
|
||||
* Authors:
|
||||
*
|
||||
* wj32 2010-2015
|
||||
* dmex 2017
|
||||
* dmex 2017-2023
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -97,12 +97,12 @@ LRESULT CALLBACK PhpHexEditWndProc(
|
||||
{
|
||||
PPHP_HEXEDIT_CONTEXT context;
|
||||
|
||||
context = PhGetWindowContext(hwnd, MAXCHAR);
|
||||
context = PhGetWindowContextEx(hwnd);
|
||||
|
||||
if (uMsg == WM_CREATE)
|
||||
{
|
||||
PhpCreateHexEditContext(&context);
|
||||
PhSetWindowContext(hwnd, MAXCHAR, context);
|
||||
PhSetWindowContextEx(hwnd, context);
|
||||
}
|
||||
|
||||
if (!context)
|
||||
@@ -136,7 +136,7 @@ LRESULT CALLBACK PhpHexEditWndProc(
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
{
|
||||
PhRemoveWindowContext(hwnd, MAXCHAR);
|
||||
PhRemoveWindowContextEx(hwnd);
|
||||
PhpFreeHexEditContext(context);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -754,6 +754,49 @@ PhRemoveWindowContext(
|
||||
_In_ ULONG PropertyHash
|
||||
);
|
||||
|
||||
FORCEINLINE
|
||||
PVOID
|
||||
PhGetWindowContextEx(
|
||||
_In_ HWND WindowHandle
|
||||
)
|
||||
{
|
||||
#if (PHNT_WINDOW_CLASS_CONTEXT)
|
||||
return PhGetWindowContext(WindowHandle, MAXCHAR);
|
||||
#else
|
||||
//assert(GetClassLongPtr(WindowHandle, GCL_CBWNDEXTRA) == sizeof(PVOID));
|
||||
return (PVOID)GetWindowLongPtr(WindowHandle, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
VOID
|
||||
PhSetWindowContextEx(
|
||||
_In_ HWND WindowHandle,
|
||||
_In_ PVOID Context
|
||||
)
|
||||
{
|
||||
#if (PHNT_WINDOW_CLASS_CONTEXT)
|
||||
PhSetWindowContext(WindowHandle, MAXCHAR, Context);
|
||||
#else
|
||||
//assert(GetClassLongPtr(WindowHandle, GCL_CBWNDEXTRA) == sizeof(PVOID));
|
||||
SetWindowLongPtr(WindowHandle, 0, (LONG_PTR)Context);
|
||||
#endif
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
VOID
|
||||
PhRemoveWindowContextEx(
|
||||
_In_ HWND WindowHandle
|
||||
)
|
||||
{
|
||||
#if (PHNT_WINDOW_CLASS_CONTEXT)
|
||||
PhRemoveWindowContext(WindowHandle, MAXCHAR);
|
||||
#else
|
||||
//assert(GetClassLongPtr(WindowHandle, GCL_CBWNDEXTRA) == sizeof(PVOID));
|
||||
SetWindowLongPtr(WindowHandle, 0, (LONG_PTR)NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef BOOL (CALLBACK* PH_ENUM_CALLBACK)(
|
||||
_In_ HWND WindowHandle,
|
||||
_In_opt_ PVOID Context
|
||||
|
||||
+5
-5
@@ -6,7 +6,7 @@
|
||||
* Authors:
|
||||
*
|
||||
* wj32 2011-2016
|
||||
* dmex 2017-2021
|
||||
* dmex 2017-2023
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -77,12 +77,12 @@ LRESULT CALLBACK PhTnpWndProc(
|
||||
{
|
||||
PPH_TREENEW_CONTEXT context;
|
||||
|
||||
context = PhGetWindowContext(hwnd, MAXCHAR);
|
||||
context = PhGetWindowContextEx(hwnd);
|
||||
|
||||
if (uMsg == WM_CREATE)
|
||||
{
|
||||
PhTnpCreateTreeNewContext(&context);
|
||||
PhSetWindowContext(hwnd, MAXCHAR, context);
|
||||
PhSetWindowContextEx(hwnd, context);
|
||||
}
|
||||
|
||||
if (!context)
|
||||
@@ -104,11 +104,11 @@ LRESULT CALLBACK PhTnpWndProc(
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
case WM_NCDESTROY:
|
||||
case WM_DESTROY:
|
||||
{
|
||||
context->Callback(hwnd, TreeNewDestroying, NULL, NULL, context->CallbackContext);
|
||||
PhTnpDestroyTreeNewContext(context);
|
||||
PhRemoveWindowContext(hwnd, MAXCHAR);
|
||||
PhRemoveWindowContextEx(hwnd);
|
||||
}
|
||||
return 0;
|
||||
case WM_SIZE:
|
||||
|
||||
Reference in New Issue
Block a user