打开Windows我的 C# Win 应用程序中的计算器?
我知道我可以使用以下代码打开 Windows 计算器:
System.Diagnostics.Process.Start("calc");
但我想在我的 C# Win 应用程序中打开它,即:我不想在独立窗口中打开它,我想在我的窗口中打开它。
我该怎么办?
I know I can open Windows Calculator with the following code :
System.Diagnostics.Process.Start("calc");
But I wanna open it in my C# Win Application, i.e : I don't want to open it in the independent window, I wanna open it in my window.
How can I do it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您不能将其他申请嵌入到您的表单中。
但是,您可以将计算器窗口移动到窗体顶部并将窗体设置为其父窗体。这可能会实现您正在寻找的视觉效果。您可以检查 SetParent API 函数。例如:
如果您确实需要在应用程序中嵌入该功能,更好的解决方案可能只是在 C# 中推出您自己的计算器控件。组合一个简单的计算器确实一点也不困难,而且它可以无限定制,可以完全按照您想要的方式进行操作和外观。
如果您想推出自己的计算器,这样的东西也许是一个很好的起点:http://www .codeproject.com/KB/cs/Scientific_Calculator.aspx
我一直认为,如果我曾经编写过一个严重依赖数字输入的应用程序,那么这种类型的控件有一天会非常有用:http://www.codeproject.com/KB/miscctrl/C__Popup_Calculator.aspx
You cannot embed another application into your form.
However, you can move the calculator window on top of your form and set your form as its parent. This might accomplish the visual effect that you're looking for. You might check into the SetParent API function. For example:
A better solution might be just to roll your own calculator control in C# if you really need that functionality embedded in your app. Banging together a simple calculator really isn't at all difficult, and its infinitely customizable to do and look exactly as you want.
Something like this, perhaps, would be a good starting point if you wanted to roll your own calculator: http://www.codeproject.com/KB/cs/Scientific_Calculator.aspx
And I've always thought this type of a control would be ridiculously useful someday if I ever wrote an app that relied heavily on numerical input: http://www.codeproject.com/KB/miscctrl/C__Popup_Calculator.aspx
MS Windows 计算器不是 GUI 控件,它是一个独立的应用程序。如果您正在寻找 .NET 计算器控件,可以使用第三方供应商提供的一些商业控件,例如
此处
http://download.cnet.com/Softgroup-Net-Calculator-Control/3000-10250_4-10909672.html
或此处
http://www.softpedia.com/get/Programming/Components-Libraries/Net-Calculator -Control.shtml
MS Windows Calculator is not a GUI control, it is a standalone application. If you are looking for a .NET calculator control, there are some commercial controls from third party vendors, for example
here
http://download.cnet.com/Softgroup-Net-Calculator-Control/3000-10250_4-10909672.html
or here
http://www.softpedia.com/get/Programming/Components-Libraries/Net-Calculator-Control.shtml
你可以pinvoke SetParent(),子窗口句柄应该是Calc的Process.MainWindowHandle,父窗口应该是你想要嵌入它的窗口的句柄。 Form.Handle 为您提供了该值。您还需要 MoveWindow 将窗口移动到正确的位置。使用 pinvoke.net 获取所需的 pinvoke 声明。
You can pinvoke SetParent(), the child window handle should be the Process.MainWindowHandle of Calc, the parent window should be the handle of the window in which you want to embed it. Form.Handle gives you that value. You'll also need MoveWindow to get the window in the right place. Use pinvoke.net to get the required pinvoke declarations.
尝试下面;为我奔跑。
try below; run for me.