home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- Path: sparky!uunet!caen!sol.ctr.columbia.edu!cortex.prospect.com!mboucher
- From: mboucher@cortex.prospect.com (Mike Boucher)
- Subject: scroll bar in dialog problem
- Organization: Cortex Corporation, Waltham, MA, USA
- Message-ID: <1992Aug20.143044.1@cortex>
- Lines: 49
- Sender: news@ctr.columbia.edu (The Daily Lose)
- Date: Thu, 20 Aug 1992 19:30:44 GMT
- X-Posted-From: cortex.prospect.com
- X-Posted-Through: sol.ctr.columbia.edu
-
- Hey there,
-
- I have a dialog box with scroll bars. When the dialog box gets created,
- the scroll bars are invisible, as they should be. It is quite easy to
- scroll part of the window off the top such that you cannot get it back!
-
- First, here is some of my code for WM_SIZE, basically the same as
- Petzold, the knowledge base here on CS, SDK manuals, etc...
-
- case WM_SIZE:
- nVertSize = HIWORD(lParam);
- nHorzSize = LOWORD(lParam);
-
- nVertScrollMax = max (0, nDlgVertSize - nVertSize);
- nVertScrollPos = min (nVertScrollMax, nVertScrollPos);
- SetScrollRange(hDlg, SB_VERT, 0, nVertScrollMax, FALSE);
- SetScrollPos(hDlg, SB_VERT, nVertScrollPos, TRUE);
-
- ... same idea for horizontal ...
-
- Here are the steps to recreate the problem:
-
- 1) Size the window, making it vertically smaller. Get a WM_SIZE message.
- 2) Determine if scroll bars should be created. They should, so activate
- them.
- 3) I then jump back to the top of the WM_SIZE code, as I just recieved
- a new WM_SIZE, since adding scroll bars changes the size of the window.
- 4) Scroll down to the bottom of the window. (eg: scroll position = 50)
- 5) Size the window again, this time making it LARGER than the full size
- 6) The max scroll will be 0, since the window is larger than neccesary,
- therefore the scroll position WILL be 0, since the minumum of whatever it
- was and 0 will be 0.
- 7) When you SetScrollRange and pos as 0, the scroll bars dissapear, and
- whatever you scrolled off the top is gone forever!
-
- The other alternative is to never change the scroll range. This will
- allow the user to scroll everything off the window, and look at white
- space. This, in my opinion, is absolutely useless. If there is nothing
- there, you should not be allowed to scroll to it.
-
- Any ideas on what I can do to avoid this problem would be appreciated.
-
- thanx.
-
- Mike
- --
- Mike Boucher mboucher@cortex.prospect.com
- Cortex Corp "Don't take life too seriously, you'll never
- Waltham, MA, USA get out of it alive!"
-