Progress Bar Control Class
Brief Introduction to Progress Bar Control
Progress bar control is an essential control in GUI system, which can visually show progress of an item and is often used in file copying, software installation and file transmission. Progress bar control in mGNCS is strengthened and reconstructed based on the built-in progress bar control in MiniGUI 3.0, and setting of renderer is added, making it easier to use and more splendid.
Class hierarchical relation of progress bar
mProgressBar
mProgressBar
Control window class:
NCSCTRL_PROGRESSBAR
Control English name:
ProgressBar
Brief introduction: Used to show progress, often used in file copying, software installation and file transmission.
Schematic diagram:

Style of mProgressBar
mProgressBar
It is inherited from the style of mWidget
Style ID
miniStudio property
Explanation
Comments
NCSS_PRGBAR_HORIZONTAL
--
In miniStudio, the two styles are divided into two controls to use, respectively corresponding to
Horz ProgressBar
NCSS_PRGBAR_VERTICAL
--
^
Vert ProgressBar
NCSS_PRGBAR_BLOCKS
BlockChunk->TRUE
Block progress
NCSS_PRGBAR_SMOOTH
BlockChunk->FALSE
Smooth progress, relative to the above block progress
NCSS_PRGBAR_SHOWPERCENT
ShowPercent
Display the current progress value (percentage)
Property of mProgressBar
mProgressBar
It is inherited from the property of mWidget
Property name
miniStudio property name
Type
RW
Explanation
NCSP_PROG_MAXPOS
MaxPos
int
RW
Maximum value of the progress range
NCSP_PROG_MINPOS
MinPos
int
RW
Minimum value of the progress range
NCSP_PROG_CURPOS
CurPos
int
RW
Current progress value
NCSP_PROG_LINESTEP
LineStep
int
RW
Step length
Event of mProgressBar
mProgressBar
It is inherited from the event of mWidget.
The control class does not have newly added event
Method of mProgressBar
mProgressBar
It is inherited from the method of mWidget
increase
int increase (mProgressBar *self, int delta);
Parameter:
self :control object pointer
delta :increase amplitude
Explanation: users can use the function to control increase of the progress value; delta is used to appoint the increase amount, which is generally used to control the increase effect of non even speed
Example:
_c(pb)->increase (pb, 5); //The progress value increases 5
stepIncrease
stepIncrease
int stepIncrease (mProgressBar *_this);
Parameter:
self :control object pointer
Explanation: the function can increase the progress value by step; calling once, a step length value is increased, and even-speed increase effect can be realized; setting of step length value is completed through corresponding properties
Example:
// Set step length of ProgressBar
_c(pb)->setProperty(pb, NCSP_PROG_LINESTEP, 5);
......
_c(pb)->stepIncrease (pb);
Renderer of mProgressBar
mProgressBar
Classic Renderer
It is inherited from the classic renderer of mWidget.
Property name
miniStudio property
Type
Schematic diagram
Explanation
NCS_BGC_HILIGHT_ITEM
ChunkColor
DWORD(ARGB
)
Color of chunk part of the progress bar, and this renderer uses the color of highlight item to draw
Fashion Renderer
It is inherited from the fashion renderer of mWidget.
Property name
miniStudio property name
Type
Schematic diagram
Explanation
NCS_BGC_PRGBAR_CHUNK
ChunkColor
DWORD(ARGB
)
Foundation color of chunk part of the progress bar, and the renderer will lighten or darken according to this color to draw progress bar of gradual change effect
Flat Renderer
It is inherited from flat renderer of mWidget.
Property name
miniStudio property name
Type
Schematic diagram
Explanation
NCS_FGC_WINDOW
ChunkColor
DWORD(ARGB
)
Color of chunk part of the progress bar, here window foreground color is used
Skin Renderer
Refer to Specification for Image Resource Used by Skin Renderer
Instance of mProgressBar
mProgressBar
ProgressBar
Example code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <mgncs/mgncs.h>
#define ID_BTN 101
#define ID_PROG 200
static BOOL mymain_onCreate (mWidget* _this, DWORD add_data)
{
SetTimer (_this->hwnd, 100, 20);
return TRUE;
}
static void mymain_onClose (mWidget* _this, int message)
{
DestroyMainWindow (_this->hwnd);
PostQuitMessage (_this->hwnd);
}
static void mymain_onTimer (mWidget *_this, int id, DWORD count)
{
//START_OF_SET_PROPERTY
static int pb_pos = 0;
mProgressBar *pb = (mProgressBar*)ncsGetChildObj (_this->hwnd, ID_PROG);
if (pb)
{
pb_pos++;
_c(pb)->setProperty(pb, NCSP_PROG_CURPOS, pb_pos);
if (pb_pos == _c(pb)->getProperty(pb, NCSP_PROG_MAXPOS))
{
DestroyMainWindow (_this->hwnd);
PostQuitMessage (_this->hwnd);
}
}
//END_OF_SET_PROPERTY
}
static void mymain_onPaint(mWidget *self, HDC hdc, const CLIPRGN* inv)
{
SetBkMode (hdc, BM_TRANSPARENT);
TextOut (hdc, 10, 10, "Installing ......");
}
static NCS_EVENT_HANDLER mymain_handlers[] = {
{MSG_CREATE, mymain_onCreate},
{MSG_CLOSE, mymain_onClose},
{MSG_PAINT, mymain_onPaint},
{MSG_TIMER, mymain_onTimer},
{0, NULL}
};
static void btn_onClicked(mWidget* _this, int id, int nc, HWND hCtrl)
{
if(nc == NCSN_WIDGET_CLICKED)
{
PostMessage(GetParent(_this->hwnd), MSG_CLOSE, 0, 0);
}
};
static NCS_EVENT_HANDLER btn_handlers[] =
{
{NCS_NOTIFY_CODE(NCSN_WIDGET_CLICKED), btn_onClicked},
{0, NULL}
};
static NCS_RDR_INFO btn_rdr_info[] =
{
{"fashion","fashion", NULL}
};
//START_OF_INITIAL_PROPS
static NCS_PROP_ENTRY progress_props[] =
{
{NCSP_PROG_MAXPOS, 100},
{NCSP_PROG_MINPOS, 0 },
{NCSP_PROG_LINESTEP, 1},
{NCSP_PROG_CURPOS, 0 },
{ 0, 0 }
};
//END_OF_INITIAL_PROPS
//START_OF_TEMPLATE
static NCS_WND_TEMPLATE _ctrl_templ[] =
{
{
NCSCTRL_PROGRESSBAR,
ID_PROG,
10, 33, 290, 25,
WS_BORDER | WS_VISIBLE | NCSS_PRGBAR_SHOWPERCENT,
WS_EX_NONE,
"",
progress_props,
NULL,
NULL, NULL, 0, 0
},
{
NCSCTRL_BUTTON,
ID_BTN,
120, 70, 80, 25,
WS_VISIBLE | NCSS_NOTIFY,
WS_EX_NONE,
"Cancel",
NULL,
btn_rdr_info,
btn_handlers, NULL, 0, 0
},
};
//END_OF_TEMPLATE
static NCS_MNWND_TEMPLATE mymain_templ =
{
NCSCTRL_DIALOGBOX,
1,
0, 0, 320, 130,
WS_CAPTION | WS_BORDER | WS_VISIBLE,
WS_EX_NONE,
"Progressbar",
NULL,
NULL,
mymain_handlers,
_ctrl_templ,
sizeof(_ctrl_templ)/sizeof(NCS_WND_TEMPLATE),
0,
0, 0,
};
int MiniGUIMain (int argc, const char* argv[])
{
ncsInitialize ();
mDialogBox* mydlg = (mDialogBox *)ncsCreateMainWindowIndirect
(&mymain_templ, HWND_DESKTOP);
_c(mydlg)->doModal (mydlg, TRUE);
ncsUninitialize ();
return 0;
}
ProgressBar
template
static NCS_WND_TEMPLATE _ctrl_templ[] =
{
{
NCSCTRL_PROGRESSBAR,
ID_PROG,
10, 33, 290, 25,
WS_BORDER | WS_VISIBLE | NCSS_PRGBAR_SHOWPERCENT,
WS_EX_NONE,
"",
progress_props,
NULL,
NULL, NULL, 0, 0
},
{
NCSCTRL_BUTTON,
ID_BTN,
120, 70, 80, 25,
WS_VISIBLE | NCSS_NOTIFY,
WS_EX_NONE,
"Cancel",
NULL,
btn_rdr_info,
btn_handlers, NULL, 0, 0
},
};
Initialize the property of
ProgressBar
static NCS_PROP_ENTRY progress_props[] =
{
{NCSP_PROG_MAXPOS, 100},
{NCSP_PROG_MINPOS, 0 },
{NCSP_PROG_LINESTEP, 1},
{NCSP_PROG_CURPOS, 0 },
{ 0, 0 }
};
In Timer message, change the property value of
ProgressBar
static int pb_pos = 0;
mProgressBar *pb = (mProgressBar*)ncsGetChildObj (_this->hwnd, ID_PROG);
if (pb)
{
pb_pos++;
_c(pb)->setProperty(pb, NCSP_PROG_CURPOS, pb_pos);
if (pb_pos == _c(pb)->getProperty(pb, NCSP_PROG_MAXPOS))
{
DestroyMainWindow (_this->hwnd);
PostQuitMessage (_this->hwnd);
}
}
<< Spinner Control Class | Table of Contents | Property Sheet Control Class >>
Last updated