Текущий архив: 2006.06.11;
Скачать: CL | DM;
Вниз
торможу с RichEdit %) Найти похожие ветки
← →
MetalFan © (2006-05-03 14:57) [0]устанавливаю выделенному тексту CharFormat
var
lCharFormat: TCharFormat2;
begin
ZeroMemory(@lCharFormat, SizeOf(TCharFormat2));
lCharFormat.cbSize := SizeOf(TCharFormat2);
lCharFormat.dwMask := CFM_PROTECTED;
lCharFormat.dwEffects := CFE_PROTECTED;
if SendMessage( RichEdit1.Handle, EM_SETCHARFORMAT, SCF_SELECTION, Cardinal(@lCharFormat) ) = 0 then
ShowMessage("Error");
все нормально, выделенный текст становится "защищенным"
пытаюсь "снять":var
lCharFormat: TCharFormat2;
begin
ZeroMemory(@lCharFormat, SizeOf(TCharFormat2));
lCharFormat.cbSize := SizeOf(TCharFormat2);
SendMessage( RichEdit1.Handle, EM_GETCHARFORMAT,SCF_SELECTION , Cardinal(@lCharFormat) );
lCharFormat.dwMask := (CFM_PROTECTED){0};
lCharFormat.dwEffects := 0;
//CharFormat.dwEffects := CharFormat.dwEffects and not CFE_PROTECTED;
if SendMessage( RichEdit1.Handle, EM_SETCHARFORMAT,SCF_SELECTION , Cardinal(@lCharFormat) ) = 0 then
ShowMessage("Error");
получаю ошибку при любом раскладе...
в чем проблема то? как снять CFM_PROTECTED с текста?
← →
MBo © (2006-05-03 15:03) [1]из b.p.d.winapi:
I am confused : I"ve just tried it again and it does not remove the
protection, as you stated in your message. After tracing the code, it seems
that the problem lies within Windows and not the Delphi VCL, so using
straight API will not help resolve the probelm.
The only solution that I"ve found to correct the problem, is by handling
the EN_PROTECTED notification. Follows an axample that handles the message
at the form level. Another possibility for you would be to create your own
descendant from TRichEdit and handle the EN_PROTECTED at the control level.
type
TForm1 = class(TForm)
.....
private
IsProtected : Boolean;
public
procedure WMNotify(var Msg : TWMNotify );message
WM_NOTIFY;
end;
procedure TForm1.WMNotify(var Msg : TWMNotify );
begin
with Msg.NMHdr^ do
begin
if hwndFrom = RichEdit1.Handle then //from the rich edit control
begin
if Code = EN_PROTECTED then //protected notification from the rich
edit
begin
Msg.Result := Integer(IsProtected);//allow/disallow editing
EXIT;
end;
end;
end;
inherited;
end;
//switch protection
procedure TForm1.Button1Click(Sender: TObject);
begin
IsProtected := not IsProtected;
RichEdit1.SelAttributes.Protected := IsProtected;
end;
HTTIH (hope this time it helps)
Atanas
← →
MetalFan © (2006-05-03 15:08) [2]мда. мне такой подход не нравится, но видимо деваться некуда!
спасибо MBo
Страницы: 1 вся ветка
Текущий архив: 2006.06.11;
Скачать: CL | DM;
Память: 0.45 MB
Время: 0.01 c