如何向所有的资源管理器窗口发送刷新消息
来源:互联网 发布:数据分析部门架构 编辑:程序博客网 时间:2024/05/17 08:48
原始问题是这样的:我想编程实现文件扩展名的显示与隐藏,实际上就是修改HKCU/Software/Microsoft/Windows/ CurrentVersion/Explorer/Advanced" 的HideFileExt的值,但问题是将此键值修改后,系统并不知道这个更新,我想应该是向系统广播某个消息(或者是某些消息)。我试着向 windows发送各种各样的消息,包括试了BroadcastSystemMessage、SHChangeNotify、 SystemParametersInfo等函数,但是都没有成功。
进一步一个折衷的问题是:我发现,在更改上面的注册表键值以后,在资源管理器窗口中按F5键刷新并起不到作用,只有点右键刷新才能使扩展名隐藏或显 示。但是,如果已经在某个资源管理器窗口中点右键刷新了,则其它的资源管理器窗口可以通过F5键来得到隐藏或显示扩展名的目的。
退一步,我应该如何向所有打开的资源管理器窗口都发送F5按键消息呢?我的思路是通过PostMessage(handle,WM_KEYDOWN, VK_F5,0);PostMessage(handle,WM_KEYUP,VK_F5,0);但是handle的确定相当困难,我试过用窗口的顶级 handle及里面的FolderView的句柄,都不起作用。而且,我想,即使是找到用VK_F5遍历发送消息的方法,也会引起巨大的系统开销。而且, 由于所有的资源管理器窗口都被遍历一遍(这是不是意味着所有的资源管理器窗口都会获得一次焦点?),如果遍历顺序控制不好的话会引起各窗口覆盖顺序的变 化,肯定会让使用者感到不爽。
问题大概就这么多,诸位有没有什么好的办法啊?请各路高手不吝赐教,多谢了先。
FeedBack:
你可以解决此问题
回复 引用 查看
HWNDhCurWnd = NULL;
TCHARszClassName[MAX_PATH] = {0};
hCurWnd = ::GetTopWindow(NULL);
while(IsWindow(hCurWnd))
{
GetClassName(hCurWnd, szClassName, MAX_PATH);
if( _tcscmp( szClassName, _T("CabinetWClass") ) == 0 || _tcscmp(szClassName, _T("ExploreWClass") )== 0 )
{
::PostMessage(hCurWnd, WM_COMMAND, 41504, 0);
}
hCurWnd = ::GetNextWindow(hCurWnd, GW_HWNDNEXT);
continue;
}
http://osdir.com/ml/version-control.cvs.tortoisecvs.user/2003-09/msg00063.html
http://osdir.com/ml/version-control.cvs.tortoisecvs.user/2003-09/msg00076.html
http://osdir.com/ml/version-control.cvs.tortoisecvs.user/2003-09/msg00070.html
Update window after Update, Commit, &c: msg#00063
It is apparently an Explorer bug, and I think it is already in the RFE tracker.Per Lindberg wrote:
Wouldn't it be nice if TortoiseCVS could update the window (= F5)TortoiseCVS already does this:
after an Update, Commit etc? Possible? Old question?
The files & directories in the file pane update fine for me. However, the directory icons on the tree don't update until I close/open explorer--is that a Windows problem or should it be put into the bug database?
Wouldn't it be nice if TortoiseCVS could update the window (= F5)
after an Update, Commit etc? Possible? Old question?
TortoiseCVS already does this:
void TortoiseAct::RefreshExplorerWindow()
{
PostMessage(myRemoteHandle, WM_COMMAND, 41504, 0);
}
http://www.eggheadcafe.com/forumarchives/VisualBasicwinapi/Jul2005/post23415399.asp
7/21/2005 2:21:23 PM SendMessage API
Dear All7/21/2005 5:12:31 PM Re: SendMessage API
Can anyone please help me on the following:
I like to write a VB program that instructs internet explorer to refresh its
window(like pressing F5 or pressing refresh button).
Problem is that internet explorer should not be the active window(not having
focus) so its just running in background as an icon.
Therefore VB's Sendkeys-Statement can't be used and I assume I need to use
Sendmessage API instead.
Although I haven't done much investigations yet I don't think that it should
be a problem getting IE's window handle because the I know the
caption(window title) of it.
However, I don't know what WM_xxx message I need to send to get a
refresh(retransmitting the actual website of IE)?
Would also be nice if one of you also have a piece of code how to use
Sendmessage or a link to a good example.
Regards
Peter
<->
1. Get the IE handle using FindWindow("ieframe", vbNullString)
2. Use 'Call SendMessage(hIE, WM_COMMAND, ByVal 41504&, ByVal 0&)'
WM_COMMAND = &H111, and 41504 is the menue identifier of the view-refresh
submenu. May be, it differs between the IE versions, but I don' believe it.
If so, you can get the right one using Spy++.
Juergen.
7/22/2005 10:57:25 AM Re: SendMessage API
Many Thanks!!!!
I will test it....
Peter
"Juergen Thuemmler" <thue@removethisgmx.de> wrote in message
news:uGlsrbgjFHA.2156@TK2MSFTNGP14.phx.gbl...
it.
7/25/2005 9:07:27 AM Re: SendMessage API
Hi Juergen
Thanks again!!! This works!
Another question: Where can I get the various parameter values(like 41504&)
and their meanings to invoke several other functions of IE?
Regards
Peter
"Juergen Thuemmler" <thue@removethisgmx.de> wrote in message
news:uGlsrbgjFHA.2156@TK2MSFTNGP14.phx.gbl...
it.
7/25/2005 10:11:16 AM Re: SendMessage API
"Peter" <peter_l@myrealbox.com> wrote in message
news:1121948485.276417@stern...
That is the API solution. There is also a COM solution and that is what I
would use. If you were to ask in the VB COM newsgroup or an IE programmer's
newsgroup you would get the alternative solution.
7/25/2005 10:24:58 AM Re: SendMessage API
You need a tool like Spy++ (shipped with Visual Studio), select "Spy" ->
"Messages" in its menu bar, drag the Finder Tool to the IE main windows
title bar, select the message "WM_COMMAND" only from the message list, and
then operate anything in IE, e.g. menu click. You'll see the generated
messages in the capturing window and have to interpret them (needs a little
knowledge how Windows is working and the meaning of the message
parameters...).
Juergen.
7/25/2005 11:04:44 AM Re: SendMessage API
Thanks, I aready played around with Spy++.
Thought that there is also some documentation available instead of spying.
Regards
Peter
"Juergen Thuemmler" <thue@removethisgmx.de> wrote in message
news:usoaZJPkFHA.3316@TK2MSFTNGP14.phx.gbl...
little
- 如何向所有的资源管理器窗口发送刷新消息
- 如何向窗口发送消息
- 无窗口的CWnd类如何向框架发送消息
- 向窗口发送消息
- 向指定窗口发送消息
- android UiAutomator如何向所有微信好友发送一条“你好,***”开头的祝福消息
- 子窗口向父窗口发送消息
- 子窗口向父窗口发送消息
- 子窗口向父窗口发送消息
- 向非活动窗口发送Hook到的消息
- 不同线程之间向对方的窗口发送消息
- 借助Spy++向指定的窗口发送消息—1
- 借助Spy++向指定的窗口发送消息—2
- 借助Spy++向指定的窗口发送消息—3
- 获得HWND的方法、向子窗口发送消息
- VC2005 向窗口的按钮发送单击消息
- 借助Spy++向指定的窗口发送消息—2
- 向其他软件窗口、控件发送消息的方法
- YUI 研究 -- Dom 模块
- 点石互动--石头之:如何让你的页面被搜索引擎收录(系列二)
- UML时序图
- 书写基于内核的linux键盘纪录器(上)(ZZ)
- YUI 研究 -- Event 模块
- 如何向所有的资源管理器窗口发送刷新消息
- YUI 研究 -- Connection Manager 模块
- VC++中使用内存映射文件处理大文件 (2)
- YUI 研究 -- DragDrop 模块
- Subversion快速入门教程(收)
- marquee滚动字幕或图片,不理解为什么用js!望赐教
- YUI 研究 -- Animation 模块
- 在ASP.NET中配置应用程序
- window.open()的所有参数列表