具有大字体的 Windows 对话框
我正在咨询一个大型.Net winforms 项目,该项目必须能够在“触摸”模式下运行,以便可以使用触摸屏界面进行操作。应用程序体系结构已经包含用于放大标准 .Net 表单和控件上的字体/显示的缩放逻辑,并且自定义控件也可以处理缩放。
问题是应用程序使用 OpenFileDialog 和 SaveFileDialog,它们不使用相同的逻辑进行缩放(本质上是递归地调整控件和表单上的 Font 属性的大小)。我相信这些对话框本质上是本机 Windows 对话框,而 OpenFileDialog 类实际上只是公开标准 .Net 接口以与它们交互的包装类。
一种解决方案可能是为这些事情实现自定义对话框,但这可能会是一项繁重的工作。我们真正想做的是以某种方式缩放这个特定对话框的字体大小(也许通过一些 P/Invoke 窗口句柄魔术)?
我知道支持触摸的一种解决方案是调整 Windows 的字体大小,但这个想法并没有真正受到该公司的欢迎,他们宁愿缩放应用程序本身,而让操作系统的其余部分保持不变。
那么,关于如何将这些对话框缩放到更大的字体,有什么经验或想法吗?或者我们应该硬着头皮为此创建自定义对话框?
I'm consulting on a large .Net winforms project that has to be able to run in "Touch" mode so it can be operated using a touch screen interface. The application architecture already contains scaling logic for enlarging the fonts/display on the standard .Net forms and controls and the custom controls also handles the scaling.
The problem is that the application uses OpenFileDialog and SaveFileDialog which does not scale using the same logic (which is essentially adjusting the size of the Font property on the control and the forms recursively). I believe that these dialogs are essentially native Windows dialogs and the OpenFileDialog class are really just wrapper classes that expose a standard .Net interface to interact with them.
One solution could be to implement custom dialogs for these things, but that would probably be somewhat extensive work. What we really would like to do is to somehow scale the font size of this particular dialog (perhaps through some P/Invoke window-handle magic)?
I know that one solution for touch-enabling would be to adjust the font size of Windows in general, but that idea is not really catching on with this company, they would rather scale the app itself and leave the rest of the OS untouched.
So, any experience or ideas as to how you could scale these dialogs to a larger font? Or should we just bite the bullet and create custom dialogs for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您提到的对话框是“操作系统的其余部分”的一部分,他们宁愿不受影响。 您要么使用通用对话框,被迫增加控制面板(即系统范围)中的字体缩放比例,要么自己重新实现这些对话框。
另一种方法可能是使用适当的API,增加其字体缩放,并在那里执行应用程序(即让应用程序创建、使用和销毁该桌面)。然后,应用程序和所有常见对话框都会放大。
不过,该应用程序永远不会与其他应用程序一起出现在一个屏幕上,并且您必须注意在应用程序中切换桌面(我认为)。当应用程序处于活动状态时,除了应用程序 GUI 之外,您不会看到任何内容。没有开始按钮,没有任务栏,没有任何问题。例如,请参阅 http://www.codeproject.com/KB/cs/csdesktopswitching.aspx< /a> 了解详细信息。
The dialogs you refer to are part of "the rest of the OS" that they would rather leave untouched. You either use the common dialogs, being forced to increase the font scaling in control panel, i.e. system-wide, or re-implement those dialogs yourself.
An alternative might be to create a separate Windows desktop using the appropriate API, increase its font scaling, and execute the app there (i.e. let the app create, use, and destroy that desktop). Then, the app and all common dialogs would be scaled up.
The app would never be seen with other apps on one screen, though, and you would have to take care of switching desktops in the app (I think). And you would not see anything but the app GUI when the app is active. No start button, no taskbar, no nuttin´. See for example http://www.codeproject.com/KB/cs/csdesktopswitching.aspx for details.
对您来说最好的解决方案是创建一个表单,实现带有标签和关闭按钮的标题,并在表单的其余部分放置您需要的内容。在这种情况下,标签字体可以增加到您想要的任何大小。当你要做什么这个对话框时,只需在表单上调用 .sohwDialog()
The best solution for you would be to create a form implement the header with a label and with close botton and in the rest of the form put what u need. In that case labels font may be increased to whatever size u wish. when u what to shoe this dialog just call .sohwDialog() on the form