开发者

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

I have a .NET application that is being targe开发者_高级运维ted 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.

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". Is there anyway on CE to have it display the "OK"? I've seen "OK" show up on message boxes so it seems like I should be able to...


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. 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. So SHDoneButton(this.handle, SHDB_SHOW) where SHDB_SHOW = 0x0001 you'll need:

[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.

To make the OK button appear, ensure that your window does not have either the WS_CAPTION or WS_CHILD styles.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜