1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2006 - Stefan Kueng
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
23 * Helper class for setting mouse cursors.\n
\r
24 * There are two ways of using this class:
\r
25 * -# Just declare a CCursor object with the
\r
26 * required cursor. As soon as the object
\r
27 * goes out of scope the previous cursor
\r
32 * CCursor(IDC_WAIT);
\r
33 * //do something here
\r
35 * //now CCursor is out of scope and the default cursor is restored
\r
37 * -# use the object the usual way. Declare a CCursor object
\r
38 * and use the methods to set the cursors.
\r
40 * \remark the class can be used on Win95 and NT4 too, but the
\r
41 * hand cursor won't be available.
\r
47 * Constructs a CCursor object.
\r
49 CCursor(LPCTSTR CursorName)
\r
52 m_bInitialized = FALSE;
\r
53 SetCursor(CursorName);
\r
59 m_bInitialized = FALSE;
\r
67 * Sets a new cursor. If you previously set a new cursor then
\r
68 * before setting a second cursor the old one is restored and
\r
69 * then the new one is set.
\r
71 HCURSOR SetCursor(LPCTSTR CursorName)
\r
73 //first restore possible old cursor before setting new one
\r
75 //try to load system cursor
\r
76 HCURSOR NewCursor = ::LoadCursor(NULL, CursorName);
\r
78 //try to load application cursor
\r
79 NewCursor = ::LoadCursor(AfxGetResourceHandle(), CursorName);
\r
82 m_hOldCursor = ::SetCursor(NewCursor);
\r
83 m_bInitialized = TRUE;
\r
87 m_bInitialized = FALSE;
\r
88 TRACE("cursor not found!\n");
\r
90 return m_hOldCursor;
\r
93 * Restores the cursor.
\r
100 ::SetCursor(m_hOldCursor);
\r
101 m_hOldCursor = NULL;
\r
103 m_bInitialized = FALSE;
\r
107 HCURSOR m_hOldCursor;
\r
108 BOOL m_bInitialized;
\r