home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / mswindo / programm / misc / 1415 < prev    next >
Encoding:
Text File  |  1992-08-20  |  2.4 KB  |  62 lines

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