home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 20001 < prev    next >
Encoding:
Text File  |  1992-12-18  |  4.0 KB  |  85 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uwm.edu!spool.mu.edu!umn.edu!csus.edu!netcom.com!friedman
  3. From: friedman@netcom.com (Greg Friedman)
  4. Subject: Mark Manning: Scrolling Dlogs
  5. Message-ID: <1992Dec17.234008.20887@netcom.com>
  6. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  7. Date: Thu, 17 Dec 1992 23:40:08 GMT
  8. Lines: 75
  9.  
  10. Mark - I tried to e-mail this response to you directly, but
  11. mail kept bouncing.  Anyhow, here is additional info on
  12. creating scrolling dlogs.  Hope this helps:
  13.  
  14. First off - the code I sent you was from one of my first attempts
  15. at Mac programming. If I were writing the same app today, I would
  16. not using scrolling dialogs.  I would use windows and text boxes.
  17. That's one possible solution, though I doubt it would be trivial
  18. for you to convert at this point.
  19.  
  20. There was a reason that MoveControl didn't work for me. Unfortunately,
  21. I didn't comment on it in the code, and I can't remember why now.
  22.  
  23. Calling GetDItem/SetDItem is not the solution.  SetDItem expects
  24. a handle to an item in the ditl list, not a control handle. I
  25. would expect it to crash in this case.
  26.  
  27. Oh yeah, now I remember why I didn't call MoveControl.  MoveControl
  28. erases and redraws controls as they are being moved. It may even
  29. disable them.  It looked very ugly in a scrolling dialog, and not
  30. at all smooth. (Be aware that scrolling dialogs are a WEIRD idea!).
  31. The shift control function I sent you basically does it's own move
  32. control by walking the controlList of a window and shifting each
  33. control by walking the controlList of a window and shifting each
  34. control up a specified number of pixels. It only shifts vertically, so
  35. if you're scrolling horizontally, you'll have to make what should be
  36. obvious changes.
  37.  
  38. If you are working in a development environment that supports interactive
  39. debuggin, break in shift controls and take a look at the control
  40. handles you are attempting to use when alter the rects.  If they
  41. are bogus, you may have the wrong windowPtr.
  42.  
  43. Here, in summary, is the sequence that works for me:
  44.  
  45. Assume a hit on the down button:
  46.  
  47. SetCtlValue() //increment the ctlValue by your index
  48. ShiftControls() //move all of the controls in the window
  49.                 // they won't be redrawn at this point, but their rects
  50.                 // will be updated.
  51. SetRect() //set up a local var rect that you want to scroll.
  52.           //make sure to remove the scroll bars from your rect
  53.           //rect.right  = windowRect.right - 15, etc.
  54. ScrollRect() // scroll the rect the correct number of pixels.
  55. SetOrigin() // now set the origin of the rect as I did in the sample
  56.             // code I sent you.  Otherwise dialog item offsets will
  57.             // be screwed and the dlog mgr will draw everything in
  58.            // the wrong place.
  59. SetRect() // set up a new rect that includes everything but the
  60.           // scrollbars.  Relative offsets have changed, so you
  61.           // have to do this again.
  62. ClipRect() // send in the rect you just made. Do this so when you
  63.            // call drawDialog, scroll bars aren't drawn.
  64. DrawDialog() //send in the dlogPtr
  65. ValidRect() // send the windows Rect (get the portRect from the structure
  66.            // pointed to by the GrafPtr
  67.  
  68. That works for me.  I don't know why you are crashing.  It probably
  69. means you are using a bogus address somewhere along the line.  You'll
  70. have to debug it.  Make sure that you have set the port to the dlog
  71. you want to scroll.  If you aren't calling SetPort() with the dlog
  72. pointer, that could be the source of your problem.  I suggest stepping
  73. through the code and looking at the window pointers and control handles
  74. you are passing around.  Make sure they point to the structures you
  75. think they do.  If you can't tell which control is which, put some
  76. identifying information into the refCon field of each control.  During
  77. the shift process, check it out in your source level debugger or
  78. MacsBug.  Happy bug hunting!
  79.  
  80. Let me know if I can answer any other ?'s.  I'm happy to try.  
  81.  
  82. Best,
  83.  
  84. Greg 
  85.