Author Topic: Dismiss Print dialog  (Read 2527 times)

0 Members and 1 Guest are viewing this topic.

Offline gumby

Dismiss Print dialog
« on: March 15, 2013, 10:04:14 PM »
Does anyone know how to programatically close/dismiss a Print dialog window?  I think I've got it tracked down to the Dialog class doit() method in Controls.sc:

Code: [Select]
= isClaimed FALSE
(while((not isClaimed))
    (self:eachElementDo(#cycle))
    = hEvent (Event:new())
    GlobalToLocal(hEvent)
    = isClaimed (self:handleEvent(hEvent))
    (send hEvent:dispose())
    (self:check)
    (if( (== isClaimed -1) or (not busy) )
        = isClaimed FALSE
        EditControl(theItem 0)
        break
    )
    Wait(1)
)

If I'm reading this correctly, this code just loops, creating new events & checking to see if they are handled in the handleEvent() method by mouse click or specific keys before it bails out and closes the print window.

I know that I could have the window close after a certain amount of time elapses.  I did try to just fake a user input with a keystroke or mouse event, but it isn't consumed (I issued these events from within the main script).  Probably because the doit() in the print is issuing it's own event, waiting for it to be claimed and ignoring all other events.

Oh, by the way, I did try this in my room script:

Code: [Select]
    (method (doit)
(super:doit())
        DisposePrintDlg()
    )

Which conceptually seems like it should work, but it doesn't - probably because we are stuck in the while loop within the controls script.
« Last Edit: March 15, 2013, 10:09:50 PM by gumby »


In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Cloudee1

Re: Dismiss Print dialog
« Reply #1 on: March 15, 2013, 11:27:50 PM »
If you were to comment out that wait... and then try to pass your fake user input, does it work. For some reason, I have a feeling that it will. I don't really know, it's just a feeling.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline gumby

Re: Dismiss Print dialog
« Reply #2 on: March 16, 2013, 10:24:06 AM »
Unfortunately removing the Wait() call had no effect.

When I remove that while loop the print dialog shows up, flashing briefly on the screen then going away, so this is the code I need to modify.  I guess before I issue a print command, I'll have to set a variable to number of cycles to wait.  Then I'll modify the loop to check to see if that variable is populated and add logic to wait the specified # of cycles or user input.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.058 seconds with 22 queries.