在wpf中使用系统计算器 [英] Use of System calculator in wpf

查看:141
本文介绍了在wpf中使用系统计算器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用系统计算器在我的wpf表单中使用 System.Diagnostics.Process.Start(calc); 但现在我想在我的wpf中存储计算结果应用程序文本框。



请告诉我如何存储此结果。

I use system calculator in my wpf form using System.Diagnostics.Process.Start("calc"); but now I want to store result of calculation in my wpf apps textbox.

Please tell me how to store this result.

推荐答案

CrystalB不太正确 - 可以从Calc获得结果 - 它使用标准控件,因此只要用户没有关闭它,就可以按照窗口句柄找到它的控件ID。 但是 ......我从来没有这样做过,部分原因是因为它是来自C#的PITA,部分是因为它是一个令人讨厌且相当愚蠢的事情。



相反,我会查看各种可用的计算器应用程序(并且有负载: Codeproject计算器 [ ^ ])并调整其中一个在您的应用程序中工作,并在您需要时返回结果。考虑到Calc.exe随着微软的变化而变化,它可能会更容易,而且肯定会更安全。
CrystalB is not quite right - it is possible to get the result from Calc - it uses standard controls so as long as the user hasn''t closed it, it is possible if you follow the window handles and locate it''s control ID. But...I''ve never done it, partly because it''s a PITA from C# and partly because it is a nasty and rather stupid thing to do.

Instead, I would look at the various calculator apps available (and there are loads: Codeproject calculators[^]) and adapt one of those to work within your application and return results when you want them to. It''d probably be easier, and certainly would be safer, given that Calc.exe is subject to change at the whim of Microsoft.


这篇关于在wpf中使用系统计算器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆