diff --git a/source/gui/widgets/progress.cpp b/source/gui/widgets/progress.cpp index 20b46ddc..2c498f7c 100644 --- a/source/gui/widgets/progress.cpp +++ b/source/gui/widgets/progress.cpp @@ -91,19 +91,26 @@ namespace nana { return value_px_; } + + bool value_px_sync() + { + if (widget_) + { + auto value_px = (widget_->size().width - border_px * 2) * value_ / max_; + + if (value_px != value_px_) + { + value_px_ = value_px; + return true; + } + } + return false; + } private: void _m_try_refresh() { - if (nullptr == widget_) - return; - - auto value_px = (widget_->size().width - border_px * 2) * value_ / max_; - - if (value_px != value_px_) - { - value_px_ = value_px; + if (value_px_sync()) API::refresh_window(*widget_); - } } private: nana::progress * widget_{ nullptr }; @@ -144,6 +151,9 @@ namespace nana auto rt_bground = rt_val; if (false == progress_->unknown(nullptr)) { + //Sync the value_px otherwise the progress is incorrect when it is resized. + progress_->value_px_sync(); + rt_bground.x = static_cast(progress_->value_px()) + static_cast(border_px); rt_bground.width -= progress_->value_px();