Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why is SetScrollInfo Sending WM_SIZE?

314 views
Skip to first unread message

Larry Lindstrom

unread,
Dec 11, 2002, 1:31:11 PM12/11/02
to
Hello Experts:

I'm building a little scrolling text box, using the Petzold
book as a guide.

I'm working only on the vertical scroll bar now. I'll add
the horizontal scrollbar when this is working.

I have scroll set to be invisible until needed.

As I add text to be displayed I call SetScrollInfo to update
the nMax value. I'll want the thumb bar to reflect the size
of the data, so SetScrollInfo's Redraw is passed as true.

The problem is that SetScrollInfo() is passing WM_SIZE to
WinProc() with a new smaller width, by 20 pixels, that
reflects the size it would be if the scroll bar is displayed.
But this is when only a couple of lines are displayed and the
scrollbar isn't needed. SetScrollInfo then makes a second
call is then made to WinProc passing a WM_SIZE with a width
that is 20 pixels larger, returning the client area width to
the size it had before I called SetScrollInfo.

This causes me several concerns. First, I didn't
design the code to be recursive. My WM_SIZE processing also
calls SetScrollInfo(), which sounds to me like I may be
looking at some endless recursion trap.

I'm planning on setting a flag when calling SetScrollInfo()
and clearing it upon return, so my WM_SIZE process can decide
if this is a "real" resize.

Is there a better method of dealing with this?

Thanks
Larry

Scott McPhillips

unread,
Dec 11, 2002, 2:01:07 PM12/11/02
to

It's pretty hard to know when the "real" WM_SIZE comes in. Also, there
are several other causes of spurious WM_SIZE messages. I've given up on
it and set the scroll info in WM_PAINT instead. When you get that the
size has settled and is available with GetWindowRect or GetClientRect.

--
Scott McPhillips [VC++ MVP]

Larry Lindstrom

unread,
Dec 12, 2002, 6:04:49 AM12/12/02
to
Scott McPhillips wrote:
>
> Larry Lindstrom wrote:

< Snip >

> It's pretty hard to know when the "real" WM_SIZE comes in. Also, there
> are several other causes of spurious WM_SIZE messages. I've given up on
> it and set the scroll info in WM_PAINT instead. When you get that the
> size has settled and is available with GetWindowRect or GetClientRect.

Thanks Scott:

I'm going to do my resize processing with a call to GetClientRect()
in the WM_PAINT clause, as you suggest.

Do you service the WM_SIZE message in WndProc()?

Larry

Scott McPhillips

unread,
Dec 12, 2002, 9:53:27 PM12/12/02
to
Larry Lindstrom wrote:
> > It's pretty hard to know when the "real" WM_SIZE comes in. Also, there
> > are several other causes of spurious WM_SIZE messages. I've given up on
> > it and set the scroll info in WM_PAINT instead. When you get that the
> > size has settled and is available with GetWindowRect or GetClientRect.
>
> Thanks Scott:
>
> I'm going to do my resize processing with a call to GetClientRect()
> in the WM_PAINT clause, as you suggest.
>
> Do you service the WM_SIZE message in WndProc()?
>
> Larry

Yes, if there are child windows to manage. Moving them around generates
WM_PAINT, and one doesn't want to do that in WM_PAINT (!)

0 new messages