芬琳漆官方旗舰店:VB入门技巧N例(7)

来源:百度文库 编辑:九乡新闻网 时间:2024/07/07 14:48:06
22.右键托盘图标后必须电击他才可以消失,怎么办?
Case WM_RBUTTONUP '鼠标在图标上右击时弹出菜单
      SetForegroundWindow Me.hwnd
        Me.PopupMenu mnuTray
加一句 SetForegroundWindow Me.hwnd

23. 将progressbar嵌入statusbar中
  1. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal _ hWndNewParent As Long) As Long
  2. Private Sub Command1_Click()
  3.     With ProgressBar1
  4.         .Max = 1000
  5.         Dim i As Integer
  6.         For i = 1 To 1000
  7.             .Value = i
  8.         Next i
  9.     End With
  10. End Sub
  11. Private Sub Form_Load()
  12.     ProgressBar1.Appearance = ccFlat
  13.     SetParent ProgressBar1.hWnd, StatusBar1.hWnd
  14.     ProgressBar1.Left = StatusBar1.Panels(1).Left
  15.     ProgressBar1.Top = 100
  16.     ProgressBar1.Width = StatusBar1.Panels(1).Width - 50
  17.     ProgressBar1.Height = StatusBar1.Height - 150
  18. End Sub   '相对位置你可以自己再调一下
复制代码
24.使你的程序界面具有XP风格 产生一个和你的可执行程序同名的后缀为exe.manifest的文件,并和可执行文件放在同一路径中。
代码中加入:
  1. Private  Declare Sub InitCommonControls Lib "comctl32.dll" ()
  2. Private Sub Form_Initialize()
  3.     InitCommonControls
  4. End Sub
复制代码
注意:
1 工具栏控件一定要用Microsoft Windows Common Controls 5.0,而不要用Microsoft Windows Common Controls 6.0。因为此

InitCommonControls API函数是位于comctl32.dll(Microsoft Windows Common Controls 5.0控件的动态链接库中)。
2 放在FRAME控件中的单远按钮有些“麻烦”!为了解决此问题,可以将单选按钮放在PICTURE控件中(以PICTURE控件作为容器),再将

PICTURE控件放在FRAME控件中,就可以了。
3 必须编译之后才能看到效果
exe.manifest文件中的内容,可用notepad编辑。


  1. version="1.0.0.0"
  2. processorArchitecture="X86"
  3. name="CompanyName.ProductName.YourApp"
  4. type="win32"
  5. />
  6. Your application description here.


  7. type="win32"
  8. name="Microsoft.Windows.Common-Controls"
  9. version="6.0.0.0"
  10. processorArchitecture="X86"
  11. publicKeyToken="6595b64144ccf1df"
  12. language="*"
  13. />


复制代码