Discussion:
When application loses focus
Erik Ronström
2014-07-24 18:51:04 UTC
Permalink
Hi,

I would like to run certain functions when my CAPI application loses focus to another application. On Cocoa, this is easy enough: I just specify :activate-callback when I create the cocoa-default-application-interface. On Windows however, I can't figure out how to do it.

The WM_ACTIVATEAPP message is what I want to catch, but is sent to the application's WindowProc function. Is it possible to hook into that via CAPI?

Using activate-callbacks of individual CAPI interfaces doesn't work well, since when an activation callback is called, there is no way to tell where it is loosing focus *to*.

Any ideas?

Erik



_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-***@lispworks.com
http://www.lispworks.com/support/lisp-hug.html
Edi Weitz
2014-07-24 19:47:08 UTC
Permalink
On Thu, Jul 24, 2014 at 8:51 PM, Erik Ronström
Post by Erik Ronström
The WM_ACTIVATEAPP message is what I want to catch, but is sent to the application's WindowProc function. Is it possible to hook into that via CAPI?
The techniques described here might work:

http://permalink.gmane.org/gmane.lisp.lispworks.general/10453

Cheers,
Edi.

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-***@lispworks.com
http://www.lispworks.com/support/lisp-hug.html
Erik Ronström
2014-07-24 23:14:51 UTC
Permalink
Thanks, I'll try it!

Erik
Post by Edi Weitz
On Thu, Jul 24, 2014 at 8:51 PM, Erik Ronström
Post by Erik Ronström
The WM_ACTIVATEAPP message is what I want to catch, but is sent to the application's WindowProc function. Is it possible to hook into that via CAPI?
http://permalink.gmane.org/gmane.lisp.lispworks.general/10453
Cheers,
Edi.
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
http://www.lispworks.com/support/lisp-hug.html
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-***@lispworks.com
http://www.lispworks.com/support/lisp-hug.html
Dmitry Ivanov
2014-07-26 06:41:44 UTC
Permalink
Erik Ronström wrote on Thu, 24 Jul 2014 20:51:04 +0200 22:51:

| Using activate-callbacks of individual CAPI interfaces doesn't work
| well, since when an activation callback is called, there is no way to
| tell where it is loosing focus *to*.
|
| Any ideas?

My idea is to schedule a global timer on deactivating, i.e. calling the
activate-callback with NIL as the second argument. After a "certain"
time interval, you can decide that the user is "really" deactivating you
application.

The timer is unscheduled on activating any of the interfaces of your
application.

This technique is not one hundred percent workable but is quite
satisfactory.
(It is used in YstokWidgets Professional Edition to control interaction
between master and slave windows. The difference is that the timer is not
global but is kept in a local slot of the slave-interface instance.)
--
Sincerely,
Dmitry Ivanov
lisp.ystok.ru

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-***@lispworks.com
http://www.lispworks.com/support/lisp-hug.html
Erik Ronström
2014-07-26 07:57:07 UTC
Permalink
Thanks!

Actually I thought of this possibility, but I wanted a more "clean" solution. But if it works well, I may give it a shot! The WindowProc solution proposed by Edi Weitz sounds more appealing to me though, so if I can get that to work, I would probably prefer it.

Erik
Post by Dmitry Ivanov
| Using activate-callbacks of individual CAPI interfaces doesn't work
| well, since when an activation callback is called, there is no way to
| tell where it is loosing focus *to*.
|
| Any ideas?
My idea is to schedule a global timer on deactivating, i.e. calling the
activate-callback with NIL as the second argument. After a "certain"
time interval, you can decide that the user is "really" deactivating you
application.
The timer is unscheduled on activating any of the interfaces of your
application.
This technique is not one hundred percent workable but is quite
satisfactory.
(It is used in YstokWidgets Professional Edition to control interaction
between master and slave windows. The difference is that the timer is not
global but is kept in a local slot of the slave-interface instance.)
--
Sincerely,
Dmitry Ivanov
lisp.ystok.ru
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
http://www.lispworks.com/support/lisp-hug.html
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-***@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Loading...