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