Why does SystemParametersInfo hang when I pass the SPIF_SENDCHANGE flag?
来源:互联网 发布:java爬虫框架 比较 编辑:程序博客网 时间:2024/05/20 01:09
http://blogs.msdn.com/b/oldnewthing/archive/2005/03/10/392118.aspx
If you pass the then the system will broadcast the message If there is a window that isn't responding to messages, then this broadcast will hang until that unresponsive window finally resumes responding to messages or is killed. If you'd rather not be victimed by unresponsive windows, you have a few options, but it also may affect your program's expectations. You could issue the With this message, the background thread can notify the main thread when the broadcast finally completes, at which point your program now knows that all windows have received their notifications and are on board with the new setting. You could issue the This does mean that unresponsive windows will not receive the notification that a system parameter has changed. This is acceptable if you decide that your change in settings was minor enough that a program missing the notification is no big deal. In other words, when the unresponsive program finally wakes up, it will not know that the setting has changed since it missed the notification. You can combine the above two methods: Use a background thread and send the message with a timeout. Perhaps the best technique is to use the The downside is that you don't know when all windows have finally received and processed the notification. All you know is that someday, they will eventually find out. Usually you don't care about this aspect of the broadcast, so this lack of information is not an impediment.Why does SystemParametersInfo hang when I pass the SPIF_SENDCHANGE flag?
SPIF_SENDCHANGE
flag to the SystemParametersInfo
function, it will broadcast the WM_SETTINGCHANGE
message with the wParam equal to the system parameter code you passed. For example, if you callSystemParametersInfo(SPI_SETDOUBLECLICKTIME, 500, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETDOUBLECLICKTIME, 0);
SystemParametersInfo
call on a background thread. Then your background thread is the one that blocks instead of your UI thread.SystemParametersInfo
call without the SPIF_SENDCHANGE
flag, then manually broadcast the change viaDWORD dwResult;SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETDOUBLECLICKTIME, 0, SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG, 5000, &dwResult);
SendNotifyMessage
function. As we learned earlier, the SendNotifyMessage
function is like SendMessage
except that it doesn't wait for a response. This lets your program get back work while not messing up programs that were momentarily unresponsive when you decided to broadcast the notification.SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETDOUBLECLICKTIME, 0);
I understand that SendNotifyMessage will just call the window procedure for the local thread, does it also skip the message queue for windows in other threads?
Maybe the "Display Properties" box doesn't notify the applications correctly? Or is it a more generic problem with broadcasted messages and modal message loops?
- Why does SystemParametersInfo hang when I pass the SPIF_SENDCHANGE flag?
- Why does Python print unicode characters when the default encoding is ASCII?
- Why did the size of my indexes expand when I rebuilt my indexes?
- Q: When I try to animate the frame of a CALayer nothing happens. Why?
- When does the store close?
- The what, when and why of wireframes
- Why I installed the Ubuntu?
- Why I open the blog ?
- No Response from the Server, Does it Hang or Spin?
- Why does Windows not recognize my USB device as the same device if I plug it into a different port?
- Why does a statically built Qt use the dynamic Visual Studio runtime libraries ? Do I need to deploy
- Why / When / How should I use exception in Python ?
- The reason why i register this blog
- The reason why I use CSDN blog
- When encountered a program hang,what command can I use to analysis this issue
- Why does TypeScript have to be the answer to anything?
- Why Does GoldenGate Report The Lag Is Unknown
- Why does the PDB format change every release?
- 有理想的程序员必须知道的15件事
- c++强制类型转换:dynamic_cast、const_cast 、static_cast、reinterpret_cast
- 笨笨数据压缩教程--第三章 奇妙的二叉树:Huffman的贡献
- 一些软件设计的原则
- vs05曲线统计图
- Why does SystemParametersInfo hang when I pass the SPIF_SENDCHANGE flag?
- 笨笨数据压缩教程--第四章 向极限挑战:算术编码
- 再简单不过的小游戏,不会沉迷
- 有网上,真幸福。。。
- asp.net MVC 权限设计
- asp.net MVC 权限设计
- 笨笨数据压缩教程--第五章 聪明的以色列人(上):LZ77
- IC与PCB层数的关系
- 只玩一些电脑小游戏