Removed references to wxBuffer from wxSlider, and

ensured that the slider doesn't use a potentially
uninitialised buffer.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-10-04 10:28:06 +00:00
parent 6bd20f9d73
commit 8c92ffaa71
2 changed files with 19 additions and 14 deletions

View File

@@ -109,13 +109,14 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
); );
// Now create min static control // Now create min static control
wxSprintf(wxBuffer, wxT("%d"), minValue); wxString minLabel;
minLabel.Printf(wxT("%d"), minValue);
wstyle = STATIC_FLAGS; wstyle = STATIC_FLAGS;
if ( m_windowStyle & wxCLIP_SIBLINGS ) if ( m_windowStyle & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS; msStyle |= WS_CLIPSIBLINGS;
m_staticMin = (WXHWND) CreateWindowEx m_staticMin = (WXHWND) CreateWindowEx
( (
0, wxT("STATIC"), wxBuffer, 0, wxT("STATIC"), minLabel,
wstyle, wstyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
wxGetInstance(), NULL wxGetInstance(), NULL
@@ -153,7 +154,7 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
HWND scroll_bar = CreateWindowEx HWND scroll_bar = CreateWindowEx
( (
MakeExtendedStyle(m_windowStyle), TRACKBAR_CLASS, wxBuffer, MakeExtendedStyle(m_windowStyle), TRACKBAR_CLASS, wxT(""),
msStyle, msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL wxGetInstance(), NULL
@@ -179,7 +180,8 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
if ( m_windowStyle & wxSL_LABELS ) if ( m_windowStyle & wxSL_LABELS )
{ {
// Finally, create max value static item // Finally, create max value static item
wxSprintf(wxBuffer, wxT("%d"), maxValue); wxString maxLabel;
maxLabel.Printf(wxT("%d"), maxValue);
wstyle = STATIC_FLAGS; wstyle = STATIC_FLAGS;
if ( m_windowStyle & wxCLIP_SIBLINGS ) if ( m_windowStyle & wxCLIP_SIBLINGS )
@@ -187,7 +189,7 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
m_staticMax = (WXHWND) CreateWindowEx m_staticMax = (WXHWND) CreateWindowEx
( (
0, wxT("STATIC"), wxBuffer, 0, wxT("STATIC"), maxLabel,
wstyle, wstyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
wxGetInstance(), NULL wxGetInstance(), NULL
@@ -319,8 +321,9 @@ void wxSlider95::SetValue(int value)
if (m_staticValue) if (m_staticValue)
{ {
wxSprintf(wxBuffer, wxT("%d"), value); wxString str;
::SetWindowText((HWND) m_staticValue, wxBuffer); str.Printf(wxT("%d"), value);
::SetWindowText((HWND) m_staticValue, str);
} }
} }

View File

@@ -92,11 +92,12 @@ bool wxSliderMSW::Create(wxWindow *parent, wxWindowID id,
wxGetInstance(), NULL); wxGetInstance(), NULL);
// Now create min static control // Now create min static control
wxSprintf(wxBuffer, wxT("%d"), minValue); wxString buf;
buf.Printf(wxT("%d"), minValue);
DWORD wstyle = STATIC_FLAGS; DWORD wstyle = STATIC_FLAGS;
if ( m_windowStyle & wxCLIP_SIBLINGS ) if ( m_windowStyle & wxCLIP_SIBLINGS )
wstyle |= WS_CLIPSIBLINGS; wstyle |= WS_CLIPSIBLINGS;
m_staticMin = (WXHWND) CreateWindowEx(0, wxT("STATIC"), wxBuffer, m_staticMin = (WXHWND) CreateWindowEx(0, wxT("STATIC"), buf,
wstyle, wstyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
wxGetInstance(), NULL); wxGetInstance(), NULL);
@@ -107,7 +108,7 @@ bool wxSliderMSW::Create(wxWindow *parent, wxWindowID id,
else else
msStyle = SBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP ; msStyle = SBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP ;
HWND scroll_bar = CreateWindowEx(MakeExtendedStyle(m_windowStyle), wxT("SCROLLBAR"), wxBuffer, HWND scroll_bar = CreateWindowEx(MakeExtendedStyle(m_windowStyle), wxT("SCROLLBAR"), wxT(""),
msStyle, msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL); wxGetInstance(), NULL);
@@ -126,11 +127,11 @@ bool wxSliderMSW::Create(wxWindow *parent, wxWindowID id,
SubclassWin(GetHWND()); SubclassWin(GetHWND());
// Finally, create max value static item // Finally, create max value static item
wxSprintf(wxBuffer, wxT("%d"), maxValue); buf.Printf(wxT("%d"), maxValue);
wstyle = STATIC_FLAGS; wstyle = STATIC_FLAGS;
if ( m_windowStyle & wxCLIP_SIBLINGS ) if ( m_windowStyle & wxCLIP_SIBLINGS )
wstyle |= WS_CLIPSIBLINGS; wstyle |= WS_CLIPSIBLINGS;
m_staticMax = (WXHWND) CreateWindowEx(0, wxT("STATIC"), wxBuffer, m_staticMax = (WXHWND) CreateWindowEx(0, wxT("STATIC"), buf,
wstyle, wstyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
wxGetInstance(), NULL); wxGetInstance(), NULL);
@@ -261,8 +262,9 @@ void wxSliderMSW::SetValue(int value)
::SetScrollPos(GetHwnd(), SB_CTL, value, TRUE); ::SetScrollPos(GetHwnd(), SB_CTL, value, TRUE);
if (m_staticValue) if (m_staticValue)
{ {
wxSprintf(wxBuffer, wxT("%d"), value); wxString buf;
SetWindowText((HWND) m_staticValue, wxBuffer); buf.Printf(wxT("%d"), value);
SetWindowText((HWND) m_staticValue, buf);
} }
} }