Dear All, I want my app to save it's window position so next time I run it, the window will place at the last position But I cannot use close event to save position since it is a tray application I plan to use on move window but cannot seem to find any documentation about it Any suggestion? Regards Hendra
on 2010-04-20 06:26
on 2010-04-20 17:29
It's easy to save the position of your window. And technically, you can
use
the onClose event, even with it being a Tray App.
The method in which this works, is that you would need to return false
from
your window to prevent the window from being destroyed.
An example of this:
class MyWin < Wx::Frame
def initialize()
super(nil,-1,"Sample Hide, not close")
evt_close(self,:on_close)
end
def on_close(event)
@pos = self.position
self.hide
return false
end
end
HTH,
Mario
on 2010-04-21 04:31
I already know how to save the position but the reason for me not to use on_close event is because I am making a simple and personal desktop calendar with todo and event reminder and I am not likely to close it before I shutdown my computer therefore I need another event to save it what comes in my mind is an event when a window is moved but I cannot seem to find it any other idea?
on 2010-04-21 08:19
Hi Hendra On 21/04/2010 02:59, penguinroad wrote: > I already know how to save the position > but the reason for me not to use on_close event is > because I am making a simple and personal desktop calendar > with todo and event reminder > and I am not likely to close it before I shutdown my computer > therefore I need another event to save it Maybe Wx::ActivateEvent - http://wxruby.rubyforge.org/doc/activateevent.html You could use the evt_activate_app to detect when the whole application loses focus, and serialise the window state then. I have not tried this with tray-based apps, but there is a sample in etc/ that you could have a look at and try easily. best alex
on 2010-04-22 04:02
On Wed, Apr 21, 2010 at 1:01 PM, Alex Fenton <alex@pressure.to> wrote: >> therefore I need another event to save it > Thank you for the pointer I found Wx::MoveEvent and it works exactly as I need Thank you
on 2010-04-22 08:13
On 22/04/2010 03:01, hendra kusuma wrote: > Thank you for the pointer > I found Wx::MoveEvent > and it works exactly as I need Good, I'm glad it works. I was cautious about suggesting MoveEvent because it occurs frequently when a Frame is, say, being dragged about by its title bar. So it's not desirable to do lengthy operations (e.g. write to a File) each time it occurs. best alex
on 2010-04-22 08:23
Well, thats exacly what I do write 2 lines to a file to save x and y position of my window I don't know it it occurs frequently but somehow it do just fine thanks
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.