📄 skinprogress.cpp
字号:
(
LPCTSTR i_poStrMessage,
int i_nUpper, // = 100
int i_nProgress, // = cSPT_PERCENT
CBitmap* i_poBitmap // = NULL
#ifdef dCSP_SLIDERBAR_METHOD
,BOOL i_bReverse // = false
#endif // dCSP_SLIDERBAR_METHOD
)
{
// Init
// A..... Set base values
m_poBaseBmp = NULL;
m_poCompatibleBmp = NULL;
m_poStretchBmp = NULL;
m_poProgressBmp = NULL;
m_oStrPrevMessage = "";
m_oRectPane.SetRect(0, 0, 0, 0);
// Process + Return
// B..... Set the bitmap
if(
!SetBitmap
(
i_poBitmap
#ifndef dCSP_TIMED_REDRAW
,false
#endif // dCSP_TIMED_REDRAW
)
)
{
return false;
}
else
{
// C..... Set the progress bar values
// Set the progress text type
m_nProgressText = i_nProgress;
// Set range and step
m_nLower = 0; // Set first parameters for the resampling
ASSERT(i_nUpper > 0); // m_nLower is 0, m_nUpper CANNOT BE BEFORE m_nLower quite now
m_nUpper = i_nUpper;
#ifdef dCSP_SLIDERBAR_METHOD
m_nLeft = 0;
#endif // dCSP_SLIDERBAR_METHOD
m_nRight = 0;
SetRange
(
0,
i_nUpper,
1,
false
#ifndef dCSP_TIMED_REDRAW
,false // Don't resample range, and avoid display there !
#endif // dCSP_TIMED_REDRAW
);
// Set and save additional values
m_oStrMessage = i_poStrMessage;
#ifdef dCSP_SLIDERBAR_METHOD
m_bReverse = i_bReverse;
#endif // dCSP_SLIDERBAR_METHOD
// D..... Get the creation date and time of the progress bar and set its position to the beginning
Reset
(
#ifndef dCSP_TIMED_REDRAW
false
#endif // dCSP_TIMED_REDRAW
);
// E..... Set the refresh timer to 500 milliseconds (or 20ms/50Hz in <dCSP_TIMED_REDRAW> mode)
#ifndef dCSP_TIMED_REDRAW
SetTimer((UINT) this, 500, NULL); // Use object's unique address as timer identifier
#else
SetTimer((UINT) this, 20, NULL); // Use object's unique address as timer identifier
#endif // dCSP_TIMED_REDRAW
// F..... Resize the text and display the whole things
RefreshPanes(); // Set the text in pane 0 and do the first drawing of the SkinProgress bar
return true;
}
}
/*--- START FUNCTION HEADER --------------------------------------------------*/
/* Name : ProgressInStatusBar */
/* Role : Create the progress in status bar with basic parameters */
/* Type : PROTECTED */
/* Interface : RETURN (direct value) */
/* BOOL = false : Error during progress bar creation */
/* true : Progress bar created */
/* OUTPUT (pointer to value) */
/* None */
/* INPUT (pointer to value, direct/default value) */
/* i_poStrMessage : The text message to display in pane 0 */
/* i_nUpper : Upper limit to reach 100% (0 at 0%) */
/* i_nProgress : Progress completion message type */
/* i_nPane : Pane number for the progress bar */
/* i_nSize : Progress bar width in pixel IF pane 0 */
/* i_poBitmap : Replacement progress bar bitmap */
/* <> i_bReverse : Reverse display of the progress bar */
/* Pre-condition : None */
/* Constraints : Base of progress bar is fixed to 0, must use [SetRange] to */
/* change it... */
/* Behavior : A - Get status bar handler */
/* B - Create a CStatic object upon the target pane */
/* C - Specific Status Bar initialization */
/* D - Create and initialize the progress bar */
/*----------------------------------------------------------------------------*/
/* PROC ProgressInStatusBar */
/* */
/* A..... Get status bar handler */
/* [IF there is a status bar] */
/* : B..... Create a CStatic object upon the target status bar pane */
/* : [IF CStatic creation OK] */
/* : : C..... Specific Status Bar initialization */
/* : : D..... Create and initialize the progress bar */
/* : [ENDIF] */
/* [ENDIF] */
/*----------------------------------------------------------------------------*/
/*--- END FUNCTION HEADER ----------------------------------------------------*/
BOOL CSkinProgress::ProgressInStatusBar
( // The initialization routine
LPCTSTR i_poStrMessage, // Text to display
int i_nUpper, // = 100, : Default range from 0 to i_nUpper
int i_nProgress, // = cSPT_PERCENT : Message type to add to the text
int i_nPane, // = 0, : Pane number in which display the progress bar
int i_nSize, // = 200, : Size of the progress bar if in pane 0
CBitmap* i_poBitmap // = NULL : Pointer to a user bitmap
#ifdef dCSP_SLIDERBAR_METHOD
,BOOL i_bReverse // = false
#endif // dCSP_SLIDERBAR_METHOD
)
{
BOOL bSuccess;
CStatusBar* poStatusBar;
DWORD nStyleEx;
DWORD nStyle;
CRect oRectPane;
LPCSTR poStrClass;
UINT nClassStyle;
// Init
bSuccess = false;
#ifdef dCSP_DIALOG_PROGRESS
m_poWndProgress = NULL;
m_poWndMessage = NULL;
#endif // dCSP_DIALOG_PROGRESS
// Process
// A..... Get status bar handler
poStatusBar = GetStatusBar();
if(poStatusBar != NULL)
{
// B..... Create a CStatic object upon the target status bar pane
// Set the style for the custom progress bas
nClassStyle = 0; // CS_CLASSDC | CS_HREDRAW | CS_VREDRAW;
nStyleEx = WS_EX_STATICEDGE;
nStyle = WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_CENTERIMAGE;
// Get CRect coordinates for requested status bar pane
poStatusBar->GetItemRect(i_nPane, &oRectPane);
// Create the progress bar
poStrClass = AfxRegisterWndClass(nClassStyle, AfxGetApp()->LoadStandardCursor(IDC_WAIT));
bSuccess = CStatic::CreateEx(nStyleEx, poStrClass, "", nStyle, oRectPane, poStatusBar, (UINT) this); // Use object's unique address as child window identifier
ASSERT(bSuccess);
if(!bSuccess)
{
return false;
}
else
{
#ifdef dCSP_VERTICAL_BAR
#ifndef dCSP_DISPLAY_STRETCH
m_bVertical = false; // *ALWAYS false IN CSkinProgress while in StatusBar mode*
#else
m_bVertical = true; // *FORCE* vertical for m_poStretchBmp analysis
#endif // dCSP_DISPLAY_STRETCH
#endif // dCSP_VERTICAL_BAR
// C..... Specific Status Bar initialization
SetSize
(
i_nSize
#ifndef dCSP_TIME
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -