ScrollWindowEx函数不能正确显示滚动条滚动后内容?

lc19890326 2009-06-14 07:18:14
在处理WM_VSCROLL的时候,按照一般做法,先处理了各种SB_LINEDOWN SB_LINEUP等消息设定了滚动条的位置,最后使用ScrollWindowEx函数产生重画消息,WM_PAINT也写好了
调用如下

ScrollWindowEx(hwnd,0,cyChar*(iVertPos-si.nPos),NULL,NULL,NULL,NULL,SW_SMOOTHSCROLL);
UpdateWindow(hwnd);


但发现这样的程序出来发现一拉动滚动条显示区域就白了,此时将窗口最小化一下或者用其他窗口遮挡一下内容又出来了。
如果换成SW_INVALIDATE可以显示,但字符有些错乱
我想这都是因为滚动之后重画没有成功的原因
是不是我调用这个函数哪里存在问题?请问这个应该怎么改正?

...全文
118 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lc19890326 2009-06-16
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 Loaden 的回复:]
InvalidateRect
[/Quote]
谢谢 这样确实是可行的
大哥能否讲下原理
UpdateWindow是直接产生WM_PAINT,并且不放入消息循环
而InvalidateRecr也是直觉产生WM_PAINT,但放入消息循环
为什么不能换用呢?
「已注销」 2009-06-15
  • 打赏
  • 举报
回复
InvalidateRect
The InvalidateRect function adds a rectangle to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn.

BOOL InvalidateRect(
HWND hWnd, // handle to window
CONST RECT* lpRect, // rectangle coordinates
BOOL bErase // erase state
);
Parameters
hWnd
[in] Handle to the window whose update region has changed. If this parameter is NULL, the system invalidates and redraws all windows, and sends the WM_ERASEBKGND and WM_NCPAINT messages to the window procedure before the function returns.
lpRect
[in] Pointer to a RECT structure that contains the client coordinates of the rectangle to be added to the update region. If this parameter is NULL, the entire client area is added to the update region.
bErase
[in] Specifies whether the background within the update region is to be erased when the update region is processed. If this parameter is TRUE, the background is erased when the BeginPaint function is called. If this parameter is FALSE, the background remains unchanged.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT/2000/XP: To get extended error information, call GetLastError.

「已注销」 2009-06-15
  • 打赏
  • 举报
回复
InvalidateRect
lc19890326 2009-06-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 Proteas 的回复:]
给指定窗口发一个 WM_PAINT 消息呢?
[/Quote]
我在后面调用了updatewindow,应该是立即产生并响应WM_PAINT消息的吧 ?
derek02 2009-06-15
  • 打赏
  • 举报
回复
学习。。。up
Proteas 2009-06-14
  • 打赏
  • 举报
回复
给指定窗口发一个 WM_PAINT 消息呢?

70,019

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧