Community

SCI Programming => SCI Syntax Help => Topic started by: gumby on March 15, 2013, 10:04:14 PM

Title: Dismiss Print dialog
Post by: gumby 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.
Title: Re: Dismiss Print dialog
Post by: Cloudee1 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.
Title: Re: Dismiss Print dialog
Post by: gumby 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.