Private defProgBarHwnd As LongPrivate Declare Function SetParent Lib "user32" _ (ByVal hWndChild As Long, _ ByVal hWndNewParent As Long) As Long Private Function AttachProgBar(pb As ProgressBar, _ sb As StatusBar, _ nPanel As Long, _ pading As Long)
If defProgBarHwnd = 0 Then
'change the parent defProgBarHwnd = SetParent(pb.hwnd, sb.hwnd)
With sb
'adjust statusbar. Doing it this way 'relieves the necessity of calculating 'the statusbar position relative to the 'top of the form. It happens so fast 'the change is not seen. .Align = vbAlignTop .Visible = False
'change, move, set size and re-show 'the progress bar in the new parent With pb .Visible = False .Align = vbAlignNone .Appearance = ccFlat .BorderStyle = ccNone .Width = sb.Panels(nPanel).Width .Move (sb.Panels(nPanel).Left + pading), _ (sb.Top + pading), _ (sb.Panels(nPanel).Width - (pading * 2)), _ (sb.Height - (pading))
.Visible = True .ZOrder 0 End With
'restore the statusbar to the 'bottom of the form and show .Panels(nPanel).AutoSize = sbrNoAutoSize .Align = vbAlignBottom .Visible = True
End With
End If
End FunctionPrivate Sub Command1_Click() Dim pading As Long 'parent the progress bar in the status bar pading = 40 AttachProgBar ProgressBar1, StatusBar1, 2, pading End Sub但编译后需要在不同分辨率下测试看是否正常,个人认为效果不是非常理想
to hpygzhx520() : 你说的这个方法我试过了,非MID窗口可以,但MDI窗口不行,move不上去
community.csdn.net/Expert/topic/4175/4175181.xml?temp=.6768305
我连PICTURE控件都放不到状态栏上面去,请问应该如何操作呢。
Private defProgBarHwnd As LongPrivate Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Private Function AttachProgBar(pb As ProgressBar, _
sb As StatusBar, _
nPanel As Long, _
pading As Long)
If defProgBarHwnd = 0 Then
'change the parent
defProgBarHwnd = SetParent(pb.hwnd, sb.hwnd)
With sb
'adjust statusbar. Doing it this way
'relieves the necessity of calculating
'the statusbar position relative to the
'top of the form. It happens so fast
'the change is not seen.
.Align = vbAlignTop
.Visible = False
'change, move, set size and re-show
'the progress bar in the new parent
With pb
.Visible = False
.Align = vbAlignNone
.Appearance = ccFlat
.BorderStyle = ccNone
.Width = sb.Panels(nPanel).Width
.Move (sb.Panels(nPanel).Left + pading), _
(sb.Top + pading), _
(sb.Panels(nPanel).Width - (pading * 2)), _
(sb.Height - (pading))
.Visible = True
.ZOrder 0
End With
'restore the statusbar to the
'bottom of the form and show
.Panels(nPanel).AutoSize = sbrNoAutoSize
.Align = vbAlignBottom
.Visible = True
End With
End If
End FunctionPrivate Sub Command1_Click()
Dim pading As Long
'parent the progress bar in the status bar
pading = 40
AttachProgBar ProgressBar1, StatusBar1, 2, pading
End Sub但编译后需要在不同分辨率下测试看是否正常,个人认为效果不是非常理想
你说的这个方法我试过了,非MID窗口可以,但MDI窗口不行,move不上去
也可以在MDI窗体底部放一个PictureBox,然后把状态栏和进度条都放PictureBox里。但要自己控制状态栏的大小。