我正在使用VSTO开发Office PowerPoint加载项,并且在PowerPoint幻灯片放映窗口中嵌入了一个窗口。 当我使用PowerPoint幻灯片放映窗口的“笔”工具时,当鼠标移至嵌入式窗口时,光标变为箭头,这就是我想要的, 但是当我使用橡皮擦工具时,当鼠标移到嵌入式窗口中时,光标仍然是橡皮擦。
有什么方法可以防止PowerPoint将光标变成橡皮擦吗?
我尝试了WNDPROC,HOOK,SetClassLong,将光标设置为箭头,但最终被PowerPoint设置为橡皮擦。
WNDPROC oldWndProc = NULL;
LRESULT CALLBACK newWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
if (message == WM_SETCURSOR || message == WM_MOUSEMOVE ||message==WM_MOUSEHOVER
|| message == WM_MOUSEACTIVATE || message == WM_TIMER) {
HCURSOR hCursor11 = LoadCursorW(NULL, OCR_SIZENS);
::SetClassLong(hwnd, GCL_HCURSOR, (LONG)hCursor11);
::SetCursor(hCursor11);
::SetSystemCursor(hCursor11, 32645); //OCR_SIZENS(32645)
return TRUE;
}
else {
return ::CallWindowProc(oldWndProc, hwnd, message, wParam, lParam);
}
}
oldWndProc = (TWndProc)::SetWindowLongA((HWND)this->winId(), GWL_WNDPROC, (LONG)newWndProc);
LRESULT CALLBACK wndHookProc1(int code, WPARAM wParam, LPARAM lParam) {
if (code >= 0) {
CWPSTRUCT * p = (CWPSTRUCT*)lParam;
if (p->message == WM_SETCURSOR || p->message == WM_MOUSEHOVER || p->message==WM_MOUSEMOVE) {
HCURSOR hCursor22 = LoadCursorW(NULL, IDC_SIZENS);
::SetClassLong(p->hwnd, GCL_HCURSOR, (LONG)hCursor22);
::SetCursor(hCursor22);
::SetSystemCursor(hCursor22, 32645);
return TRUE;
}
else {
return ::CallNextHookEx(gWndHook, code, wParam, lParam);
}
}
else {
return ::CallNextHookEx(gWndHook, code, wParam, lParam);
}
}
gHInstance = GetModuleHandleFromAddress(wndHookProc1);
gWndHook = ::SetWindowsHookExA(WH_CALLWNDPROC, wndHookProc1, gHInstance, NULL);