要实现的功能是鼠标滚动的时候,另一个richedit也同步滚动,用下面的代码似乎SendMessag发的一些消息丢掉了,导致来回滚动几次之后两个richedit就不同步了,差了几行,点击一下一边的滚动条就可以跳到同一行
请教一下高手怎么解决这个问题,困惑很久了...
if (Msg.Msg=WM_MOUSEWHEEL) and RedtBeforeModify.Focused then
SendMessage(RedtAfterModify.Handle,Msg.Msg,Msg.WParam,Msg.LParam);
请教一下高手怎么解决这个问题,困惑很久了...
if (Msg.Msg=WM_MOUSEWHEEL) and RedtBeforeModify.Focused then
SendMessage(RedtAfterModify.Handle,Msg.Msg,Msg.WParam,Msg.LParam);
解决方案 »
- 如何先捕获后台错误
- 收到 “美国Borland软件公司北京代表处” 的传真,要钱来了
- 没分了..往timer里加for为什么会出现系统当机??
- 如何实现世界时和北京时的转换?
- midas中登录Dcom时的用户问题
- Corrupt file-other than header是什么意思?
- 怎样调用 颜色公共对话框? 谢谢
- 关于三层应用服务器中调用存储过程的问题
- 大家好!!sql怎么样限制显示第十条至二十条记录的问题的问题!!!!
- delphi qry 的 onGetText 中用sender 会报错 访问冲突。求大神指教
- 求Access数据库SQL语句
- 如何用delphi做一个程序,可以打开某个网页
if (Msg.Msg=WM_MOUSEWHEEL) and RedtBeforeModify.Focused then
begin
ActiveControl := RedtAfterModify;
RedtAfterModify.perform(Msg.Msg,Msg.WParam, Msg.LParam);
end;
PS: I haven't tested this code, but above provided snippet should work.Let me know how it goes.Thanks,Ali
Type
TYourRichEdit = Class(TRichEdit)
private
fOnTimer : TNotifyEvent;
procedure DoTimer(var Message: TMessage); message WM_TIMER;
published
property fOnTimer : TNotifyEvent read fOnTimer write fOnTimer;
end;procedure TYourRichEdit.DoTimer(var Message: TMessage);
begin
if Assigned(fOnTimer) then fOnTimer(Self);
end;注册该类,拖到Form上,
然后在该对象的OnTimer里写上var
n : integer;
begin
n := GetScrollPos(YourRichEdit1.Handle , SB_VERT);
SetScrollPos(RichEdit2.Handle , SB_VERT , n , True);
end;其实就是响应 WM_TIMER事件
var
n : integer;
begin
n := GetScrollPos(YourRichEdit1.Handle , SB_VERT) SHL 16 + SB_THUMBPOSITION;
SendMessage(RichEdit2.Handle , WM_VSCROLL , n , 0);
end;