Tech Support > Microsoft Windows > Development Resources > Richedit MFC
Richedit MFC
Posted by John Carson on November 29th, 2003


"Przemo Drochomirecki" <pedrosch@gazeta.pl> wrote in message
news:bqamcr$ja3$1@nemesis.news.tpi.pl
I don't know how to do it in MFC, but the following is a win32 solution that
appears to work and which you might adapt. I subclass the window procedure
of the rich edit control and replace it with the following window procedure.
It kills off WM_MOUSEMOVE and WM_LBUTTONDBLCLK processing (to stop selection
with the mouse) and modifies WM_KEYDOWN processing to change the key state
of the shift key so that it does not register as being down (to turn off
selection with the arrow keys).


LRESULT CALLBACK RichEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch(message)
{
case WM_MOUSEMOVE:
case WM_LBUTTONDBLCLK:
return 0;
case WM_KEYDOWN:
if (wParam == VK_SHIFT
|| wParam == VK_LSHIFT
|| wParam == VK_RSHIFT)
{
BYTE array[256];
GetKeyboardState(array);
array[VK_SHIFT] = array[VK_LSHIFT] = array[VK_RSHIFT] = 0;
SetKeyboardState(array);
}
break;
}
return CallWindowProc(oldRichEditProc, hwnd, message, wParam, lParam);
}



--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)


Posted by Przemo Drochomirecki on November 30th, 2003


hello,
let's consider we have array of english words (unsigned char [20])
and we wish to print them in richedit but only for reading, (without
possibility of copy and paste - how to do it? switch off selection- but
how?)
but some letters in some words could have different colour.
does anyone know how to do it effectively?

best regards
Przemo

p.s. the length of the array may be very huge >1.000.000 words




Posted by Ali R. on December 1st, 2003


Create the RichEdit control with the ReadOnly Flag. If that's not enough do
this :

// CReadOnlyRich message handlers

BOOL CReadOnlyRich::PreTranslateMessage(MSG* pMsg)

{

// always hide the caret

HideCaret();

// catch all mouse messages

if (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)

{

// set focus in order to scroll

SetFocus();

// let the mouse wheel message through

if (pMsg->message == WM_MOUSEWHEEL)

return FALSE;

return TRUE;

}

return FALSE;

}



void CReadOnlyRich::OnSetFocus(CWnd* pOldWnd)

{

if (pOldWnd)

pOldWnd->SetFocus();

}

"Przemo Drochomirecki" <pedrosch@gazeta.pl> wrote in message
news:bqamcr$ja3$1@nemesis.news.tpi.pl...


Posted by Przemo Drochomirecki on December 2nd, 2003


hi,
thanks for you and John, unfortunatelly, i don't understand both
solution...i even don't know how to use them
in MFC structures. so my problem is still open

but i've found solution for main problem know i convert list of words to rft
and display it using streams, but
here another problem occurs: in windows 2000, there's a kinda absurd limit
for rtf size. maybe you know how to avoid it?

best regards
Przemo



Similar Posts