如何隐藏系统托盘上的图标?(30分)

K

kim_fu

Unregistered / Unconfirmed
GUEST, unregistred user!
我想做一个程序。它可以把别的程序在系统托盘上的图标隐藏,或显示。比如我要做一个<br>程序。他可以隐藏系统托盘上音量控制,输入法,或其他程序生成的图标。<br><br>只剩下30分了。不好意思。
 
FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'TrayNotifyWnd',nil);<br>有了句柄干什么都行了^_^
 
to YB_unique<br>使用你的方法我如何确定找到的句柄就是我要找的那个窗口的呢?比如我找到音量和<br>输入法两个句柄。我如何区分他们呢?
 
我昨天实验了。用你的语句 aWnd=FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'TrayNotifyWnd',nil);<br>是得到了托盘区的窗口句柄。然后我又用 GetWindow(aWnd,GW_CHILD)得到的是时间窗口的<br>句柄(假设托盘区只有 音量,输入法,时间三部分)。然后又用 GetNextWindow(aWnd,GW_HWNDNEXT)<br>获得了音量,和输入法的句柄,给我的感觉好象音量,输入法是在一个窗口中。但是我就<br>没办法得到音量,或输入法的窗口。我该怎么办呢?
 
到今天我又赞了10分。我全加上。帮忙呀。
 
function WindowHasChild(H: HWND): boolean; &nbsp;//判断有无子窗口<br>var M: HWND;<br>begin<br>&nbsp; M:=GetWindow(H,GW_CHILD);<br>&nbsp; if M=0 then<br>&nbsp; &nbsp; result:=false<br>&nbsp; else<br>&nbsp; &nbsp; result:=true;<br>end;<br><br>procedure CreateTree(H: HWND; T: TTreeNode);<br>var M: &nbsp;HWND;<br>&nbsp; &nbsp; P: &nbsp;PChar;<br>&nbsp; &nbsp; s: &nbsp;string;<br>&nbsp; &nbsp; s1: string;<br>&nbsp; &nbsp; N: &nbsp;TTreeNode;<br>begin<br>&nbsp; M:=GetWindow(H,GW_CHILD);<br>&nbsp; while M&lt;&gt;0 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; GetMem(P,256);<br>&nbsp; &nbsp; &nbsp; GetClassName(M,P,256);<br>&nbsp; &nbsp; &nbsp; s:='ClassName='+strpas(P);<br>&nbsp; &nbsp; &nbsp; GetWindowText(M,P,256);<br>&nbsp; &nbsp; &nbsp; s1:=strpas(P);<br>&nbsp; &nbsp; &nbsp; if s1='' then<br>&nbsp; &nbsp; &nbsp; s1:='Nil';<br>&nbsp; &nbsp; &nbsp; s:=s+' Caption='+s1+' Handle='+IntToSTr(M);<br>&nbsp; &nbsp; &nbsp; N:=Form1.TreeView1.Items.AddChild(T,s);<br>&nbsp; &nbsp; &nbsp; Freemem(P);<br>&nbsp; &nbsp; &nbsp; if WindowHasChild(M) then<br>&nbsp; &nbsp; &nbsp; &nbsp;CreateTree(M,N); &nbsp;递归调用<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; M:=GetWindow(M,GW_HWNDNEXT);<br>end;<br><br>var x: TTreeNode;<br>&nbsp; &nbsp; TreeView1.Items.Clear;<br>&nbsp; &nbsp; x:=TreeView1.Items.Add(nil,s);<br>&nbsp; &nbsp; CreateTree(GetDesktopWindow(),x); &nbsp;//用树型结构表示当前拥有句柄窗口的<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 结构,有了层次结构和句柄什么API不可<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 调用<br>&nbsp;<br>
 
98中,各个图标是ImageList,除了时间单独有一个窗口句柄,其他共用一个窗口句柄,很难<br>把其中的某个图标隐藏。<br>2000中,有一个API函数HindIcon,可以按Index隐藏某个图标。<br>但隐藏后想恢复就难了。<br>我作过一个在2000下隐藏某个图标的程序(例如隐藏QQ),在98下没作到(只有全部隐藏,除<br>系统时间外,输入法和QQ都隐藏了)
 
guqs 你是如何隐藏QQ的图标的呢?能把代码贴上吗?
 
to kim_fu:<br>》》获得了音量,和输入法的句柄,给我的感觉好象音量,输入法是在一个窗口中<br>我怎么<br>&nbsp; h1:=GetWindow(h1,gw_child);<br>&nbsp; h1:=GetNextWindow(h1,GW_HWNDNEXT);<br>后连一个句柄都得不到呀?
 
coolbaby 对。你说的对。我也感觉音量和输入法和后运行的程序。比如 RealPlay 等都是在一个<br>窗口中。我没办法得到某一个比如音量的句柄(还不清楚其是不是单独有一个句柄)。<br><br>大家帮帮忙呀。我把到今天的分全加上。
 
guqs:<br>&nbsp; &nbsp;如何获得QQ的index,另外,如何恢复,难在那里,能不能说详细点~~~~~~~~~~3q
 
再提前。加上40分
 
提前,提前,再提前。
 
to kim_fu, <br>&nbsp; &nbsp;我也感觉音量和输入法和后运行的程序。比如 RealPlay 等都是在一个<br>窗口中。你的意思是你可以得到他们这些在一起的句柄了,是吧。<br>&nbsp; 我怎么只能取到start和时间的,他们整体的都没有取到。
 
to coolbaby<br>&nbsp; 你按照我最先的帖子的做法就可以得到时间之前的音量,输入法在一起的句柄了
 
继续啊!
 
关注....
 
关注!我也遇到过这样的问题!但没有进展!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
顶部