在我的C#Windows应用程序打开Windows的“计算器? [英] Open Windows' Calculator in my C# Win Application?

查看:218
本文介绍了在我的C#Windows应用程序打开Windows的“计算器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以打开Windows计算器以下code:

I know I can open Windows Calculator with the following code :

System.Diagnostics.Process.Start("calc");

不过,我想在我的C#Windows应用程序,也就是打开它。我不希望在独立的窗口中打开它,我想在我的窗口中打开它
我该怎么办呢?

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 ?

推荐答案

您不能嵌入其他应用程序到您的形式。

You cannot embed another application into your form.

不过,您可将计算器窗口中的窗体顶部设置窗体作为其父。这可能会实现,你要寻找的视觉效果。你可能会检查到的setparent 的API函数。例如:

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:

System.Diagnostics.Process p = System.Diagnostics.Process.Start("calc.exe");
p.WaitForInputIdle();
NativeMethods.SetParent(p.MainWindowHandle, this.Handle);


有一个更好的解决方案可能是刚刚推出的C#你自己的计算器控制,如果你真的需要嵌入到你的应用程序的功能。一起重击了一个简单的计算器真的是一点都不难,它的无限定制做的,看起来完全是你想要的。


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.

这样的事情,也许,会是一个很好的起点,如果你想推出自己的计算器:<一href="http://www.$c$cproject.com/KB/cs/Scientific_Calculator.aspx">http://www.$c$cproject.com/KB/cs/Scientific_Calculator.aspx

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

和我一直认为这种类型的控制将是可笑的有用的,如果有一天我曾经写了一个应用程序,在很大程度上依赖于数字输入:<一href="http://www.$c$cproject.com/KB/miscctrl/C__Popup_Calculator.aspx">http://www.$c$cproject.com/KB/miscctrl/C__Popup_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

这篇关于在我的C#Windows应用程序打开Windows的“计算器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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