两个在Windows mobile开发中常用的how to.

<1>:How to Prevent Display of Smart Minimize and OK Buttons in Dialog Boxes.

 

n general, a dialog box should include the OK button on the title bar. However, if you are creating a wizard-style dialog box or another type of dialog box that includes a Cancel button, you can choose to show no title bar icon for that dialog box. This requires several changes to general-purpose code, such as that generated by the App Wizard.

  1. Manually edit the resource (.rc) file for the dialog box. Add WS_NONAVDONEBUTTON to the STYLE line to prevent the display of the Smart Minimize button, as shown:

    //

    // Dialog.

    //

    IDD_WIZARD DIALOG DISCARDABLE 0, 0, 140, 57

    STYLE WS_POPUP | WS_CAPTION | WS_NONAVDONEBUTTON

    EXSTYLE 0x80000000L

    CAPTION "Your Wizard"
  2. Remove SHDIF_DONEBUTTON from the dwFlags member of the SHINITDLGINFO user interface structure (generally found in the WM_INITDIALOG message handler for the dialog box) to remove the OK button from the title bar, as follows:

    SHINITDLGINFO shidi;

    switch (message)

    {

    case WM_INITDIALOG:

    shidi.dwMask = SHIDIM_FLAGS;



    shidi.hDlg = hDlg;

    if (!SHInitDialog(&shidi)) {

    MessageBox(NULL, _T("Can't create dialog box."),

    _T("Error"), MB_OK);

    exit(0); // Replace with specific error handling.

    }

    .

    .

    .
  3. Add a call to the SHDoneButton function with the SHDB_HIDE state after calling the SHInitDialog function to hide the OK button, as follows:

        if (!SHDoneButton(hDlg, SHDB_HIDE)) {

    MessageBox(NULL, _T("Can't hide the OK button."),

    _T("Error"), MB_OK);

    exit(0); // Replace with specific error handling.

    }
  4. If you run the code as is, no Smart Minimize button or OK button appears on the title bar, but tapping the Enter key in the emulator or on the input panel keyboard closes the dialog box. If this is not the desired behavior, make the appropriate changes to the WM_COMMAND message handler. Generally, you want to set focus to the default control in the current panel of your wizard.

<2>How to Prevent Display of Smart Minimize Buttons in Application Windows

In general, a top-level window should include a Smart Minimize button in the title bar. To prevent the Smart Minimize button from appearing on title bar of windows, do not use the WS_CAPTION style — add the WS_NONAVDONEBUTTON to the styles when calling the Windows Embedded CE CreateWindow function.

The following code example demonstrates how to prevent the Smart Minimize button from appearing on title bar of windows.

Note:
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
hWnd = CreateWindow(szWindowClass, szTitle, 

WS_NONAVDONEBUTTON, CW_USEDEFAULT,

CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,

NULL, hInstance, NULL);

3:
Windows Mobile上创建的窗口程序,点默认右上角“X”是发送窗口最小化消息,而不是Windows程序中发WM_CLOSE消息。要实现关闭的功能,可在窗口创建的时候加入:
::SHDoneButton(hWnd, SHDB_SHOWCANCEL);//SHDB_SHOW显示OK
这样可以在窗口的WM_COMMAND消息中,处理IDOK或IDCANCEL来关闭。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值