OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
gdibase.cpp
Go to the documentation of this file.
1
//----------------------------------------------------------------------------
2
// ObjectWindows
3
// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4
//
5
/// \file
6
/// Implementation of TGdiBase, base abstract class for all GDI objects that
7
/// have Handles.
8
//----------------------------------------------------------------------------
9
#include <
owl/pch.h
>
10
#include <
owl/gdibase.h
>
11
#include <stdio.h>
12
13
namespace
owl
{
14
15
OWL_DIAGINFO
;
16
17
//
18
/// This default constructor sets Handle to 0 and ShouldDelete to true. This
19
/// constructor is intended for use by derived classes that must set the Handle
20
/// member later.
21
//
22
TGdiBase::TGdiBase
()
23
:
24
Handle
(nullptr),
25
ShouldDelete
(true)
26
{
27
// Handle must be set and validated by the derived class.
28
}
29
30
//
31
/// Initializes members to given values, and validates the handle.
32
/// This constructor is intended for use by derived classes only.
33
//
34
TGdiBase::TGdiBase
(HANDLE handle,
TAutoDelete
autoDelete)
35
:
36
Handle
(handle),
37
ShouldDelete
(autoDelete==
AutoDelete
)
38
{
39
CheckValid
();
40
}
41
42
#if !defined(BI_COMP_GNUC)
43
#pragma warn -par
// resId is never used in small model
44
#endif
45
//
46
//
47
//
48
void
49
TGdiBase::CheckValid
(
uint
resId)
50
{
51
_CheckValid
(
Handle
, resId);
52
}
53
54
//
55
//
56
//
57
void
58
TGdiBase::_CheckValid
(HANDLE handle,
uint
resId)
59
{
60
if
(!handle)
61
TXGdi::Raise
(resId);
62
}
63
#if !defined(BI_COMP_GNUC)
64
#pragma warn .par
65
#endif
66
67
//----------------------------------------------------------------------------
68
69
//
70
/// Converts the resource ID to a string and returns the string message.
71
/// \note For backward compatibility
72
//
73
tstring
74
TXGdi::Msg
(
uint
resId, HANDLE handle)
75
{
76
return
MakeMessage
(resId,
static_cast<
uint
>
(
reinterpret_cast<
UINT_PTR
>
(handle)));
77
}
78
79
//
80
/// Constructs a TXGdi object with a default IDS_GDIFAILURE message.
81
//
82
TXGdi::TXGdi
(
uint
resId, HANDLE handle)
83
:
84
TXOwl
(
Msg
(resId, handle), resId)
85
{
86
}
87
88
//
89
// Clone the exception object for safe-throwing across Windows.
90
//
91
TXGdi
*
92
TXGdi::Clone
()
93
{
94
return
new
TXGdi
(*
this
);
95
}
96
97
98
//
99
/// Throws the exception object. Throw must be implemented in any class derived from
100
/// TXOwl.
101
//
102
void
103
TXGdi::Throw
()
104
{
105
throw
*
this
;
106
}
107
108
//
109
/// Throws the exception.
110
//
111
void
112
TXGdi::Raise
(
uint
resId, HANDLE handle)
113
{
114
TXGdi
(resId, handle).Throw();
115
}
116
117
}
// OWL namespace
118
/* ========================================================================== */
119
owl::TGdiBase::TGdiBase
TGdiBase()
This default constructor sets Handle to 0 and ShouldDelete to true.
Definition
gdibase.cpp:22
owl::TGdiBase::CheckValid
void CheckValid(uint resId=IDS_GDIFAILURE)
Definition
gdibase.cpp:49
owl::TGdiBase::_CheckValid
static void _CheckValid(HANDLE handle, uint resId=IDS_GDIFAILURE)
Definition
gdibase.cpp:58
owl::TGdiBase::ShouldDelete
bool ShouldDelete
Should object delete GDI handle in dtor?
Definition
gdibase.h:82
owl::TGdiBase::Handle
HANDLE Handle
GDI handle of this object.
Definition
gdibase.h:81
owl::TXGdi
Describes an exception resulting from GDI failures such as creating too many TWindow device contexts ...
Definition
gdibase.h:52
owl::TXGdi::Raise
static void Raise(uint resId=IDS_GDIFAILURE, HANDLE handle=0)
Throws the exception.
Definition
gdibase.cpp:112
owl::TXGdi::TXGdi
TXGdi(uint resId=IDS_GDIFAILURE, HANDLE handle=0)
Constructs a TXGdi object with a default IDS_GDIFAILURE message.
Definition
gdibase.cpp:82
owl::TXGdi::Throw
void Throw()
Throws the exception object.
Definition
gdibase.cpp:103
owl::TXGdi::Msg
static tstring Msg(uint resId, HANDLE)
Converts the resource ID to a string and returns the string message.
Definition
gdibase.cpp:74
owl::TXGdi::Clone
TXGdi * Clone()
Definition
gdibase.cpp:92
gdibase.h
Definition of base most abstract GDI object class, and associated exception class.
owl::TAutoDelete
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition
gdibase.h:70
owl::AutoDelete
@ AutoDelete
Definition
gdibase.h:70
owl::TXOwl::MakeMessage
static tstring MakeMessage(uint resId, const tstring &infoStr, TModule *module=&GetGlobalModule())
Definition
except.cpp:233
owl::TXOwl::TXOwl
TXOwl(const tstring &msg, uint resId=0)
An OWL exception with a given message for displaying and an unsigned Id that can be used for identifi...
Definition
except.cpp:123
pch.h
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
owl::OWL_DIAGINFO
OWL_DIAGINFO
Definition
animctrl.cpp:14
owl::tstring
std::string tstring
Definition
defs.h:79
owl::uint
unsigned int uint
Definition
number.h:25
source
owlcore
gdibase.cpp
Generated by
1.18.0