comparison foosdk/sdk/foobar2000/shared/win32_misc.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3
4 class win32_font {
5 public:
6 win32_font(HFONT p_initval) : m_font(p_initval) {}
7 win32_font() : m_font(NULL) {}
8 ~win32_font() {release();}
9
10 void release() {
11 HFONT temp = detach();
12 if (temp != NULL) DeleteObject(temp);
13 }
14
15 void set(HFONT p_font) {release(); m_font = p_font;}
16 HFONT get() const {return m_font;}
17 HFONT detach() {return pfc::replace_t(m_font,(HFONT)NULL);}
18
19 void create(const t_font_description & p_desc) {
20 SetLastError(NO_ERROR);
21 HFONT temp = p_desc.create();
22 if (temp == NULL) throw exception_win32(GetLastError());
23 set(temp);
24 }
25
26 bool is_valid() const {return m_font != NULL;}
27
28 private:
29 win32_font(const win32_font&) = delete;
30 void operator=(const win32_font &) = delete;
31
32 HFONT m_font;
33 };