Uso un RxRichEdit para un mini-editor de texto.
Mi problema me surge a la hora de que se quiera justificar un texto. Encontré un procedimiento que me justifica perfectamente. Es el siguiente:
delphi
procedure TMainForm.Justificado(Editor: TRxRichEdit; AllText: Boolean); const TO_ADVANCEDTYPOGRAPHY = $1; EM_SETTYPOGRAPHYOPTIONS = (WM_USER + 202); EM_GETTYPOGRAPHYOPTIONS = (WM_USER + 203); var ParaFormat : TParaFormat; SelStart, SelLength : Integer; begin ParaFormat.cbSize := SizeOf(ParaFormat); if SendMessage(Editor.Handle, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY) = 1 then begin SelStart := Editor.SelStart; SelLength:= Editor.SelLength; if AllText then Editor.SelectAll; ParaFormat.dwMask := PFM_ALIGNMENT; ParaFormat.wAlignment := PFA_JUSTIFY; SendMessage(Editor.handle, EM_SETPARAFORMAT, 0, LongInt(@ParaFormat)); Editor.SelStart := SelStart; Editor.SelLength := SelLength; end; end;
Guardo los textos porque después necesito utilizarlos. Hasta ahí perfecto. Mi problema viene cuando abro un texto en el RxRichEdit ya guardado y justificado, no me aparece justificado. Aunque realmente si lo está porque lo abro con otro editor de textos (word) y lo muestra bien.
Tengo claro que el componente tiene por defecto la propiedad Alignment que contiene estos tres valores: taLeftJustify, taRightJustify, taCenter. Pero no el justificado. Con lo cual habrá que cambiar la unidad 'RxRichEd' para que acepte también el justificado.
delphi
TParaAlignment = (paLeftJustify, paRightJustify, paCenter, paJustify); . . . PFA_JUSTIFY = 4;
Con esto sólo evidentemente no me funciona. He intentado encontrar donde exactamente alinea los párrafos para llamar a la función de justificado pero no lo he conseguido. He probado mil cosas sin resultado. Se les ocurre donde puedo hacerlo.
Alguna idea al respecto. Gracias.