Object Notifications

I

Icarus

Excuse my lack of knowledge, but I'd like to know how to achieve something
like this.

I have Excel open and I'm working on several money calculations. Money
formats are displayed according my system's money default format. Without
close Excel I go to the Control Panel and make a change to my regional money
format to another diferent to default. Accept the changes and then, when i
switch to the Excel window, all money formats are refreshed and the changes
are reflected automatically.

My question is, How Excel is notified about the changes in the default
system money format? Is an event pushed when that occurs?

I'd like to do this because My program use a class instance with properties
that maps to an application settings, for example: connection string, some
configurable bussiness rules, etc. And I'd like that, when an Instance of my
application change any of thoose setting, all running application instances
detect that change and refresh it's own settings class with the new values.
The running instances of my program can be running on several PCs.

Is there any way to get this done?

TIA
Sergio
 
J

Jeroen Mostert

Icarus said:
Excuse my lack of knowledge, but I'd like to know how to achieve something
like this.

I have Excel open and I'm working on several money calculations. Money
formats are displayed according my system's money default format. Without
close Excel I go to the Control Panel and make a change to my regional money
format to another diferent to default. Accept the changes and then, when i
switch to the Excel window, all money formats are refreshed and the changes
are reflected automatically.

My question is, How Excel is notified about the changes in the default
system money format? Is an event pushed when that occurs?
Excel is handling the WM_SETTINGCHANGE window message, which is sent to all
top-level windows when the locale changes (among other things). Excel
refreshes its locale info when this happens.
I'd like to do this because My program use a class instance with properties
that maps to an application settings, for example: connection string, some
configurable bussiness rules, etc. And I'd like that, when an Instance of my
application change any of thoose setting, all running application instances
detect that change and refresh it's own settings class with the new values.
The running instances of my program can be running on several PCs.

Is there any way to get this done?
In a multitude of ways. Sending a window message is only really an option if
the applications are all Forms-based and running on one computer. Failing
that, you'll need to use some form of network IPC, for which many
possibilities exist: DCOM, network shares, pipes, sockets, most of them
conveniently exposed through .NET remoting. However, these mechanisms
require that applications make specific connections to each other.

One simple approach for a notification like this is to listen for UDP
packets on a particular socket, and send a packet on a broadcast address
when the other instances need to be informed. Another is to have all
instances look at the same configuration file on a network share somewhere
with FileSystemWatcher (writing the new settings is a little trickier, since
you'll have to make sure the instances don't get in each other's way).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top