Pregunta: | 49476 - UN SCROLLBAR CON UN MEMO Y RICHEDIT |
Autor: | roberto rangugni |
me gustaria manejar con en mismo scrollbar un memo y un richedit al mismo tiempo que estan puestos los dos uno al lado del otro.. de manera de ver las mismas lineas al mismo tiempo.. |
Respuesta: | José Cantó |
pon este codigo en cada memo y/o richedtit que quieras mover "al mismo tiempo" cambiando la clase para cada tipo de control.
procedure TFMain.wwDBRichEdit19SelectionChange(Sender: TObject); var i: integer; tmpControl: TControl; PrimeraLinea: integer; Salto: integer; begin if Moviendo then exit; Moviendo:= True; try PrimeraLinea:= SendMessage(TwwDBRichEdit(Sender).Handle,EM_GETFIRSTVISIBLELINE,0,0); for i:= 0 to TControl(Sender).Parent.ControlCount -1 do begin if Sender <> TControl(Sender).Parent.Controls[i] then begin tmpControl:= TControl(Sender).Parent.Controls[i]; if tmpControl.ClassType = TwwDBRichEdit then begin Salto:= SendMessage(TwwDBRichEdit(tmpControl).Handle,EM_GETFIRSTVISIBLELINE,0,0); Salto:= PrimeraLinea - Salto; SendMessage(TwwDBRichEdit(tmpControl).Handle,EM_LINESCROLL,0,Salto); end; end; end; finally Moviendo:= False; end; end; la variable MOVIENDO es global a la unidad. |