{"id":416,"date":"2014-11-26T06:24:11","date_gmt":"2014-11-26T15:24:11","guid":{"rendered":"http:\/\/blog.box.kr\/?p=416"},"modified":"2014-11-26T06:24:11","modified_gmt":"2014-11-26T15:24:11","slug":"%ed%8e%8cmfc-dialog%ec%b0%bd%ec%97%90%ec%84%9c-enter%eb%88%84%eb%a5%b4%eb%a9%b4-%ec%b0%bd%ec%9d%b4-%eb%8b%ab%ed%9e%88%eb%8a%94-%ec%a6%9d%ec%83%81-%ea%b0%9c%ec%84%a0-%ed%95%98%ec%9e%90","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=416","title":{"rendered":"[\ud38c][mfc] Dialog\ucc3d\uc5d0\uc11c Enter\ub204\ub974\uba74 \ucc3d\uc774 \ub2eb\ud788\ub294 \uc99d\uc0c1 \uac1c\uc120 \ud558\uc790.."},"content":{"rendered":"<p>\uc6d0\uc778\uc740 Dailog\uc5d0\uc11c Enter\ub098 ESC\uac00 \ub20c\ub9ac\uba74 Event\ub97c \ucc3e\ub2e4\uac00 \uad6c\ud604\uc774 \uc5c6\uc73c\uba74<br \/>\n\ubd80\ubaa8\uc778 CDialog\uc758 SetDefID \ud568\uc218\ub97c \ubd80\ub974\ub294\ub370 \uc5ec\uae30\uc5d0 IDOK\uac00 \uad6c\ud604 \ub418\uc5b4 \uc788\uc5b4\uc11c \uadf8\ub7f0 \uac70\uc784..<\/p>\n<p>\uc774\uac78 \ubc29\uc9c0 \ud558\uc790\uba74 \ubb34\uc2dd\ud558\uac8c VK_ENTER\ub4f1\uc73c\ub85c Key press\ub97c \ub9c9\ub294 \ubc29\ubc95\ub3c4 \uc788\uc9c0\ub9cc.<br \/>\n\uc880\ub354 \uc6b0\uc544 \ud558\uac8c \uc6d0\uc778\uc744 \ucc3e\uc544 \ud574\uacb0 \ud558\uace0\uc790 \ud558\uba74 \uc544\ub798\uc640 \uac19\uc774<\/p>\n<p>\ubd80\ubaa8\uc758\u00a0SetDefID\ub97c \ub0b4\uac00 \uad6c\ud604\ud574 \ubc84\ub9ac\uba74 \ub418\ub294\uac70\ub2e4..<\/p>\n<p>\uc544\ub798\ub294 \uc778\ud130\ub137\uc5d0\uc11c \ucc3e\uc544\ub0b8 \uc6d0\uc778\uacfc \ud574\uacb0 \ubc29\ubc95<\/p>\n<p>&nbsp;<\/p>\n<p>When the user presses Enter key in a dialog two things can happen:<\/p>\n<ol>\n<li>The dialog has a default control (see <code>CDialog::SetDefID()<\/code>). Then a WM_COMMAND with the ID of this control is sent to the dialog.<\/li>\n<li>The dialog does not have a default control. Then WM_COMMAND with ID = IDOK is sent to the dialog.<\/li>\n<\/ol>\n<p>With the first option, it may happen that the default control has a ID equal to IDOK. Then the results will be the same that in the second option.<\/p>\n<p>By default, class <code>CDialog<\/code> has a handler for the <code>WM_COMMAND(IDOK)<\/code> that is to call to <code>CDialog::OnOk()<\/code>, that is a virtual function, and by default it calls <code>EndDialog(IDOK)<\/code> that closes the dialog.<\/p>\n<p>So, if you want to avoid the dialog being closed, do one of the following.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div class=\"de1\"><span class=\"co1\">\/\/ 1st approach. <a href=\"http:\/\/msdn.microsoft.com\/en-us\/magazine\/cc301409.aspx\">http:\/\/msdn.microsoft.com\/en-us\/magazine\/cc301409.aspx<\/a><\/span>\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"de1\">BEGIN_MESSAGE_MAP<span class=\"br0\">(<\/span>CMyDlg, CDialog<span class=\"br0\">)<br \/>\n<\/span>ON_MESSAGE<span class=\"br0\">(<\/span>DM_GETDEFID, OnGetDefID<span class=\"br0\">)<br \/>\n<\/span>&#8230;.<br \/>\n<span class=\"me1\">END_MESSAGE_MAP<\/span><span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"de1\">LRESULT CMyDlg<span class=\"sy4\">::<\/span><span class=\"me2\">OnGetDefID<\/span><span class=\"br0\">(<\/span>WPARAM wp, LPARAM lp<span class=\"br0\">)<br \/>\n<\/span>{<br \/>\n<span class=\"kw1\">return<\/span> MAKELONG<span class=\"br0\">(<\/span><span class=\"nu19\">0<\/span>,DC_HASDEFID<span class=\"br0\">)<\/span>;<br \/>\n}\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"de1\">\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"de1\"><span class=\"co1\">\/\/ 2nd approach.<br \/>\n<\/span><span class=\"kw4\">BOOL<\/span> DialogName<span class=\"sy4\">::<\/span><span class=\"me2\">PreTranslateMessage<\/span><span class=\"br0\">(<\/span>MSG<span class=\"sy2\">*<\/span> pMsg<span class=\"br0\">)<br \/>\n<\/span>{<br \/>\n\/\/ TODO: Add your specialized code here and\/or call the base class<br \/>\n<span class=\"kw1\">\u00a0 \u00a0 \u00a0if<\/span><span class=\"br0\">(<\/span>pMsg<span class=\"sy2\">&#8211;<\/span><span class=\"sy1\">&gt;<\/span>message<span class=\"sy1\">==<\/span>WM_KEYDOWN<span class=\"br0\">)<br \/>\n<\/span>\u00a0 \u00a0 {<br \/>\n<span class=\"kw1\">\u00a0 \u00a0 \u00a0 \u00a0 if<\/span><span class=\"br0\">(<\/span>pMsg<span class=\"sy2\">&#8211;<\/span><span class=\"sy1\">&gt;<\/span>wParam<span class=\"sy1\">==<\/span>VK_RETURN || pMsg<span class=\"sy2\">&#8211;<\/span><span class=\"sy1\">&gt;<\/span>wParam<span class=\"sy1\">==<\/span>VK_ESCAPE<span class=\"br0\">)<br \/>\n<\/span>\u00a0 \u00a0 \u00a0 \u00a0 {\n<\/div>\n<div class=\"de1\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0pMsg<span class=\"sy2\">&#8211;<\/span><span class=\"sy1\">&gt;<\/span>wParam<span class=\"sy1\">=<\/span><span class=\"kw2\">NULL<\/span> ;\n<\/div>\n<div class=\"de1\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0}\n<\/div>\n<div class=\"de1\">\u00a0 \u00a0 \u00a0}\n<\/div>\n<div class=\"de1\"><span class=\"kw1\">\u00a0 \u00a0 \u00a0return<\/span> CDialog<span class=\"sy4\">::<\/span><span class=\"me2\">PreTranslateMessage<\/span><span class=\"br0\">(<\/span>pMsg<span class=\"br0\">)<\/span>;\n<\/div>\n<div class=\"de1\">}\n<\/div>\n<div class=\"de1\">\n<\/div>\n<div class=\"de1\">\n<\/div>\n<div class=\"de1\">\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\uc6d0\uc778\uc740 Dailog\uc5d0\uc11c Enter\ub098 ESC\uac00 \ub20c\ub9ac\uba74 Event\ub97c \ucc3e\ub2e4\uac00 \uad6c\ud604\uc774 \uc5c6\uc73c\uba74 \ubd80\ubaa8\uc778 CDialog\uc758 SetDefID \ud568\uc218\ub97c \ubd80\ub974\ub294\ub370 \uc5ec\uae30\uc5d0 IDOK\uac00 \uad6c\ud604 \ub418\uc5b4 \uc788\uc5b4\uc11c \uadf8\ub7f0 \uac70\uc784.. \uc774\uac78 \ubc29\uc9c0 \ud558\uc790\uba74 \ubb34\uc2dd\ud558\uac8c VK_ENTER\ub4f1\uc73c\ub85c Key press\ub97c \ub9c9\ub294 \ubc29\ubc95\ub3c4 \uc788\uc9c0\ub9cc. \uc880\ub354 \uc6b0\uc544 \ud558\uac8c \uc6d0\uc778\uc744 \ucc3e\uc544 \ud574\uacb0 \ud558\uace0\uc790 \ud558\uba74 \uc544\ub798\uc640 \uac19\uc774 \ubd80\ubaa8\uc758\u00a0SetDefID\ub97c \ub0b4\uac00 \uad6c\ud604\ud574 \ubc84\ub9ac\uba74 \ub418\ub294\uac70\ub2e4.. \uc544\ub798\ub294 \uc778\ud130\ub137\uc5d0\uc11c \ucc3e\uc544\ub0b8 \uc6d0\uc778\uacfc \ud574\uacb0 \ubc29\ubc95 &nbsp; When the user presses Enter key in a dialog two things can happen: The dialog has a default control (see CDialog::SetDefID()). Then a WM_COMMAND with the ID of this control is sent to the dialog. The dialog does not have a default control. Then WM_COMMAND with ID = IDOK is sent to the dialog. With the first option, it may happen that the default control has a ID equal to IDOK. Then the results will be the same that in the second option. By default, class CDialog has a handler for the WM_COMMAND(IDOK) that is to call to CDialog::OnOk(), that is a virtual function, and by default it calls EndDialog(IDOK) that closes the dialog. So, if you want to avoid the dialog being closed, do one of the following. &nbsp; &nbsp; &nbsp; \/\/ 1st approach. http:\/\/msdn.microsoft.com\/en-us\/magazine\/cc301409.aspx &nbsp; BEGIN_MESSAGE_MAP(CMyDlg, CDialog) ON_MESSAGE(DM_GETDEFID, OnGetDefID) &#8230;. END_MESSAGE_MAP() &nbsp; LRESULT CMyDlg::OnGetDefID(WPARAM wp, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[9,19,7],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-6I","jetpack-related-posts":[{"id":305,"url":"https:\/\/blog.box.kr\/?p=305","url_meta":{"origin":416,"position":0},"title":"[MFC] \ub0b4\ubd80 \ucc3d\ub07c\ub9ac \uba54\uc2dc\uc9c0 \uc1a1\uc218\uc2e0","date":"2014-08-07","format":false,"excerpt":"\ud074\ub798\uc2a4\uac04 \ub370\uc774\ud130 \uc804\ub2ec\uc744 \ud558\ub294 \ubc29\ubc95\uc774 \ubb34\uc5c7\uc774 \uc788\uc744\uae4c. 1. \uc804\uc5ed\ubcc0\uc218 2. \ud5e4\ub354 include \ud6c4 \ubcc0\uc218 \uc811\uadfc 3. SendMessage SendMessage\ub97c \uc774\uc6a9\ud558\uba74 \ud074\ub798\uc2a4\uac04 \ub370\uc774\ud130 \uc804\ub2ec\uc774 \uc6a9\uc774\ud568\uc744 \uc54c\uace0, \uc0ac\uc6a9\ud574\ubcf4\uc558\ub2e4(\uba87\ubc88\uc758 \uc0bd\uc9c8\uacfc \ud568\uaed8...) ? 1 2 3 4 5 6 7 8 9 10 11 12 LRESULT SendMessage( \u00a0\u00a0\u00a0\u00a0UINT message, \u00a0\u00a0\u00a0\u00a0WPARAM wParam = 0, \u00a0\u00a0\u00a0\u00a0LPARAM lParam\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":271,"url":"https:\/\/blog.box.kr\/?p=271","url_meta":{"origin":416,"position":1},"title":"Placing Dialog at the center","date":"2014-07-26","format":false,"excerpt":"BOOL CTest11Dlg::OnInitDialog(){CDialog::OnInitDialog();CWnd* pWnd = GetDesktopWindow();CenterWindow(pWnd);return TRUE}","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":269,"url":"https:\/\/blog.box.kr\/?p=269","url_meta":{"origin":416,"position":2},"title":"Visual Studio 2010 \uc774\uc0c1 \uc5d0\uc11c OnInitDialog \ucd94\uac00\ud558\uae30","date":"2014-07-26","format":false,"excerpt":"\uad6c\uae00 \uac80\uc0c9\uacb0\uacfc visual studio 2010\uc5d0\uc11c \uba54\uc2dc\uc9c0 \ucc98\ub9ac\ud568\uc218\uc778 OnInitdialog \ub97c \ucd94\uac00 \ud558\ub294 \ubc29\ubc95\uc740 \ub450\uac00\uc9c0\uac00 \uc788\ub2e4. \ubc29\ubc95 1. 1. \ud074\ub798\uc2a4\ub97c \uc120\ud0dd\ud558\uc5ec \uc18d\uc131 \ucc3d\uc744 \uc5f0\ub2e4. 2. \uc7ac\uc815\uc758 \ud0ed\uc744 \uc120\ud0dd\ud55c\ub2e4. 3. \ub9ac\uc2a4\ud2b8\uc5d0\uc11c OnInitDialog \ub97c \uc120\ud0dd\ud558\uc5ec \ucd94\uac00\ud55c\ub2e4. \ubc29\ubc95 2. 1. \ud5e4\ub354 \ud30c\uc77c\uc758 \ud074\ub798\uc2a4\uc5d0 \uba54\uc11c\ub4dc \uc120\uc5b8\uc744 \ud55c\ub2e4. class \ud074\ub798\uc2a4\uba85::public CDialog { \uc0dd\ub7b5 protected: virtual BOOL OnInitDialog();\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":333,"url":"https:\/\/blog.box.kr\/?p=333","url_meta":{"origin":416,"position":3},"title":"[MFC] &#8211; \ud2b8\ub808\uc774 \uc544\uc774\ucf58 \ub4f1\ub85d \ubc0f \uc708\ub3c4\uc6b0 \uac10\ucd94\uae30","date":"2014-08-09","format":false,"excerpt":"\ucd9c\ucc98 :\u00a0http:\/\/hotangs.tistory.com\/28 \uc708\ub3c4\uc6b0 \uc6b0\uce21 \ud558\ub2e8\uc5d0 \ud2b8\ub808\uc774 \uc544\uc774\ucf58\uc744 \ub4f1\ub85d\ud558\ub294 \ubc29\ubc95\uc774\ub2e4. \uc6b0\uc120 \ud504\ub85c\uc81d\ud2b8\uc5d0 \ud604\uc7ac \ud2b8\ub808\uc774 \uc0c1\ud0dc\ub97c \uc54c\uc218 \uc788\ub294 BOOL \ubcc0\uc218\ub97c \uc120\uc5b8\ud55c\ub2e4. Protected \uc5d0 \uc120\uc5b8 \ubcc0\uc218 \uc774\ub984\uc740 m_bIsTrayIcon \ub85c \ud558\uaca0\ub2e4. \u00a0 \ub2e4\uc74c \ud2b8\ub808\uc774\uc544\uc774\ucf58\uc744 \ub4f1\ub85d\ud558\ub294 \ud568\uc218\ub97c \ub9cc\ub4e0\ub2e4. \ud568\uc218 \uc774\ub984\uc740 RegistTrayIcon \ub85c \ud558\uaca0\ub2e4. Private \ub85c \uc120\uc5b8 \uadf8\ub9ac\uace0 \ucf54\ub529\ud55c\ub2e4. void CTrayDlg::RegistTrayIcon() { NOTIFYICONDATA\u00a0 nid; nid.cbSize =\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"\u00ec\u0082\u00ac\u00ec\u009a\u00a9\u00ec\u009e\u0090 \u00ec\u0082\u00bd\u00ec\u009e\u0085 \u00ec\u009d\u00b4\u00eb\u00af\u00b8\u00ec\u00a7\u0080","src":"https:\/\/i0.wp.com\/cfs3.tistory.com\/upload_control\/download.blog?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":196,"url":"https:\/\/blog.box.kr\/?p=196","url_meta":{"origin":416,"position":4},"title":"MFC Dialog\ud504\ub808\uc784 \ubc14\uafb8\uae30","date":"2014-07-16","format":false,"excerpt":"\uc708\ub3c4\uc6b0\uc758 \ud504\ub808\uc784\uc740 \uc708\ub3c4\uc6b0\uc758 \uacbd\uacc4\ub97c \ub098\ud0c0\ub0b4\uba74\uc11c \ub3d9\uc2dc\uc5d0 \uc190\uc27d\uac8c \uc708\ub3c4\uc6b0\uc758 \ud06c\uae30\ub97c \ubcc0\uacbd\ud560 \ub54c\ub3c4 \uc4f0\uc778\ub2e4. \uc774 \ud504\ub808\uc784\uc744 \uc81c\uac70\ud558\uba74, \uc708\ub3c4\uc6b0 \uacbd\uacc4\uc9c0\uc810\uc5d0 \ub9c8\uc6b0\uc2a4 \ud3ec\uc778\ud130\ub97c \uc704\uce58\ud558\uace0 \ub4dc\ub798\uadf8\ud558\uba70 \uc708\ub3c4\uc6b0 \ud06c\uae30\ub97c \ubcc0\uacbd\ud558\ub294\uac83\uc774 \ubd88\uac00\ub2a5\ud574 \uc9c4\ub2e4. \uadf8\ub798\uc11c \uc774 \ubd80\ubd84\uc744 \uc0ac\uc6a9\uc790\uac00 \uc9c1\uc811 \uad6c\ud604\ud574 \uc8fc\uc5b4\uc57c \ud558\ub294\ub370, \uc774\ub7f0 \uc2a4\ud2b8\ub808\uc2a4\ub97c \ud53c\ud558\uae30 \uc704\ud574 \uc708\ub3c4\uc6b0 \ud504\ub808\uc784\uc744 \uadf8\ub0e5 \ud558\uc597\uac8c \uce60\ud574\ubc84\ub9ac\uac70\ub098 \uc6d0\ud558\ub294 \ubaa8\uc591\uc73c\ub85c \ubc14\uafb8\uc5b4 \uc8fc\ub294 \ubc29\ubc95\ub3c4 \uc788\ub2e4. \/\/WM_NCPAINT\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":198,"url":"https:\/\/blog.box.kr\/?p=198","url_meta":{"origin":416,"position":5},"title":"MFC \ud0c0\uc774\uba38","date":"2014-07-16","format":false,"excerpt":"\uc77c\uc815 \uc2dc\uac04 \ub4a4\uc5d0 \uc6d0\ud558\ub294 \uc5c5\ubb34\ub97c \ucc98\ub9ac\ud558\uae30 \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \ube44\uc2b7\ud55c \uae30\ub2a5\uc73c\ub85c Sleep( millisecond ) \ub97c \uc785\ub825\ud558\ub294\ub370\uc694. Sleep\uc744 \uc774\uc6a9\ud560 \uacbd\uc6b0 \ud574\ub2f9 \uc4f0\ub808\ub4dc \uc804\uccb4\uac00 \uba48\ucd94\uc5b4 \ubc84\ub9ac\uace0 \uadf8 \uba48\ucda4\uc5d0 \ub530\ub77c \uc678\ubd80 \uc778\ud130\ub7fd\ud2b8\uc785\ub825(\ud0a4\ubcf4\ub4dc, \ub9c8\uc6b0\uc2a4, \ub4f1\ub4f1)\uc774 \uc8fc\uc5b4\uc9c0\uac8c \ub418\uba74 \ubc84\ud37c\uc5d0 \uc313\uc600\ub2e4\uac00 \ud55c\ubc88\uc5d0 \ucc98\ub9ac\ub418\ub294 \uc77c\uc774 \ubc1c\uc0dd\ud558\uac8c \ub418\ubc84\ub9bd\ub2c8\ub2e4. \uadf8\ub798\uc11c \uadf8\uac78 \ubc29\uc9c0\ud558\uae30 \uc704\ud574 Timer\ub97c \uc0ac\uc6a9\ud558\ub294\ub370 \uc0ac\uc6a9\ubc29\ubc95\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. -\ub4f1\ub85d \u00a0BEGIN_MESSAGE_MAP(CGroupChatWindow, CDialog)\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/416"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=416"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/416\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}