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 m_hOldCursor
= nullptr;
54 SetCursor(CursorName
);
60 m_bInitialized
= FALSE
;
61 m_hOldCursor
= nullptr;
69 * Sets a new cursor. If you previously set a new cursor then
70 * before setting a second cursor the old one is restored and
71 * then the new one is set.
73 HCURSOR
SetCursor(LPCTSTR CursorName
)
75 //first restore possible old cursor before setting new one
77 //try to load system cursor
78 HCURSOR NewCursor
= ::LoadCursor(NULL
, CursorName
);
80 //try to load application cursor
81 NewCursor
= ::LoadCursor(AfxGetResourceHandle(), CursorName
);
84 m_hOldCursor
= ::SetCursor(NewCursor
);
85 m_bInitialized
= TRUE
;
89 m_bInitialized
= FALSE
;
90 TRACE("cursor not found!\n");
95 * Restores the cursor.
102 ::SetCursor(m_hOldCursor
);
105 m_bInitialized
= FALSE
;
109 HCURSOR m_hOldCursor
;