需要帮助让DEFPUSHBUTTON样式起作用 [英] Need help getting DEFPUSHBUTTON style to work

查看:124
本文介绍了需要帮助让DEFPUSHBUTTON样式起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个简单的对话框,其中唯一的按钮被声明为DEFPUSHBUTTON。 

Hello, I have a simple dialog box, where the only button is declared as DEFPUSHBUTTON. 

在对话框的消息处理程序中,焦点设置到文本编辑框,以便使用键盘或SIP的输入直接到达所需的位置。但是,如果按下Enter键,则表示应用程序没有响应 - 没有默认的
操作发生。如何才能使默认按钮操作起作用?

In the message handler for the dialog box, the focus is set to the text edit box, so that input with the keypad or SIP goes directly where it needs to. However, if the Enter key is pressed, there is no response from the application - there is no default action taking place. How can I get the default push button action to work?

我的项目是在VS2008中创建的,目标是WM6.x professional。

My project was created in VS2008, target WM6.x professional.

我的对话框rc文件:

IDD_DIALOG DIALOG  0, 0, 221, 129
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg"
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,85,63,50,14
    LTEXT           "Static",IDC_STATIC,84,15,19,8
    EDITTEXT        IDC_PASSWORD,70,29,90,14,ES_AUTOHSCROLL
END

我的对话框消息处理函数:

My dialog message handler function:

INT_PTR CALLBACK Dialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    static TCHAR * KeyString;

    switch (message)
    {
        case WM_INITDIALOG:
            SendMessage(GetDlgItem(hDlg, IDC_PASSWORD), EM_LIMITTEXT, 16, 0);
	    SetFocus(GetDlgItem(hDlg, IDC_PASSWORD));
            KeyString = (TCHAR*)lParam;
            break;

        case WM_COMMAND:
#ifdef SHELL_AYGSHELL
            if (LOWORD(wParam) == IDOK)
#endif
            {
               GetDlgItemText(hDlg, IDC_PASSWORD, (LPWSTR)KeyString, 17);
                EndDialog(hDlg, LOWORD(wParam));
                return (INT_PTR)TRUE;
            }
            break;

        case WM_CLOSE:
            EndDialog(hDlg, message);
            return (INT_PTR)TRUE;

    }
    return (INT_PTR)FALSE;
}

谢谢,

DK

推荐答案

因此窗口处于活动状态(在前面)但Enter不生成IDOK或不生成任何WM_COMMAND消息? EDIT控件是否具有多行或者想要返回的样式集(代码中)?是否使用DialogBox()启动了对话框?或者它是无模式的(在这种情况下你
不应该调用EndDialog)?你的主循环使用IsDialogMessage(),TranslateMessage(),DispatchMessage()的标准布局吗?

So the window is active (in front) but Enter doesn't generate IDOK or doesn't generate any WM_COMMAND messages? Does the EDIT control have multi-line or wants-return style set (in code)? Was the dialog launched with DialogBox()? Or is it modeless (you shouldn't call EndDialog, in that case)? Does your main loop use the standard layout of IsDialogMessage(), TranslateMessage(), DispatchMessage()?

Paul T。


这篇关于需要帮助让DEFPUSHBUTTON样式起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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