Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 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.47 MB
Время: 0.032 c
2-1148142741
Мурзилка
2006-05-20 20:32
2006.06.11
1) Звук


1-1146815087
zhegulov
2006-05-05 11:44
2006.06.11
Формирование XML-файла


3-1145346379
Sanych_K_A
2006-04-18 11:46
2006.06.11
Ошибка при подключении к FireBird


1-1146834500
VEZ
2006-05-05 17:08
2006.06.11
TImage и гиперссылки


15-1147688857
07BB
2006-05-15 14:27
2006.06.11
XML+Java