简体   繁体   English

在.NET应用程序的Windows CE .NET 4.2中将[X]更改为OK

[英]Changing [X] to OK on form in Windows CE .NET 4.2 in .NET application

I have a .NET application that is being targeted to run on Windows Mobile 5 and Windows CE .NET 4.2 and there are some minor differences between how forms display that I'm trying to converge. 我有一个目标为在Windows Mobile 5和Windows CE .NET 4.2上运行的.NET应用程序,而我尝试聚合的表单显示方式之间有一些细微的差异。

On the WM device a form will display with an "ok" button in the top right while on CE the same form will show an "X". 在WM设备上,一个表单将显示在右上角带有“确定”按钮,而在CE上,同一表单将显示一个“ X”。 Is there anyway on CE to have it display the "OK"? 无论如何,CE上是否都显示“ OK”? I've seen "OK" show up on message boxes so it seems like I should be able to... 我已经看到“ OK”出现在消息框上,因此看来我应该能够...

The easiest way is probably to set the forms window style ControlBox = False and MinimizeBox = False and then call SHDoneButton in the form's Paint event handler and when it's activated or shown. 最简单的方法可能是设置窗体窗口样式ControlBox = FalseMinimizeBox = False ,然后在窗体的Paint事件处理程序中以及激活或显示窗体时调用SHDoneButton You really are only supposed to need to do it before the form becomes the foreground window but I found that you have to also call it in the Paint event handler. 实际上,您只需要在窗体成为前景窗口之前执行此操作,但是我发现您还必须在Paint事件处理程序中调用它。 So SHDoneButton(this.handle, SHDB_SHOW) where SHDB_SHOW = 0x0001 you'll need: 因此SHDoneButton(this.handle, SHDB_SHOW)您需要SHDoneButton(this.handle, SHDB_SHOW)其中SHDB_SHOW = 0x0001

[DllImport("aygshell.dll")]
public static extern bool SHDoneButton(IntPtr hWnd, UInt32 dwState);

somewhere as well. 以及某处。

Per the linked documentation: 根据链接的文档:

Typically, the Done button is managed by the shell, and showing or hiding the OK button happens automatically. 通常,“完成”按钮是由外壳程序管理的,显示或隐藏“确定”按钮是自动发生的。 A top-level window that needs the Done button to appear should use the WS_EX_CAPTIONOKBTN window style. 需要显示“完成”按钮的顶级窗口应使用WS_EX_CAPTIONOKBTN窗口样式。

To make the OK button appear, ensure that your window does not have either the WS_CAPTION or WS_CHILD styles. 要显示“确定”按钮,请确保您的窗口没有WS_CAPTION或WS_CHILD样式。

Whenever the foreground window changes, the shell checks the style bits of the window to determine if the OK button should appear in the taskbar. 每当前景窗口更改时,外壳程序都会检查窗口的样式位,以确定“确定”按钮是否应出现在任务栏中。 The OK button takes precedence over a menu bar added to the taskbar. “确定”按钮优先于添加到任务栏的菜单栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM