STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

winstl_setcursor_scope.h

Go to the documentation of this file.
00001 /* 
00002  * File:        winstl_setcursor_scope.h
00003  *
00004  * Purpose:     Cursor scoping class.
00005  *
00006  * Created:     12th May 2003
00007  * Updated:     11th September 2004
00008  *
00009  * Home:        http://stlsoft.org/
00010  *
00011  * Copyright (c) 2003-2004, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * 
00039 
00040 
00044 
00045 #ifndef WINSTL_INCL_H_WINSTL_SETCURSOR_SCOPE
00046 #define WINSTL_INCL_H_WINSTL_SETCURSOR_SCOPE
00047 
00048 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00049 # define WINSTL_VER_H_WINSTL_SETCURSOR_SCOPE_MAJOR      2
00050 # define WINSTL_VER_H_WINSTL_SETCURSOR_SCOPE_MINOR      0
00051 # define WINSTL_VER_H_WINSTL_SETCURSOR_SCOPE_REVISION   1
00052 # define WINSTL_VER_H_WINSTL_SETCURSOR_SCOPE_EDIT       18
00053 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00054 
00055 /* 
00056  * Includes
00057  */
00058 
00059 #ifndef WINSTL_INCL_H_WINSTL
00060 # include "winstl.h"                    // Include the WinSTL root header
00061 #endif /* WINSTL_INCL_H_WINSTL */
00062 #ifndef STLSOFT_INCL_H_STLSOFT_STRING_ACCESS
00063 # include "stlsoft_string_access.h"     // stlsoft::c_str_ptr
00064 #endif /* !STLSOFT_INCL_H_STLSOFT_STRING_ACCESS */
00065 #ifndef WINSTL_INCL_H_WINSTL_STRING_ACCESS
00066 # include "winstl_string_access.h"      // stlsoft::c_str_ptr
00067 #endif /* !WINSTL_INCL_H_WINSTL_STRING_ACCESS */
00068 
00069 /* 
00070  * Namespace
00071  */
00072 
00073 #ifndef _WINSTL_NO_NAMESPACE
00074 # if defined(_STLSOFT_NO_NAMESPACE) || \
00075      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00076 /* There is no stlsoft namespace, so must define ::winstl */
00077 namespace winstl
00078 {
00079 # else
00080 /* Define stlsoft::winstl_project */
00081 
00082 namespace stlsoft
00083 {
00084 
00085 namespace winstl_project
00086 {
00087 
00088 # endif /* _STLSOFT_NO_NAMESPACE */
00089 #endif /* !_WINSTL_NO_NAMESPACE */
00090 
00091 #if !defined(__STLSOFT_COMPILER_IS_MWERKS)
00092 stlsoft_ns_using(c_str_ptr)
00093 #endif /* compiler */
00094 
00095 /* 
00096 
00099 
00103 
00108 
00109 /* 
00110  * Classes
00111  */
00112 
00113 // setcursor_scope
00118 class setcursor_scope
00119 {
00120 public:
00121     typedef setcursor_scope class_type;
00122 
00123 // Construction
00124 public:
00128     ss_explicit_k setcursor_scope(HCURSOR hcur)
00129         : m_hcurLast(::SetCursor(hcur))
00130     {}
00131 #ifdef __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT
00135     template <ss_typename_param_k S>
00136     setcursor_scope(HINSTANCE hinst, S const &name)
00137         : m_hcurLast(::SetCursor(load_(hinst, c_str_ptr(name))))
00138     {}
00139 #endif /* __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT */
00143     setcursor_scope(HINSTANCE hinst, ws_char_a_t const *name)
00144         : m_hcurLast(::SetCursor(load_(hinst, name)))
00145     {}
00149     setcursor_scope(HINSTANCE hinst, ws_char_w_t const *name)
00150         : m_hcurLast(::SetCursor(load_(hinst, name)))
00151     {}
00155     setcursor_scope(HINSTANCE hinst, int id)
00156         : m_hcurLast(::SetCursor(::LoadCursor(hinst, MAKEINTRESOURCE(id))))
00157     {}
00159     ~setcursor_scope()
00160     {
00161         ::SetCursor(m_hcurLast);
00162     }
00163 
00165 private:
00166     static HCURSOR load_(HINSTANCE hinst, ws_char_a_t const *name)
00167     {
00168         return ::LoadCursorA(hinst, name);
00169     }
00170     static HCURSOR load_(HINSTANCE hinst, ws_char_w_t const *name)
00171     {
00172         return ::LoadCursorW(hinst, name);
00173     }
00174 
00176 private:
00177     HCURSOR m_hcurLast;
00178 
00180 private:
00181     setcursor_scope(setcursor_scope const &);
00182     setcursor_scope &operator =(setcursor_scope const &);
00183 };
00184 
00185 /* 
00186 
00188 
00189 /* 
00190 
00191 #ifndef _WINSTL_NO_NAMESPACE
00192 # if defined(_STLSOFT_NO_NAMESPACE) || \
00193      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00194 } // namespace winstl
00195 # else
00196 } // namespace winstl_project
00197 } // namespace stlsoft
00198 # endif /* _STLSOFT_NO_NAMESPACE */
00199 #endif /* !_WINSTL_NO_NAMESPACE */
00200 
00201 /* 
00202 
00203 #endif /* WINSTL_INCL_H_WINSTL_SETCURSOR_SCOPE */
00204 
00205 /* 

STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004