OWLNext    7.0
Borland's Object Windows Library for the modern age
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
11namespace owl {
12
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//
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//
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//
51{
52 if (Handle)
53 {
54 if (ShouldDelete)
55 {
56 // Do not restore objects, Metafiles cleanup after themselves
57 //
58 if (IsEnhanced())
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//
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//
86 : TDC(),
87 Enhanced(true)
88{
89 tstring description = appName + _T('\0') + picName + _T('\0');
91 dc,
92 filename.empty() ? nullptr : filename.c_str(),
93 &r,
94 description.c_str());
95 CheckValid();
96}
97
98} // OWL namespace
99/* ========================================================================== */
100
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
void CheckValid(uint resId=IDS_GDIFAILURE)
Definition gdibase.cpp:49
bool ShouldDelete
< The handle of this DC. Uses the base class's handle (TGdiBase::Handle.)
Definition gdibase.h:82
HANDLE Handle
< make this function available to derivatives
Definition gdibase.h:81
~TMetaFileDC()
Destroys the metafile device context. If the metafile is memory-based, its contents will be lost.
Definition metafldc.cpp:50
HMETAFILE Close()
Closes the metafile device context and returns a handle that identifies a Windows-format metafile.
Definition dc.h:3474
TMetaFileDC(LPCTSTR filename=nullptr)
Creates a device context for a Windows-format metafile.
Definition metafldc.cpp:22
HENHMETAFILE CloseEnh()
Closes the enhanced-metafile device context and returns a handle that identifies an enhanced-format m...
Definition dc.h:3497
bool IsEnhanced() const
Returns true if the device context contains an enhanced metafile.
Definition dc.h:3489
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
#define _T(x)
Definition cygwin.h:51
Definition of GDI DC encapsulation classes: TDC, TWindowDC, TScreenDC, TDesktopDC,...
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
OWL_DIAGINFO
Definition animctrl.cpp:14
std::string tstring
Definition defs.h:79