请问VB高手,谁用VB做过,把进度条放到状态栏里。

masterlee 2002-03-08 08:48:16
如果那位大虾做过,请把代码发到masterlee@263.net。
谢谢。
...全文
218 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
cuzz 2002-09-04
  • 打赏
  • 举报
回复
masterlee 的很好啊
sunmingdong 2002-09-04
  • 打赏
  • 举报
回复
1、把progressbar放到statusbar中
2、设置progressbar:visible=false,不可见
3、在form的resize事件中加入调整progressbar的位置的代码
vcbug 2002-09-04
  • 打赏
  • 举报
回复
to cuiyxy(沧海鲨鱼)

太谢谢你了,,你真是一语道中啊,,我就是因为这个原因搞了半天,,
xfyxq 2002-03-08
  • 打赏
  • 举报
回复
是的,在API中,是以像数为单位的,而VB默认为'提'.
cuiyxy 2002-03-08
  • 打赏
  • 举报
回复
楼上的代码很好
但要注意一下窗口SCALEMODE
Me.ScaleMode = 3
masterlee 2002-03-08
  • 打赏
  • 举报
回复
我知道怎么做了。
我的程序中,一个FROM,一个MODULE

FROM1中代码如下:
Option Explicit
Private Sub Command1_Click()
Command1.Enabled = False

ProgressBar1.Min = 0
ProgressBar1.Max = 100
'设置进度条的最大和最小值

ShowProgresslnStatusBar True
Timer1.Enabled = True
'启动定时器模拟一项任务
End Sub

Private Sub ShowProgresslnStatusBar(ByVal bShowProgress As Boolean)
Dim tRC As RECT

If bShowProgress Then
SendMessage StatusBar1.hwnd, SB_GETRECT, 1, tRC
'状态栏的第一栏为0,第二栏为1
SetParent ProgressBar1.hwnd, StatusBar1.hwnd
ProgressBar1.Move tRC.Left, tRC.Top, tRC.Roght - tRC.Left, tRC.Bottom - tRC.Top
ProgressBar1.Visible = True
ProgressBar1.Value = 0

Else
SetParent ProgressBar1.hwnd, Me.hwnd
ProgressBar1.Visible = False
End If
End Sub

Private Sub form_load()
ProgressBar1.Visible = False
Timer1.Enabled = False
Timer1.Interval = 20
End Sub

Private Sub form_Unload(Cancel As Integer)
ShowProgresslnStatusBar False
'把进度条控件的容器还原为窗体
End Sub

Private Sub timer1_timer()
Static inum As Long
inum = inum + 5
If inum > 100 Then
Timer1.Enabled = False
ShowProgresslnStatusBar False
Command1.Enabled = True
inum = 0
End If
ProgressBar1.Value = inum
End Sub

MODULE1中代码:
Option Explicit
Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Public Type RECT
Left As Long
Top As Long
Roght As Long
Bottom As Long
End Type

Public Const SB_GETRECT As Long = &H40A




xfyxq 2002-03-08
  • 打赏
  • 举报
回复
用API,有一个专门用于改变控件的父对象的API函数,它可以把一个控件从某个容器移到另一个容器,不过,我一时忘了,如果你有API帮助,你自已找找看吧.

:(

如果下面没人知道,过一下,我再帮你查一下
寒星 2002-03-08
  • 打赏
  • 举报
回复
将ProgressBar放进StatusBar中,其初始visibled为false,再需要时再将其visibled置为true.
koes 2002-03-08
  • 打赏
  • 举报
回复
把你想放状态条的那一段长度固定,然后把状态条盖在上边,效果凑合,呵呵
Richard2001 2002-03-08
  • 打赏
  • 举报
回复
你在状态栏中加个Picture,在Picture里加进度条。
limit 2002-03-08
  • 打赏
  • 举报
回复
用delphi比较容易,没用vb做过

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧