[comp.sys.mac.programmer] UpdateMyWindow

rapickering@miavx1.acs.muohio.edu (11/10/90)

Got a problem.

I've written a program that displays the contents of a linked list in 
a window of my design.  

The problem:  I need to be able to update the window.
              I use ShowWindow() and HideWindow(), I realize I could just
close the window and re-open it, but that's really silly.  

I have the Mac Prog Primer, but it doesn't help for what I'm doing.

Anyone have a 'standard' way of updating a window.  I just want to erase the
whole thing everytime I call my display function.

Thanks in advance.

-- 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Rob Pickering
                                            
internet:  pickerin@apsvax.aps.muohio.edu      \ Preferred
           rapickering@miavx1.acs.muohio.edu   /
bitnet  :  pickerin@miamiu.bitnet              - Not bad
NeXT: pickerin@next4.acs.muohio.edu            - Don't read, but there's voice
 
"I'm working on a campaign to take all the salt out of the ocean,
 I think the fish are getting high blood pressure."     -Steven Wright
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

stevec@Apple.COM (Steve Christensen) (11/10/90)

rapickering@miavx1.acs.muohio.edu writes:
>[...]
>The problem:  I need to be able to update the window.
>              I use ShowWindow() and HideWindow(), I realize I could just
>close the window and re-open it, but that's really silly.  
>
>Anyone have a 'standard' way of updating a window.  I just want to erase the
>whole thing everytime I call my display function.

How about setting up your update routine like this?

	void UpdateMyWindow(WindowPtr theWindow) {

	  SetPort(theWindow);
	  BeginUpdate(theWindow);

	  EraseRect(&theWindow->portRect);

	  // do any drawing here

	  EndUpdate(theWindow);
	}

steve

peted@microsoft.UUCP (Peter DUNIHO) (11/15/90)

In article <2828.273adecd@miavx1.acs.muohio.edu> rapickering@miavx1.acs.muohio.edu writes:
>Got a problem.
>
>I've written a program that displays the contents of a linked list in 
>a window of my design.  
>
>The problem:  I need to be able to update the window.
>              I use ShowWindow() and HideWindow(), I realize I could just
>close the window and re-open it, but that's really silly.  
>
>I have the Mac Prog Primer, but it doesn't help for what I'm doing.
>
>Anyone have a 'standard' way of updating a window.  I just want to erase the
>whole thing everytime I call my display function.
>
>Thanks in advance.
>
>-- 
>Rob Pickering
>                                            
>internet:  pickerin@apsvax.aps.muohio.edu      \ Preferred
>           rapickering@miavx1.acs.muohio.edu   /

Well, I'm fighting with vi here (I dunno what's got into it
today), so please excuse any messy things... :)

Anyway, it depends on what you mean.  If you are just trying to
generate an update event so that some other redrawing routine
can deal with the actual update, you can use InvalRect on the
entire window...whether or not to EraseRect the rect is up to
you, but you ought to either do it with the InvalRect or in the
update routine (to get rid of any old drawing)...

See the response made by another netter if what you want to do
is actually redraw the thing.  (I would, however, recommend limiting
drawing to when an update event is generated, and use the InvelRect
to force one when the data changes.  This IMHO is better as long
as update speed isn't crucial (real-time display would probably require
another method, such as the one suggested elsewhere)).

Pete D

uunet!microsoft!peted