?? howto_statusbar_show_progress.html
字號:
<HTML>
<META http-equiv="PICS-Label" content='(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" by "RodStephens@vb-helper.com" for "http://www.vb-helper.com" on "1998.03.17T18:18-0800" r (n 0 s 0 v 0 l 0))'>
<HEAD>
<TITLE>VB Helper: HowTo: Display a status bar showing the steps in a long task</TITLE>
<META NAME="Author" CONTENT="Rod Stephens">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Keywords" CONTENT="StatusBar, steps, stages, progress, ProgressBar">
<META NAME="Keywords" CONTENT="StatusBar, steps, stages, progress, ProgressBar">
<META NAME="Description" CONTENT="VB Helper: HowTo: Display a status bar showing the steps in a long task">
<META NAME="Copyright" CONTENT="Copyright 1997-2003, Rocky Mountain Computer Consulting, Inc.">
<META NAME="Rating" CONTENT="General">
<META NAME="Robots" CONTENT="All">
</HEAD>
<BODY BGCOLOR="#E1F3FF" BACKGROUND="bg_blue.jpg">
<!-- This table contains the banner, menu column, and content. -->
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<!-- ****** -->
<!-- Banner -->
<!-- ****** -->
<TR><TD>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="Left">
<TR>
<TD BACKGROUND="banner_mid.jpg"><IMG SRC="banner_l.jpg" WIDTH="410" HEIGHT="64"></TD>
<TD BGCOLOR="#E1F3FF"><IMG SRC="banner_r.jpg" WIDTH="32" HEIGHT="64"></TD>
</TR>
</TABLE>
</TD></TR>
<TR><TD> </TD></TR>
<!-- Menu column and content -->
<TR><TD>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="2" CELLPADDING="0">
<!-- *********** -->
<!-- Menu column -->
<!-- *********** -->
<TR>
<TD ALIGN="Left" VALIGN="Top">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<!-- Menu top -->
<TR>
<TD><IMG SRC="blue_ul.jpg" WIDTH="16" HEIGHT="16"></TD>
<TD><IMG SRC="blue_um.jpg" WIDTH="93" HEIGHT="16"></TD>
<TD><IMG SRC="blue_ur.jpg" WIDTH="16" HEIGHT="16"></TD>
</TR>
<!-- Menu entries -->
<TR BGCOLOR="#7FCFFF">
<TD BACKGROUND="blue_l.jpg" WIDTH="16"> </TD>
<TD><CENTER>
<A HREF="index.html"><B><FONT SIZE="+1">Home</FONT></B></A><BR>
<A HREF="search.html"><B>Search</B></A><BR>
<BR>
<A HREF="whats_new.html"><B>What's New</B></A><BR>
<A HREF="index_categories.html"><B>Index</B></A><BR>
<A HREF="books.html"><B>Books</B></A><BR>
<A HREF="links.html"><B>Links</B></A><BR>
<A HREF="http://www.topica.com/lists/VBHelperQA/read"><B>Q & A</B></A><BR>
<A HREF="newsletter.html"><B>Newsletter</B></A><BR>
<A HREF="banners.html"><B>Banners</B></A><BR>
<BR>
<A HREF="mailto:feedback@vb-helper.com"><B>Feedback</B></A><BR>
<A HREF="tip_jar.html"><B>Tip Jar</B></A><BR>
<BR>
<A HREF="feed.xml"><IMG SRC="xml_rss.jpg" BORDER="0" ALT="XML RSS Feed"></A><BR>
</CENTER></TD>
<TD BACKGROUND="blue_r.jpg" WIDTH="16"> </TD>
</TR>
<!-- Menu bottom -->
<TR>
<TD><IMG SRC="blue_ll.jpg" WIDTH="16" HEIGHT="16"></TD>
<TD><IMG SRC="blue_lm.jpg" WIDTH="93" HEIGHT="16"></TD>
<TD><IMG SRC="blue_lr.jpg" WIDTH="16" HEIGHT="16"></TD>
</TR>
<TR><TD HEIGHT="50" COLSPAN="3"> </TR></TD>
<!-- ******** -->
<!-- Partners -->
<!-- ******** -->
<!-- MVP -->
<TR><TD COLSPAN="3"><A HREF="http://www.mvps.org"><IMG SRC="mvp_logo.gif" BORDER="0"></A></TR></TD>
<TR><TD HEIGHT="20" COLSPAN="3"> </TR></TD>
<!-- MSDN VB Community -->
<TR><TD COLSPAN="3" ALIGN="Center">
<A HREF="http://msdn.microsoft.com/vbasic/community/default.aspx">MSDN Visual Basic Community</A>
</TD></TR>
<TR><TD HEIGHT="50" COLSPAN="3"> </TR></TD>
<!-- Amazon Recommends -->
<TR><TD COLSPAN="3" ALIGN="Center">
<!-- -->
<SCRIPT SRC="http://rcm.amazon.com/e/cm?t=vbhelper&l=rc1&p=2&o=1" TYPE="text/JavaScript"></SCRIPT>
<!-- -->
<NOSCRIPT>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="125">
<TR><TD>
<MAP NAME="boxmap">
<AREA SHAPE="RECT" COORDS="18, 263, 105, 274" HREF="http://rcm.amazon.com/e/cm/privacy-policy.html?o=1">
<AREA COORDS="0,0,10000,10000" HREF="http://www.amazon.com/exec/obidos/redirect-home/vbhelper">
</MAP>
<img src="http://rcm-images.amazon.com/images/G/01/associates/amzn_recommends/gnbox125x275.gif" width="125" height="275" border="0" usemap="#boxmap">
</TD></TR>
</TABLE>
</NOSCRIPT>
</TD></TR>
<TR><TD HEIGHT="50" COLSPAN="3"> </TR></TD>
<!-- Wiley -->
<TR><TD COLSPAN="3" ALIGN="Center" BACKGROUND="sandpaper.gif"><A HREF="http://service.bfast.com/bfast/click?bfmid=37920629&siteid=40078832&bfpage=computer_science" TARGET="_top"><IMG SRC="wiley_logo.gif" BORDER="0" ALIGN="Center" WIDTH="77" HEIGHT="105"></TD></TR>
<TR><TD HEIGHT="10" COLSPAN="3"> </TR></TD>
<!-- Que -->
<TR><TD COLSPAN="3" ALIGN="Center"><A HREF="http://www.quepublishing.com"><IMG SRC="que.gif" BORDER="0" ALIGN="Center" WIDTH="121" HEIGHT="36"></A></TD></TR>
<TR><TD HEIGHT="10" COLSPAN="3"> </TR></TD>
<!-- Amazon -->
<TR><TD COLSPAN="3" ALIGN="Center"><A HREF="amazon.html"><IMG SRC="amazon_logo.gif" BORDER="0" ALIGN="Center" WIDTH="68" HEIGHT="65"></A></TD></TR>
<TR><TD HEIGHT="10" COLSPAN="3"> </TR></TD>
<!-- ********** -->
<!-- More stuff -->
<!-- ********** -->
</TABLE>
</TD>
<!-- A little space between the menus and content -->
<TD WIDTH="5"> </TD>
<!-- ******* -->
<!-- Content -->
<!-- ******* -->
<TD WIDTH="100%" ALIGN="Left" VALIGN="Top">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<!-- How To Summary -->
<TR><TD>
<TABLE WIDTH="100%" BORDER="2" CELLSPACING="0" CELLPADDING="2">
<TR><TH ALIGN="Left">Title</TH><TD WIDTH="100%">Display a status bar showing the steps in a long task</TD></TR>
<TR><TH ALIGN="Left">Description</TH><TD WIDTH="100%">This example shows how to display a status bar showing the steps in a long task in Visual Basic 6.</TD></TR>
<TR><TH ALIGN="Left">Keywords</TH><TD>StatusBar, steps, stages, progress, ProgressBar</TD></TR>
<TR><TH ALIGN="Left">Categories</TH><TD>Controls, Software Engineering</TD></TR>
</TABLE>
</TD></TR>
<!-- Text content -->
<TR><TD> <BR></TD></TR>
<TR><TD>
When the program starts, it prepares the StatusBar. It creates panels to show a message, a progress bar, and the time.
<P>
A key step here is calling subroutine MoveIntoStatusBar, which reparents the ProgressBar control into the StatusBar.
</TD></TR>
<!-- Code content -->
<TR><TD> <BR></TD></TR>
<TR>
<TD BACKGROUND="computer_paper.jpg">
<PRE><FONT NAME="Courier New" POINT-SIZE="10" SIZE="2">Private Sub Form_Load()
StatusBar1.Panels.Clear
With StatusBar1.Panels.Add()
.Text = ""
End With
With StatusBar1.Panels.Add()
.Width = 2 * 1440
End With
MoveIntoStatusBar StatusBar1, ProgressBar1, 2
With StatusBar1.Panels.Add()
.Style = sbrTime
.AutoSize = sbrSpring
End With
End Sub
Public Sub MoveIntoStatusBar(ByVal sbr As StatusBar, ByVal _
ctl As Control, ByVal panel_number As Long)
Dim r As RECT
<FONT COLOR="#008000">' Reparent the control into the status bar.</FONT>
SetParent ctl.hWnd, sbr.hWnd
<FONT COLOR="#008000">' Get the status bar's panel's rectangle.</FONT>
SendMessage sbr.hWnd, SB_GETRECT, panel_number - 1, r
<FONT COLOR="#008000">' Position the control in the panel.</FONT>
MoveWindow ctl.hWnd, r.Left, r.Top, r.Right - r.Left, _
r.Bottom - r.Top, True
End Sub</FONT></PRE>
</TD></TR>
<!-- Text content -->
<TR><TD> <BR></TD></TR>
<TR><TD>
When you click the Go button, the program sets the ProgressBar's minimum and maximum values. Then for a series of steps, the program calls subroutine SetProgress to show the current state of progress, and then wastes a little time.
<P>
Subroutine SetProgress displays a text message and sets the ProgressBar's value.
</TD></TR>
<!-- Code content -->
<TR><TD> <BR></TD></TR>
<TR>
<TD BACKGROUND="computer_paper.jpg">
<PRE><FONT NAME="Courier New" POINT-SIZE="10" SIZE="2">Private Sub cmdGo_Click()
ProgressBar1.Min = 0
ProgressBar1.Max = 7
SetProgress "Step 1 of 4", 1
WasteTime 0.5
SetProgress "Step 1 of 4", 2
WasteTime 0.5
SetProgress "Step 2 of 4", 3
WasteTime 0.5
SetProgress "Step 3 of 4", 4
WasteTime 0.5
SetProgress "Step 4 of 4", 5
WasteTime 0.5
SetProgress "Step 4 of 4", 6
WasteTime 0.5
SetProgress "Done", 0
End Sub
Private Sub SetProgress(ByVal txt As String, ByVal _
progress_value As Integer)
StatusBar1.Panels(1).Text = txt
StatusBar1.Refresh
ProgressBar1.Value = progress_value
ProgressBar1.Refresh
End Sub</FONT></PRE>
</TD></TR>
<!-- *************** -->
<!-- Download button -->
<!-- *************** -->
<TR><TD><FONT SIZE="-2"> </FONT></TD></TR>
<TR><TD ALIGN="Center"><A HREF="HowTo/howto_statusbar_show_progress.zip"><IMG SRC="download.jpg" BORDER="0"></A></TD></TR>
<TR><TD><FONT SIZE="-2"> </FONT></TD></TR>
</TABLE> <!-- End content table -->
</TD> <!-- End content column -->
<!-- ************** -->
<!-- Google AdSense -->
<!-- ************** -->
<TD WIDTH="120" ALIGN="Right" VALIGN="Top">
<TABLE WIDTH="165" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR><TD ALIGN="Right">
<script type="text/javascript"><!--
google_ad_client = "pub-6627515316741006";
google_ad_width = 160;
google_ad_height = 600;
google_ad_format = "160x600_as";
google_ad_channel ="4974732445";
google_color_border = "00CC66";
google_color_bg = "99FF99";
google_color_link = "0000FF";
google_color_url = "0033FF";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</TD></TR>
</TD> <!-- End Google AdSense column -->
</TR> <!-- End row containing menu column and content -->
</TABLE> <!-- End table containing menu column and content -->
</TD></TR>
<!-- ****** -->
<!-- Footer -->
<!-- ****** -->
<TR><TD WIDTH="100%">
<TABLE WIDTH="100%" BORDER="0" BGCOLOR="#87CEFA" CELLSPACING="0" CELLPADDING="0">
<!-- Top row -->
<TR>
<TD BGCOLOR="#E1F3FF" ALIGN="Right" WIDTH="16"><IMG SRC="blue_ul.jpg" WIDTH="16" HEIGHT="16"></TD>
<TD BACKGROUND="blue_um.jpg" COLSPAN="2" ALIGN="Center"><FONT SIZE="-2">
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc. All rights reserved.
</FONT></TD>
<TD BGCOLOR="#E1F3FF"><IMG SRC="blue_ur.jpg" WIDTH="16" HEIGHT="16"></TD>
</TR>
<!-- Bottom row -->
<TR>
<TD BGCOLOR="#E1F3FF" ALIGN="Right" WIDTH="16"><IMG SRC="blue_ll.jpg" WIDTH="16" HEIGHT="16"></TD>
<TD BACKGROUND="blue_lm.jpg"><FONT SIZE="-2">
<SCRIPT LANGUAGE=JavaScript>document.write(document.URL)</SCRIPT></FONT></TD>
<TD BACKGROUND="blue_lm.jpg" ALIGN="Right"><FONT SIZE="-2">
Updated <SCRIPT LANGUAGE=JavaScript>document.write(document.lastModified)</SCRIPT>
</FONT></TD>
<TD BGCOLOR="#E1F3FF"><IMG SRC="blue_lr.jpg" WIDTH="16" HEIGHT="16"></TD>
</TR>
</TABLE>
</TD></TR>
</TABLE> <!-- End table containing banner, menu column + content, and footer -->
</BODY>
</HTML>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -