.NET文化变革的事件?事件、文化、NET

2023-09-04 05:31:17 作者:做我的信仰可好

我有一个.NET自定义控制,在一个文化相关的方式显示信息。为了提高性能,我缓存控制内部的一些信息,而不是生成它每一次。我需要知道,如果文化已经改变了,这样我可以重新生成适当的这种内部信息。

I have a .NET custom control that displays information in a culture dependant way. To improve performance I cache some information inside the control rather than generate it every time. I need to know if the culture has changed so that I can regenerate this internal info as appropriate.

有没有一些事件我有勾成?还是我刚才试的文化设定每次我画的,看它是否改变了?

Is there some event I have hook into? Or do I have to just test the culture setting every time I paint to see if it has changed?

推荐答案

似乎没有事件,但Windows并广播WM_SETTINGSCHANGE消息给所有形式。您可以尝试通过重写的WndProc检测它(请这和的这个获得更多信息)。

It seems that there is no event, but Windows does broadcast the WM_SETTINGSCHANGE message to all Forms. You could try detecting it by overriding WndProc (Check this and this for more info).

在这种情况下,你不需要触发一个静态事件,而是作废静态的缓存,然后继续。

In that case you don't need to fire a static event, but rather invalidate your static "cache" and continue.