New topic: Hide window on close - reopen by clicking dock icon
<http://forums.realsoftware.com/viewtopic.php?t=45770> Page 1 of 1 [ 9 posts ] Previous topic | Next topic Author Message marcuseaton1 Post subject: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 5:55 am Joined: Thu Apr 19, 2012 12:13 pm Posts: 22 Hello Everybody! Hope you are all well. I've finished coding the main part of my program and i am just doing the last few touches. I'm trying to implement the app to minimize to the dock instead of close on "x". Much like how iMail or and of the other apps work. Instead of going down to the right side of the dock as a 'minimised window'. I want it to 'hide' when closing it and then when clicking on the dock icon is brings it back up. The program is a missed call application that the receptionists in the offices use it to send missed calls to a program that the staff have on there computer then it pops up with a new message alert. I would like to do it in a way so the programs code still runs unaffected. (similar to how iMail still receives emails when it is hidden) If i can get help i'd be really grateful.. I'll send over some good energy as a thanks. Thanks in advance. Best, Marcus x Top jakuno Post subject: Re: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 6:14 am Joined: Fri Aug 31, 2012 3:56 pm Posts: 7 Try Function HandleAppleEvent(theEvent As AppleEvent, eventClass As String, eventID As String) As Boolean if eventClass + eventID = "aevtrapp" then window1.Show Return true end if End Function Top marcuseaton1 Post subject: Re: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 9:15 am Joined: Thu Apr 19, 2012 12:13 pm Posts: 22 Hi, thanks for the quick reply. That works on the first point mentioned but unfortunately it doesn't notify me of new messages unless the window is open. Would putting the code into this if statement keep the code running? Best, Marcus x Top jakuno Post subject: Re: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 9:41 am Joined: Fri Aug 31, 2012 3:56 pm Posts: 7 try: app.DockItem.ResetIcon app.DockItem.Graphics.DrawPicture p, X, Y app.DockItem.UpdateNow where p is the picture with i. e. the red number --- to jump the icon use MacNotificationMBS Top marcuseaton1 Post subject: Re: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 10:06 am Joined: Thu Apr 19, 2012 12:13 pm Posts: 22 jakuno wrote:try: app.DockItem.ResetIcon app.DockItem.Graphics.DrawPicture p, X, Y app.DockItem.UpdateNow where p is the picture with i. e. the red number --- to jump the icon use MacNotificationMBS I don't think im understanding this. I have my icon all set up and the code to alert the dock icon when a new message is received. My problem is just that when the windows is hidden, it doesn't run the code. (it works off a timer) Is there a way to keep the code running when the window is closed? Thanks, Marcus x Top jakuno Post subject: Re: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 10:36 am Joined: Fri Aug 31, 2012 3:56 pm Posts: 7 Hi, the timer fires on hidden windows (2011 R3) . Are you sure you hide the window in the CancelClose Event and Return true? Only self.hide in the Cancel Event stops the Timer, because the window is hidden and then closed. Top amitavak Post subject: Re: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 10:38 am Joined: Mon Jan 02, 2012 1:51 am Posts: 331 Location: India marcuseaton1 wrote:My problem is just that when the windows is hidden, it doesn't run the code. (it works off a timer) Did you close the window? Try just hide the window(Window.Hide). _________________ Amitava Karan Real Studio 2012 Release 1 Windows 7 (32 bit) Mac OS X Version 10.7 Top marcuseaton1 Post subject: Re: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 11:35 am Joined: Thu Apr 19, 2012 12:13 pm Posts: 22 I managed to get it working by creating a button called "close" and putting window.hide behind it. I added the Function HandleAppleEvent(theEvent As AppleEvent, eventClass As String, eventID As String) As Boolean if eventClass + eventID = "aevtrapp" then window1.Show Return true end if End Function And now it works perfectly, thanks everyone. Best, Marcus x Top Thom McGrath Post subject: Re: Hide window on close - reopen by clicking dock iconPosted: Wed Oct 31, 2012 1:25 pm Site Admin Joined: Tue May 06, 2008 1:07 pm Posts: 1229 Location: Greater Hartford Area, CT Rather than a close button, I would recommend the CancelClose event: Function CancelClose(appQuitting as Boolean) As Boolean If Not AppQuitting Then Self.Hide() Return True End If End Function _________________ Thom McGrath - @tekcor Web Framework Architect, Real Software, Inc. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 9 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
