分享
 
 
 

建立在TaskBar上没有Item的Form(转载)

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

TaskBar上针对每个程式都会有一个Item於其上,按该Item便会Activate该对应的程式

,其实TaskBar上的这些程式Item是用Tab Control做的,所以如果我们能得到TaskBar

上的Tab Control(SysTab)的hWnd,我们便可以随意删除其上的Item了。

1. 一个应用程式启动时, 除了送出 WM_ACTIVE 叫醒自己本身的主要视窗外, 它还会通知

SysTab (Send ABM_ACTIVATE) 建立该程式在工作列(TaskBar)上的按钮及图示

2. 要让一个应用程式, 按 Alt-Tab 无法切换到, 则必须先改变此应用程式的视窗型态

为 ToolWindow; 然而在 VB 里面用 Show vbModal 可以达到相同的效果

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _

ByVal lpClassName As String, _

ByVal lpWindowName As String) As Long

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _

ByVal hWndParent As Long, _

ByVal hWndChild As Long, _

ByVal lpClassName As String, _

ByVal lpWindowName As String) As Long

Const GWL_EXSTYLE = (-20)

Const WS_EX_TOOLWINDOW = &H80

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const TCM_FIRST = &H1300 ' Tab control messages

Private Const TCM_GETIMAGELIST = (TCM_FIRST + 2)

Private Const TCM_SETIMAGELIST = (TCM_FIRST + 3)

Private Const TCM_GETITEMCOUNT = (TCM_FIRST + 4)

Private Const TCM_GETITEMA = (TCM_FIRST + 5)

Private Const TCM_GETITEMW = (TCM_FIRST + 60)

Private Const TCM_SETITEMA = (TCM_FIRST + 6)

Private Const TCM_SETITEMW = (TCM_FIRST + 61)

Private Const TCM_INSERTITEMA = (TCM_FIRST + 7)

Private Const TCM_INSERTITEMW = (TCM_FIRST + 62)

Private Const TCM_DELETEITEM = (TCM_FIRST + 8)

Private Const TCM_DELETEALLITEMS = (TCM_FIRST + 9)

Private Const TCM_GETITEMRECT = (TCM_FIRST + 10)

Private Const TCM_GETCURSEL = (TCM_FIRST + 11)

Private Const TCM_SETCURSEL = (TCM_FIRST + 12)

Private Const TCM_HITTEST = (TCM_FIRST + 13)

Private Const TCM_SETITEMEXTRA = (TCM_FIRST + 14)

Private Const TCM_ADJUSTRECT = (TCM_FIRST + 40)

Private Const TCM_SETITEMSIZE = (TCM_FIRST + 41)

Private Const TCM_REMOVEIMAGE = (TCM_FIRST + 42)

Private Const TCM_SETPADDING = (TCM_FIRST + 43)

Private Const TCM_GETROWCOUNT = (TCM_FIRST + 44)

Private Const TCM_GETTOOLTIPS = (TCM_FIRST + 45)

Private Const TCM_SETTOOLTIPS = (TCM_FIRST + 46)

Private Const TCM_GETCURFOCUS = (TCM_FIRST + 47)

Private Const TCM_SETCURFOCUS = (TCM_FIRST + 48)

Private Const TCM_SETMINTABWIDTH = (TCM_FIRST + 49)

Private Const TCM_DESELECTALL = (TCM_FIRST + 50)

Private Const TCM_HIGHLIGHTITEM = (TCM_FIRST + 51)

Private Const TCM_SETEXTENDEDSTYLE = (TCM_FIRST + 52)

Private Const TCM_GETEXTENDEDSTYLE = (TCM_FIRST + 53)

Private Const TCM_SETUNICODEFORMAT = &H2005

Private Const TCM_GETUNICODEFORMAT = &H2006

Private Sub Form_Load()

Dim lReturn As Long

Dim lHwnd As Long

lReturn = FindWindow("Shell_TrayWnd", vbNullString) ' 先找 Shell Tray handle

lReturn = FindWindowEx(lReturn, 0, "MSTaskSwWClass", vbNullString) ' 再找它的 Child

lHwnd = FindWindowEx(lReturn, 0, "SysTabControl32", vbNullString) ' 原来就是这一个

Me.Show

'DoEvents

Me.Visible = False

'将 Window Extend Style 设成 ToolWindow, 按 Alt-Tab 无法切换到

lReturn = SetWindowLong(Me.hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW)

'应该设定 Visible 的属性, 才能让改变Window Style的 API 致能

Me.Visible = True

' 将 SysTab 上的最後一个 Item 删掉

lReturn = SendMessage(lHwnd, TCM_GETITEMCOUNT, 0, ByVal 0)

lReturn = SendMessage(lHwnd, TCM_DELETEITEM, lReturn - 1, ByVal 0)

End Sub

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有