Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2006.06.11;
Скачать: [xml.tar.bz2];

Вниз

торможу с 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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.013 c
6-1130738229
WildWind
2005-10-31 08:57
2006.06.11
cgi для загрузки файла


15-1147086622
homm
2006-05-08 15:10
2006.06.11
Traffic Compressor


2-1148380907
Ironman83
2006-05-23 14:41
2006.06.11
Литература


2-1148642335
novice06
2006-05-26 15:18
2006.06.11
ка кзаписать структуру в нетепизированный файл?


2-1148304847
Gagarin_MSX
2006-05-22 17:34
2006.06.11
Как циклически проследить выполнение?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский