OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
metafldc.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 class TMetaFileDC, a Metafile DC encapsulation
7
//----------------------------------------------------------------------------
8
#include <
owl/pch.h
>
9
#include <
owl/dc.h
>
10
11
namespace
owl
{
12
13
OWL_DIAGINFO
;
14
15
//
16
/// Creates a device context for a Windows-format metafile. If the provided filename is NULL,
17
/// the Windows-format metafile is memory based and its contents are lost when it is destroyed.
18
/// \note This constructor is provided only for compatibility with Windows-format metafiles.
19
/// Enhanced-format metafiles provide superior functionality and are recommended for new applications.
20
/// To create an enhanced metafile, use one of the constructors that accept a TDC& as the first parameter.
21
//
22
TMetaFileDC::TMetaFileDC
(LPCTSTR filename)
23
:
24
TDC
(),
25
Enhanced(false)
26
{
27
Handle
= ::CreateMetaFile(filename);
28
CheckValid
();
29
}
30
31
//
32
/// Creates a device context for a Windows-format metafile. If the provided filename is empty,
33
/// the Windows-format metafile is memory based and its contents are lost when it is destroyed.
34
/// \note This constructor is provided only for compatibility with Windows-format metafiles.
35
/// Enhanced-format metafiles provide superior functionality and are recommended for new applications.
36
/// To create an enhanced metafile, use one of the constructors that accept a TDC& as the first parameter.
37
//
38
TMetaFileDC::TMetaFileDC
(
const
tstring
& filename)
39
:
40
TDC
(),
41
Enhanced(false)
42
{
43
Handle
= ::CreateMetaFile(filename.empty() ?
nullptr
: filename.c_str());
44
CheckValid
();
45
}
46
47
//
48
/// Destroys the metafile device context. If the metafile is memory-based, its contents will be lost.
49
//
50
TMetaFileDC::~TMetaFileDC
()
51
{
52
if
(
Handle
)
53
{
54
if
(
ShouldDelete
)
55
{
56
// Do not restore objects, Metafiles cleanup after themselves
57
//
58
if
(
IsEnhanced
())
59
::DeleteEnhMetaFile(
CloseEnh
());
60
else
61
::DeleteMetaFile(
Close
());
62
}
63
Handle
=
nullptr
;
64
}
65
}
66
67
//
68
/// Creates a device context for an enhanced-format metafile.
69
/// \note The given description string pointer, if not null, should point to two consecutive
70
/// null-terminated strings.
71
//
72
TMetaFileDC::TMetaFileDC
(
const
TDC
& dc, LPCTSTR filename,
TRect
* rect,
73
LPCTSTR description)
74
:
75
TDC
(),
76
Enhanced(true)
77
{
78
Handle
= ::CreateEnhMetaFile(dc, filename, rect, description);
79
CheckValid
();
80
}
81
82
//
83
/// String-aware overload
84
//
85
TMetaFileDC::TMetaFileDC
(
const
TDC
& dc,
const
tstring
& filename,
const
TRect
& r,
const
tstring
& appName,
const
tstring
& picName)
86
:
TDC
(),
87
Enhanced(true)
88
{
89
tstring
description = appName +
_T
(
'\0'
) + picName +
_T
(
'\0'
);
90
Handle
= ::CreateEnhMetaFile(
91
dc,
92
filename.empty() ?
nullptr
: filename.c_str(),
93
&r,
94
description.c_str());
95
CheckValid
();
96
}
97
98
}
// OWL namespace
99
/* ========================================================================== */
100
owl::TDC::TDC
TDC(HDC handle)
use an existing DC, doesn't auto delete it
Definition
dc.cpp:35
owl::TDC::CheckValid
void CheckValid(uint resId=IDS_GDIFAILURE)
Definition
gdibase.cpp:49
owl::TDC::ShouldDelete
bool ShouldDelete
< The handle of this DC. Uses the base class's handle (TGdiBase::Handle.)
Definition
gdibase.h:82
owl::TDC::Handle
HANDLE Handle
< make this function available to derivatives
Definition
gdibase.h:81
owl::TMetaFileDC::~TMetaFileDC
~TMetaFileDC()
Destroys the metafile device context. If the metafile is memory-based, its contents will be lost.
Definition
metafldc.cpp:50
owl::TMetaFileDC::Close
HMETAFILE Close()
Closes the metafile device context and returns a handle that identifies a Windows-format metafile.
Definition
dc.h:3474
owl::TMetaFileDC::TMetaFileDC
TMetaFileDC(LPCTSTR filename=nullptr)
Creates a device context for a Windows-format metafile.
Definition
metafldc.cpp:22
owl::TMetaFileDC::CloseEnh
HENHMETAFILE CloseEnh()
Closes the enhanced-metafile device context and returns a handle that identifies an enhanced-format m...
Definition
dc.h:3497
owl::TMetaFileDC::IsEnhanced
bool IsEnhanced() const
Returns true if the device context contains an enhanced metafile.
Definition
dc.h:3489
owl::TRect
TRect is a mathematical class derived from tagRect.
Definition
geometry.h:308
_T
#define _T(x)
Definition
cygwin.h:51
dc.h
Definition of GDI DC encapsulation classes: TDC, TWindowDC, TScreenDC, TDesktopDC,...
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
source
owlcore
metafldc.cpp
Generated by
1.18.0