Note that there are some explanatory texts on larger screens.

plurals
  1. PORich Edit Control changes the DialogBox return value behavior?
    text
    copied!<p>I'm a bit puzzled: i created a dialogbox with <code>Edit Control</code>, then i noticed the text isn't word wrapped, so i googled and found out that i should use <code>Rich Edit Control</code> instead. So i did. Now, when ever there is a <code>Rich Edit Control</code> in my dialog box, the functionality changes: without <code>Rich Edit Control</code> the dialogbox returned either <code>IDOK</code> or <code>IDCANCEL</code>, which i handle outside of the message handler code. BUT, if there is a <code>Rich Edit Control</code> anywhere in the dialogbox, it always returns something else than <code>IDOK</code>, before i even click any buttons in the dialog box: the dialogbox seems to not even be created at all.</p> <p>Here is the message handler:</p> <pre><code>INT_PTR CALLBACK MyDialogBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){ switch(message){ case WM_INITDIALOG: { SetDlgItemText(hDlg, IDC_EDIT1, (LPCTSTR)some_string.c_str()); return (INT_PTR)TRUE; } case WM_COMMAND: switch(LOWORD(wParam)){ case IDOK: case IDCANCEL: { EndDialog(hDlg, LOWORD(wParam)); return (INT_PTR)TRUE; } } break; } return (INT_PTR)FALSE; } </code></pre> <p>And here is the code where i use the dialogbox:</p> <pre><code>if(DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, MyDialogBox) == IDOK){ // without rich edit control it goes here or below depending on the user choice. }else{ // with rich edit it always goes here. } </code></pre> <p>So, the ultimate question here is: how do i get this thing work like it works with normal <code>Edit Control</code> ?</p> <p><strong>Edit:</strong> when it fails, the values are: -1 for DialogBox(), and 0 for GetLastError(), if that helps ?</p> <p><strong>Edit2:</strong> Problem solved by antinome's <a href="http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/c325a6ab-5e58-4970-a123-cda46fb096ff/" rel="nofollow">link</a>: include <code>afxwin.h</code> and call <code>AfxInitRichEdit2()</code> at the window <code>WM_CREATE</code> message.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload