[comp.sys.mac.programmer] Window Manager Problem...

pfile@cory.Berkeley.EDU (Rob Pfile) (06/14/89)

I am using LSC 3.0 to finally begin programming on the Mac.
I have a Mac II with 2MB memory...

I am having a problem calling SetWindowPic() from LSC.

I have generated a PICT, and have a handle to the picture, as well
as a pointer to a window...

WindowPtr window2;
PicHandle myPicHandle;

SetWindowPic(window2,myPicHandle);

has no effect on the window's grafport, according to LSC's debugger.
I tried using casts to make sure the function was getting the right
types, but that did not work either....

What gives here? I know the version of LSC is a bit old, but I have not 
upgraded yet. Is this the problem?

What I am trying to do here is play around with different ways to 
save images in windows for refresh during updateevents and activateevents.

I have already managed to save the image in an offscreen PixMap, but
I was just trying out different techniques.

Does anyone know what the fastest way to restore and save pixmap data
from the screen? Would if be faster to record a PICT or use the Offscreen
techniques?

Thanks. I'm totally stumped.

Rob Pfile

pfile@cory.berkeley.edu
...!ucbvax!cory!pfile

mnkonar@gorby.SRC.Honeywell.COM (Murat N. Konar) (06/15/89)

In article <14618@pasteur.Berkeley.EDU> pfile@cory.Berkeley.EDU (Rob Pfile) writes:
>
>I am having a problem calling SetWindowPic() from LSC.
>
Background: IM says that if the WindowPic field of the window record is not nil,
the window manager will use the PICT pointed to by WindowPic for updates instead 
of reporting an update event to your application.  The way to do this is by using
SetWindowPic.

I could never get this to work under LSP 1.11 on a Mac II.  Never tried it using
LSP 2.x, but I suspect that the problem lies with the window manager and not with 
the development system.

____________________________________________________________________
Have a day. :^|
Murat N. Konar        Honeywell Systems & Research Center, Camden, MN
mnkonar@SRC.honeywell.com (internet) {umn-cs,ems,bthpyd}!srcsip!mnkonar(UUCP)

lsr@Apple.COM (Larry Rosenstein) (06/15/89)

In article <14618@pasteur.Berkeley.EDU> pfile@cory.Berkeley.EDU (Rob 
Pfile) writes:
> SetWindowPic(window2,myPicHandle);
> 
> has no effect on the window's grafport, according to LSC's debugger.

The picture field is in the Window Manager portion of the data.  WindowPtr 
is declared as being the same as a grafPort, so if LSC is using this 
definition as the basis of what to show, then you won't see any change.

If you cast the WindowPtr to a WindowPeek, then you should see the change. 
 (I haven't used LSC, but in LSP 2.0, there is a debugging tool to cast a 
value to a different type.)

Larry Rosenstein, Apple Computer, Inc.
Object Specialist

Internet: lsr@Apple.com   UUCP: {nsc, sun}!apple!lsr
AppleLink: Rosenstein1

tim@hoptoad.uucp (Tim Maroney) (06/15/89)

In article <2375@internal.Apple.COM> lsr@Apple.COM (Larry Rosenstein) writes:
>The picture field is in the Window Manager portion of the data.  WindowPtr 
>is declared as being the same as a grafPort, so if LSC is using this 
>definition as the basis of what to show, then you won't see any change.

Clever!  I was wondering what problem he was having -- I have used
SetWindowPic and it works.  However, note that after calling it on a
window that's already visible, he will need to do an
"InvalRect(&window->portRect);" to get the window redrawn.

>If you cast the WindowPtr to a WindowPeek, then you should see the change. 
> (I haven't used LSC, but in LSP 2.0, there is a debugging tool to cast a 
>value to a different type.)

The LSC debugger lets you display the value of any expression with no
side effects, so the proper structure can be viewed simply by typing
in the type cast -- i.e., "((WindowPeek)window)->windowPic".
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com
Postal: 424 Tehama, SF CA 94103; Phone: (415) 495-2934

"What's bad? What's the use of turning?
 In Hell I'll be there a-burning!
 Meanwhile, think of what I'm earning!
 All on account of my name." - Bill Sykes, "Oliver"

pfile@cory.Berkeley.EDU (Rob Pfile) (06/16/89)

In article <7644@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes:
>In article <2375@internal.Apple.COM> lsr@Apple.COM (Larry Rosenstein) writes:
>>The picture field is in the Window Manager portion of the data.  WindowPtr 
>>is declared as being the same as a grafPort, so if LSC is using this 
>>definition as the basis of what to show, then you won't see any change.
>
>Clever!  I was wondering what problem he was having -- I have used
>SetWindowPic and it works.  However, note that after calling it on a
>window that's already visible, he will need to do an
>"InvalRect(&window->portRect);" to get the window redrawn.
>
>Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

Well, when I typed my original message, I used the wrong term. I _was_
looking at (WindowPeek)myWindow, and after the call to SetWindowPic(),
the windowPic field was still null.

Even if the debugger was incorrect,  the call to SetWindowPic()
still seems to have done nothing since forcing the window to be redrawn
did not cause the pict to be drawn there.

I still don't know what the problem is, but I am sure that I am in
error somewhere...

I'll keep working on it.

Rob Pfile

mnkonar@manyjars.SRC.Honeywell.COM (Murat N. Konar) (06/17/89)

In article <14695@pasteur.Berkeley.EDU> pfile@cory.Berkeley.EDU.UUCP (Rob Pfile) writes:
>looking at (WindowPeek)myWindow, and after the call to SetWindowPic(),
>the windowPic field was still null.
>

Earlier, I had reported dificulty in getting SetWindowPic to work
using LSP 1.11.  Well, I tried it last night with LSP 2.0p1 and it
worked fine.  



____________________________________________________________________
Have a day. :^|
Murat N. Konar        Honeywell Systems & Research Center, Camden, MN
mnkonar@SRC.honeywell.com (internet) {umn-cs,ems,bthpyd}!srcsip!mnkonar(UUCP)