我有一个 Windows 窗体文本框,后台线程每秒更新其值。如果我将光标放在文本框中,它将在下次更新时失去当前位置。与文本选择相同。
我试着这样解决
protected void SetTextProgrammatically(string value)
{
// save current cursor position and selection
int start = textBox.SelectionStart;
int length = textBox.SelectionLength;
// update text
textBox.Text = value;
// restore cursor position and selection
textBox.SelectionStart = start;
textBox.SelectionLength = length;
}
Run Code Online (Sandbox Code Playgroud)
大多数情况下它运行良好。这是它不起作用的情况:
1) 我将光标放在文本框中文本的末尾
2) 按 SHIFT 并使用 <- 箭头键将光标向左移动
选择将无法正常工作。
它看起来像组合SelectionStart=10并SelectionLength=1自动将光标移动到位置 11(不是我想要的 10)。
如果有什么我可以做的,请告诉我!我正在使用 Framework.NET 2.0。
必须有一种方法可以在文本框中设置光标位置,而不是SelectionStart+SelectionLength.
请帮我理解这个表达方式:
(dwStreamSizeMax >> 32i64)
Run Code Online (Sandbox Code Playgroud)
我以前从未见过像32i64这样的操作数.谢谢.
我无法将 DLL 隐式链接到 C 控制台应用程序。我使用 Visual Studio 2008。
我创建了空的 DLL 项目“Library”,其中仅包含一个文件 main.c:
__declspec(dllexport) int get_value()
{
return 123;
}
Run Code Online (Sandbox Code Playgroud)
我还使用文件 main.c 创建了空控制台项目“CallingProgram”:
__declspec(dllimport) int get_value();
void main()
{
int result = get_value();
}
Run Code Online (Sandbox Code Playgroud)
我将“Library.lib”添加到“Linker\Input\Additional Dependency”中。
我仍然有这个错误:
error LNK2019: unresolved external symbol __imp__get_value referenced in function _main
Run Code Online (Sandbox Code Playgroud)
我测试了使用 LoadLibrary/GetProcAddress 创建的 DLL - 它工作正常。
我使用 DumpBin 检查了 Library.dll,它看起来也不错:
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file library.dll
File Type: DLL
Section contains the following …Run Code Online (Sandbox Code Playgroud) 我正在使用 .NET Core 3.1 这是我正在使用的代码:
CredentialCache credentialCache = new CredentialCache();
credentialCache.Add(new Uri(URL), "NEGOTIATE", new NetworkCredential(USER, PASSWORD, DOMAIN));
using (HttpClientHandler handler = new HttpClientHandler())
{
handler.Credentials = credentialCache;
using (HttpClient httpClient = new HttpClient(handler))
{
HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("GET"), REQUEST_URL);
HttpResponseMessage response = httpClient.SendAsync(request).Result;
Console.Write(response.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
它在我的 Windows 机器上工作正常,但在 Linux docker 容器上启动时崩溃:
System.AggregateException:发生一个或多个错误。(GSSAPI 操作失败,出现错误 - 未指定的 GSS 失败。次要代码可能会提供更多信息(找不到领域“DOMAIN_NAME”的 KDC)。) ---> System.ComponentModel.Win32Exception (0x80090020):GSSAPI 操作失败,出现错误 - 未指定的 GSS失败。次要代码可能会提供更多信息(无法找到领域“DOMAIN_NAME”的 KDC)。在System.Net.Security.NegotiateStreamPal.AcquireCredentialsHandle(字符串包,布尔isServer,NetworkCredential凭据)在System.Net.NTAuthentication.Initialize(布尔isServer,字符串包,NetworkCredential凭据,字符串spn,ContextFlagsPal requestContextFlags,ChannelBindingchannelBinding)在System。 Net.Http.AuthenticationHelper.SendWithNtAuthAsync(HttpRequestMessage请求,Uri authUri,ICredentials凭证,布尔isProxyAuth,HttpConnection连接,HttpConnectionPool连接池,CancellationToken取消令牌)在System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection连接,HttpRequestMessage请求,布尔doRequestAuth,CancellationToken cancelToken)在 System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage 请求,布尔 doRequestAuth,CancellationToken CancellationToken) 在 System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage 请求,Uri …
.net-2.0 ×1
.net-core ×1
32bit-64bit ×1
c ×1
c# ×1
c++ ×1
dll ×1
dllexport ×1
dllimport ×1
docker ×1
httpclient ×1
visual-c++ ×1
winforms ×1