如何在输入按键时执行代码? [英] how to execute code on enter key press?

查看:69
本文介绍了如何在输入按键时执行代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有三个编辑框和一个提交按钮我在提交按钮单击时执行一些代码但我也想要如果我按下回车键,代码也应该执行。我的代码是 -



In my application I have three edit box and a submit button I am executing some code on submit button click but I also want that if I 'll press the enter key that code should also execute.my code is-

case WM_COMMAND:



           switch(LOWORD(wParam))
           {

           case IDC_MAIN_BUTTON:
               {

                   SendMessage(h_Name,WM_GETTEXT,sizeof(CName)/sizeof(CName[0]),reinterpret_cast<LPARAM>(CName));
                   SendMessage(h_Email,WM_GETTEXT,sizeof(CName)/sizeof(CEmail[0]),reinterpret_cast<LPARAM>(CEmail));
                   SendMessage(h_Phone,WM_GETTEXT,sizeof(CPhone)/sizeof(CPhone[0]),reinterpret_cast<LPARAM>(CPhone));

                         i = 1;

                         EnableWindow( GetDlgItem(hwnd, IDC_MAIN_BUTTON),false);
                         EnableWindow( GetDlgItem(hwnd, IDC_CLEAR_BUTTON),false);
                         ShowWindow(GetDlgItem(hwnd, 3), SW_SHOW);
                         SendMessage( hwndPrgBar, PBM_SETPOS, 0, 0 );
                         SetTimer(hwnd, ID_TIMER, 10, NULL);


                    

                   
               }
               break;





所以现在请告诉我这个代码如何在enter键上执行按



so please now tell me that how this code will also execute on enter key press

推荐答案

在对话框资源中将您的按钮声明为 DEFPUSHBUTTON
Declare your button as DEFPUSHBUTTON in your dialog resource.


这篇关于如何在输入按键时执行代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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