[comp.sys.mac.programmer] Why would it suddenly become impossible to draw into a modal dialog?

vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan) (05/16/91)

Well, this one's got me stumped. :-/

Before, I have never had any problem drawing into a modal dialog;
you just setPort to the dialog and draw into it as you would into
any window.

For some reason, a dialog I am working on starts out drawing fine, but
after once or twice through the loop, it becomes impossible to
draw anything else into the dialog.  All of the mouse events
are handled properly, but the loss of drawing ability is so absolute
that the Toolbox can't even hilite its own buttons.  Reapplication of
SetPort doesn't help the problem any.

The dialog is a fairly complex one, containing several buttons,
four pop-up menus, an editable text item, a PICT, and several disabled
text items.  There is a complex filter function which handles the
pop-up menus.  The pop-up items are defined in my template as user
items; I set a pointer to the routine to draw the menu boxes so that
updates are handled automatically.  I am not certain, but the problem
*may* have first manifested when I changed my code so that these
items were drawn in this manner (with a pointer passed by SetDItem).

Any good ideas?

--Kurisuto
un020070@vaxa.wvnet.edu

neeri@iis.ethz.ch (Matthias Ulrich Neeracher) (05/16/91)

In article <1767@babcock.cerc.wvu.wvnet.edu> vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan) writes:
>Well, this one's got me stumped. :-/
>
>Before, I have never had any problem drawing into a modal dialog;
>you just setPort to the dialog and draw into it as you would into
>any window.
>
>For some reason, a dialog I am working on starts out drawing fine, but
>after once or twice through the loop, it becomes impossible to
>draw anything else into the dialog.  All of the mouse events
>are handled properly, but the loss of drawing ability is so absolute
>that the Toolbox can't even hilite its own buttons.  Reapplication of
>SetPort doesn't help the problem any.

Did you change the clipRgn or the visRgn of the window ?

Matthias

-----
Matthias Neeracher                                      neeri@iis.ethz.ch
   "These days, though, you have to be pretty technical before you can 
    even aspire to crudeness." -- William Gibson, _Johnny Mnemonic_

vrm@babcock.cerc.wvu.wvnet.edu (Vasile R. Montan) (05/17/91)

> In article <1767@babcock.cerc.wvu.wvnet.edu> vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan) writes:
>>Well, this one's got me stumped. :-/
>>
>>Before, I have never had any problem drawing into a modal dialog;
>>you just setPort to the dialog and draw into it as you would into
>>any window.
>>
>>For some reason, a dialog I am working on starts out drawing fine, but
>>after once or twice through the loop, it becomes impossible to
>>draw anything else into the dialog.  All of the mouse events
>>are handled properly, but the loss of drawing ability is so absolute
>>that the Toolbox can't even hilite its own buttons.  Reapplication of
>>SetPort doesn't help the problem any.

So far, I've gotten two basic answers to this question.

1.  Perhaps the problem has to do with the clipping region.  I think
this is probably not the case; I didn't tamper any with the region
myself, and just in case somebody else did, I tried inserting this
code here and there:

    SetPort(theDialog);
    ClipRect(thePort^.portRect);

This didn't have any noticable effect, and it didn't solve the
strange problem.  :-(

2.  Maybe I have a wild handle or pointer out of control which is
messing up something in low memory.  This is possible; I've looked
my code over to see if anybody might be doing this, but nothing
seemed to be improper.  I have yet to go over the code with a
fine-toothed comb, specifically looking for this problem.
     The thing is, though, that there are no other symptoms.  If
the low memory were being trashed, I would expect that there would
be several manifestations of the problem; in this case, the only
symptom is the lack of ability to draw into the dialog.  Once
the dialog is dismissed, the program goes on drawing into other
windows with no problem.  No crash, no strange fonts in the menus,
nothing. :-{

Any other ideas?  I would be very glad to hear any conjectues you
may have.

--Kurisuto
un020070@vaxa.wvnet.edu

Thank you all for letting me know my messages *are* being posted.