00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef WINSTL_INCL_WINSTL_WINDOW_HPP_WINDOW_TEXT_SCOPE
00048 #define WINSTL_INCL_WINSTL_WINDOW_HPP_WINDOW_TEXT_SCOPE
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define WINSTL_VER_WINSTL_WINDOW_HPP_WINDOW_TEXT_SCOPE_MAJOR 4
00052 # define WINSTL_VER_WINSTL_WINDOW_HPP_WINDOW_TEXT_SCOPE_MINOR 1
00053 # define WINSTL_VER_WINSTL_WINDOW_HPP_WINDOW_TEXT_SCOPE_REVISION 1
00054 # define WINSTL_VER_WINSTL_WINDOW_HPP_WINDOW_TEXT_SCOPE_EDIT 39
00055 #endif
00056
00057
00058
00059
00060
00061 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00062 # include <winstl/winstl.h>
00063 #endif
00064 #ifndef WINSTL_INCL_SHIMS_ATTRIBUTE_HPP_GET_HWND
00065 # include <winstl/shims/attribute/get_HWND.hpp>
00066 #endif
00067 #ifndef WINSTL_INCL_WINSTL_WINDOW_HPP_WINDOW_TRAITS
00068 # include <winstl/window/window_traits.hpp>
00069 #endif
00070 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER
00071 # include <stlsoft/memory/auto_buffer.hpp>
00072 #endif
00073 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR
00074 # include <winstl/memory/processheap_allocator.hpp>
00075 #endif
00076
00077
00078
00079
00080
00081 #ifndef _WINSTL_NO_NAMESPACE
00082 # if defined(_STLSOFT_NO_NAMESPACE) || \
00083 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00084
00085 namespace winstl
00086 {
00087 # else
00088
00089
00090 namespace stlsoft
00091 {
00092
00093 namespace winstl_project
00094 {
00095
00096 # endif
00097 #endif
00098
00099
00100
00101
00102
00103
00111 template <ss_typename_param_k S>
00112 class window_text_scope
00113 {
00116 public:
00118 typedef S string_type;
00120 typedef window_text_scope<S> class_type;
00122 typedef ss_typename_type_k string_type::value_type char_type;
00124 typedef window_traits<char_type> traits_type;
00125 private:
00126 typedef stlsoft_ns_qual(auto_buffer_old)< char_type
00127 , processheap_allocator<char_type>
00128 > buffer_type_;
00130
00133 public:
00141 ss_explicit_k window_text_scope(HWND wnd, char_type const* s)
00142 : m_hwnd(wnd)
00143 {
00144 buffer_type_ buffer(1 + traits_type::get_window_text_length(m_hwnd));
00145
00146 if(0 < buffer.size())
00147 {
00148 buffer[buffer.size() - 1] = char_type(0);
00149
00150 traits_type::get_window_text(m_hwnd, &buffer[0], buffer.size());
00151
00152 m_oldText = buffer.data();
00153
00154 traits_type::set_window_text(m_hwnd, s);
00155 }
00156 }
00157
00158 #ifdef STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT
00166 #if 0
00167 template <ss_typename_param_k S>
00168 ss_explicit_k window_text_scope(HWND wnd, S const& s)
00169 : m_hwnd(wnd)
00170 {
00171 buffer_type_ buffer(1 + traits_type::get_window_text_length(m_hwnd));
00172
00173 if(0 < buffer.size())
00174 {
00175 buffer[buffer.size() - 1] = char_type(0);
00176
00177 traits_type::get_window_text(m_hwnd, &buffer[0], buffer.size());
00178
00179 m_oldText = buffer.data();
00180
00181 traits_type::set_window_text(m_hwnd, s);
00182 }
00183 }
00184 #endif
00185
00193 template< ss_typename_param_k W
00194 , ss_typename_param_k S1
00195 >
00196 ss_explicit_k window_text_scope(W &wnd, S1 const& s)
00197 : m_hwnd(get_HWND(wnd))
00198 {
00199 buffer_type_ buffer(1 + traits_type::get_window_text_length(m_hwnd));
00200
00201 if(0 < buffer.size())
00202 {
00203 buffer[buffer.size() - 1] = char_type(0);
00204
00205 traits_type::get_window_text(m_hwnd, &buffer[0], buffer.size());
00206
00207 m_oldText = buffer.data();
00208
00209 traits_type::set_window_text(m_hwnd, s);
00210 }
00211 }
00212 #endif
00213
00215 ~window_text_scope() stlsoft_throw_0()
00216 {
00217 traits_type::set_window_text(m_hwnd, m_oldText);
00218 }
00220
00223 private:
00224 HWND m_hwnd;
00225 string_type m_oldText;
00227
00230 private:
00231 window_text_scope(class_type const& rhs);
00232 class_type const& operator =(class_type const& rhs);
00234 };
00235
00236
00237
00238 #ifndef _WINSTL_NO_NAMESPACE
00239 # if defined(_STLSOFT_NO_NAMESPACE) || \
00240 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00241 }
00242 # else
00243 }
00244 }
00245 # endif
00246 #endif
00247
00248
00249
00250 #endif
00251
00252