{"record":{"id":"55921db319c841bd","repo":"dotnet/wpf","slug":"0x80040207","errorCode":"0x80040207","errorMessage":"SR.TextStore_TS_E_INVALIDPOINT","messagePattern":"SR\\.TextStore_TS_E_INVALIDPOINT","errorType":"error_code","errorClass":"COMException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs","lineNumber":965,"sourceCode":"            milPoint = compositionTarget.TransformFromDevice.Transform(milPoint);\n\n            // Convert to local coordinates.\n            GeneralTransform transform = compositionTarget.RootVisual.TransformToDescendant(RenderScope);\n            // REVIEW: should we throw if the point could not be transformed?\n            transform?.TryTransform(milPoint, out milPoint);\n\n            // Validate layout information on TextView\n            if (!view.Validate(milPoint))\n            {\n                throw new COMException(SR.TextStore_TS_E_NOLAYOUT, UnsafeNativeMethods.TS_E_NOLAYOUT);\n            }\n\n            // Do the hittest.\n            position = view.GetTextPositionFromPoint(milPoint, (flags & UnsafeNativeMethods.GetPositionFromPointFlags.GXFPF_NEAREST) != 0 /* snapToText */);\n            if (position == null)\n            {\n                // GXFPF_ROUND_NEAREST was clear and we didn't hit a char.\n                throw new COMException(SR.TextStore_TS_E_INVALIDPOINT, UnsafeNativeMethods.TS_E_INVALIDPOINT);\n            }\n\n            positionCP = position.CharOffset;\n            if ((flags & UnsafeNativeMethods.GetPositionFromPointFlags.GXFPF_ROUND_NEAREST) == 0)\n            {\n                // Check if the point is on the backward position of the TextPosition.\n                Rect rectCur;\n                Rect rectPrev;\n                Point milPointTopLeft;\n                Point milPointBottomRight;\n\n                ITextPointer positionCur = position.CreatePointer(LogicalDirection.Backward);\n                ITextPointer positionPrev = position.CreatePointer(LogicalDirection.Forward);\n                positionPrev.MoveToNextInsertionPosition(LogicalDirection.Backward);\n\n                rectCur = view.GetRectangleFromTextPosition(positionCur);\n                rectPrev = view.GetRectangleFromTextPosition(positionPrev);\n","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs#L947-L983","documentation":"TS_E_INVALIDPOINT (0x80040207) is thrown from GetPositionFromPoint when the point falls outside any character: layout was valid, but GetTextPositionFromPoint returned null because GXFPF_ROUND_NEAREST was clear and the point did not hit a character. It is the TSF HRESULT for 'the point is not over text'.","triggerScenarios":"ITextStoreACP::GetACPFromPoint called with a screen point that misses all text and without the GXFPF_ROUND_NEAREST flag (and GXFPF_NEAREST not producing a snap), so no text position can be returned.","commonSituations":"IME candidate/phrase-boundary clicks in empty areas beside text (margins, blank lines' trailing space); coordinate conversion mismatches (per-monitor DPI, wrong window origin) putting points off the text surface.","solutions":["Pass the GXFPF_ROUND_NEAREST flag so TSF rounds to the nearest character instead of failing.","Verify the client coordinate conversion (screen-to-client, DPI scaling) before hit-testing.","Only issue point queries for points inside the rendered text rectangle; clamp or reject outside points upstream."],"exampleFix":"// before\nvar flags = 0; // GXFPF_ROUND_NEAREST clear -> point must hit a char exactly\n// after\nvar flags = UnsafeNativeMethods.GetPositionFromPointFlags.GXFPF_ROUND_NEAREST; // snap to nearest char","handlingStrategy":"validation","validationCode":"// Only hit-test points inside the editor's text area; convert screen->client with DPI awareness first.\nvar pt = editor.PointFromScreen(screenPoint);\nbool inside = editor.RenderSize.Width > pt.X && pt.X >= 0 && editor.RenderSize.Height > pt.Y && pt.Y >= 0;","typeGuard":null,"tryCatchPattern":"catch (COMException e) when (e.ErrorCode == unchecked((int)0x80040207)) { /* point not over text: ignore or retry with GXFPF_ROUND_NEAREST */ }","preventionTips":["Set GXFPF_ROUND_NEAREST when exact character hits aren't required.","Validate coordinates (DPI, window origin) before querying.","Treat points over margins/blank areas as no-ops."],"tags":["wpf","tsf","hit-test","coordinates","com-interop"],"backgroundTag":"invalid-point-hit-test","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}