• Advertisement
Sign in to follow this  

Win32 Rich Edit Control

This topic is 4684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm creating a Win32 rich edit control, I can create the control, but i can only use return, delete and backspace. I can't actually type any letters or numbers into the control and I don't know why. Bound to be a silly question ;)
DWORD Style = WS_CHILD | WS_VISIBLE | WS_HSCROLL |
		WS_VSCROLL | ES_LEFT | ES_MULTILINE |
		ES_AUTOHSCROLL | ES_AUTOVSCROLL;

m_hWnd = CreateWindowEx( NULL,
		RICHEDIT_CLASS,			// predefined class 
		NULL,		// text
		Style ,				// styles 
		m_iPosX,			// starting x position 
		m_iPosY,			// starting y position 
		m_iWidth,	// button width 
		m_iHeight,// button height 
		m_ParentWnd,				// parent window 
		NULL,				// No menu 
		(HINSTANCE) GetWindowLong(m_ParentWnd, GWL_HINSTANCE), 
		NULL);   

Share this post


Link to post
Share on other sites
Advertisement
still not sorted it out. Tried,


SendMessage(m_hWnd, EM_SETEVENTMASK, 0, ENM_CORRECTTEXT|ENM_CHANGE|ENM_UPDATE);

but the control recieves no event notifications and i have no idea why? I can set the text in the control by sending it a message, however i can only edit the text by deleting characters, inserting text just doesn't work :(

Share this post


Link to post
Share on other sites
I tried inserting your code into a simple test application and I can input text just fine. (For the test, I used version 1.0 of the control: RICHED32.DLL).

This suggests that the problem is not in the code you posted, but somewhere else. What does your message handler look like?

BTW: I suggest also adding ES_WANTRETURN to your style (unrelated to your problem, though).

[Edited by - Kippesoep on April 26, 2005 5:18:54 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

static dialog proc for all dialog boxes.


LONG CALLBACK MFWindow::DialogProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{

// iterate through window list to find the correct window and forward the messages
for(int i=0;i<ms_WindowList.size();i++)
{
if(ms_WindowList->GetWinHandle() == hDlg)
{
return ms_WindowList->LocalDialogProc(hDlg,message,wParam,lParam);
}
}
return FALSE;
}



which in turn sends the message to the correct window's local wnd proc


BOOL MFWindow::LocalDialogProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message)
{
case WM_COMMAND: {
return OnCommand(hDlg,message,wParam,lParam);
}
break;

case WM_NOTIFY: {
return OnNotify(hDlg,message,wParam,lParam);
}
break;

default:
break;
}
return DefWindowProc (hDlg, message, wParam, lParam) ;
}



which calls OnCommand or OnNotify to pass the messages down to the individual controls.


bool OnCommand(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) {
HWND ctrl = (HWND)lParam;
std::vector<MFControl*>::iterator it = m_ControlList.begin();
for( ; it != m_ControlList.end(); ++it ) {
if( (*it)->OnCommand(hDlg,message,wParam,lParam) )
return 1;
}
return false;
}

bool OnNotify(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) {
HWND ctrl = (HWND)lParam;
std::vector<MFControl*>::iterator it = m_ControlList.begin();
for( ; it != m_ControlList.end(); ++it ) {
if( (*it)->OnNotify(hDlg,message,wParam,lParam) )
return 1;
}
return false;
}



It works for everything apart from Edit Controls and Rich Edit controls which send no messages apart from delete and backspace. I'm really confused :(

Share this post


Link to post
Share on other sites
Is there anything that catches WM_KEYDOWN, WM_KEYUP or WM_CHAR?

Also, in your Peek/GetMessage loop, what are you specifying for the window handle?

BTW, if you're using DialogBox to display the dialog box, then you shouldn't use DefWindowProc, but DefDlgProc instead.

Share this post


Link to post
Share on other sites
I have a main openGL window, and then a set of child windows (not dialogs). My message despatching looks a bit like this :


// keep looping till done
while (!g_bWindowDestroyed)
{
// Success Creating Window. Check For Window Messages
if (PeekMessage (&msg, g_hWnd, 0, 0, PM_REMOVE) != 0)
{
// Check For WM_QUIT Message
if (msg.message != WM_QUIT)
{
DispatchMessage (&msg);
}
else
{
break;
}
}
else {

// check messages of child windows
MFWindow::DoMessageLoop();

// draw our scene
Draw();
}
}



the MFWindow::DoMessageLoop() function walks over the list of currently created child windows (it's scriptable) and calls the member function:


void MFWindow::MessageLoop() {
MSG msg;
if (PeekMessage(&msg,m_hWnd,0, 0, PM_REMOVE)) {
DispatchMessage (&msg);
}
}



I've checked for WM_KEYDOWN, WM_KEYUP and WM_CHAR in the main windows WndProc, the child windows WndProc and none of them get triggered?

Share this post


Link to post
Share on other sites
Do NOT call DefWindowProc in your MFWindow::LocalDialogProc implementation. The DialogProc is conceptually different from a window proc. Just return FALSE if you didn't process the message. Windows will then pass the message on to the dialogs real window proc which is hidden from you.

Share this post


Link to post
Share on other sites
erm. I assume windows created with CreateWindowEx() would be windows and those created with CreateDialog() would be dialogs, in which case, i'm using windows.

Share this post


Link to post
Share on other sites
Quote:
Original post by RobTheBloke
I assume windows created with CreateWindowEx() would be windows and those created with CreateDialog() would be dialogs, in which case, i'm using windows.


The terminology is off a bit, but you're using it correctly, hence my question about the dialog procedure.

About your message loop: don't put a window handle in there. Use NULL instead. For a detailed explanation, read this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement