Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
void Slider::set_value(std::size_t value) { if (value < m_range.first) value = m_range.first; else if (value > m_range.second) value = m_range.second; else if (m_value == value) return; ::RECT rect; ::GetClientRect(m_hWnd, &rect); // value multiplier const double multiplier(static_cast<double>(rect.right - rect.left - 10) / (m_range.second - m_range.first)); // old cursor pos const long old_x(rect.left + static_cast<long>(multiplier * (m_value - m_range.first))); // old cursor rect const ::RECT old_rect = { old_x - 5, rect.top, old_x + 5, rect.bottom }; const std::size_t old_value(m_value); m_value = value; // new cursor pos const long new_x(rect.left + 5 + static_cast<long>(multiplier * (m_value - m_range.first))); rect.left = new_x - 5; rect.right = new_x + 5; // redraw old and new rect ::InvalidateRect(m_hWnd, &old_rect, TRUE); ::InvalidateRect(m_hWnd, &rect, TRUE); ::SendMessageW(m_pParentWnd->get_safe_hwnd(), SMN_POSCHANGE, MAKEWPARAM(old_value, m_value), reinterpret_cast<LPARAM>(m_hWnd)); } |
Zitat von »"msdn"«
By convention, the right and bottom edges of the rectangle are normally considered exclusive. In other words, the pixel whose coordinates are (right, bottom) lies immediately outside of the the rectangle. For example, when RECT is passed to the FillRect function, the rectangle is filled up to, but not including, the right column and bottom row of pixels. This structure is identical to the RECTL structure.
Werbeanzeige