VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 在任务栏中显示无边框窗体的图标
发表评论(0)作者:, 平台:, 阅读:11253, 日期:2000-03-12
在任务栏中显示无边框窗体的图标



当你将窗体的BorderStyle和ShowInTaskbar这两个属性分别设为True时,你会发现

在任务栏中只显示了该窗体的Caption属性,而窗体的图标则没有显示出来。同时,

如果你用鼠标右键在任务栏中单击该窗体,原本就显示的系统菜单,现在也没有了。

要解决这个问题,你需要用到下面两个API函数。GetWindowLong和SetWindowLong.

下面是程序示例:


将下面的代码放入窗体的声明段中:


Private Declare Function GetWindowLong Lib "user32" Alias "

GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias "

SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal

dwNewLong As Long) As Long

Private Const GWL_STYLE = (-16)

Private Const WS_SYSMENU = &H80000


然后将下面的代码放入窗体的Load事件中:


Dim lStyle As Long


lStyle = GetWindowLong(hWnd, GWL_STYLE) Or _ WS_SYSMENU


SetWindowLong hWnd, GWL_STYLE, lStyle