Sample Code

Windows Driver Samples/ OEM Printer Customization Plug-in Samples/ C++/ PSUIRep/ Features.h/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
//  Copyright  2001 - 2003  Microsoft Corporation.  All Rights Reserved.
//
//  FILE:   Features.h
//
 
#pragma once
 
////////////////////////////////////////////////////////
//      Defines and Macros
////////////////////////////////////////////////////////
 
 
 
////////////////////////////////////////////////////////
//      Type Definitions
////////////////////////////////////////////////////////
 
// Struct used to map keyword to information
// such as display name and stickiness.
typedef struct _tagKeywordMap
{
    PCSTR   pszKeyword;
    PCWSTR  pwszModule;
    UINT    uDisplayNameID;
    DWORD   dwMode;
    DWORD   dwFlags;
 
} KEYWORDMAP, *PKEYWORDMAP;
 
 
// Struct container for info about
// feature that is in conflict.
typedef struct  _tagConflict
{
    PCSTR   pszFeatureKeyword;
    PCWSTR  pszFeature;
    PSTR    pszOptionKeyword;
    PWSTR   pszOption;
    PSTR    pmszReasons;
    DWORD   dwReasonsSize;
 
} CONFLICT, *PCONFLICT;
 
 
 
////////////////////////////////////////////////////////
//      Class Definitions
////////////////////////////////////////////////////////
 
// Class wrapper and container for Core Driver Feature Options.
class COptions
{
    private:
 
        // Option Infomation
        class OPTION_INFO
        {
            public:
                PKEYWORDMAP pMapping;
                PWSTR       pszDisplayName;
 
            public:
                OPTION_INFO()
                {
                    pMapping        = NULL;
                    pszDisplayName  = NULL;
                }
 
                virtual ~OPTION_INFO(){}
        };
        typedef class OPTION_INFO   *POPTION_INFO;
 
        // Data Members
        WORD            m_wOptions;     // Count of the number of options contained for an instance of the class.
        BYTE            m_cType;        // CPSUI Option Type (i.e. what to set pOptItem->pOptType->Type to).
        PSTR            m_pmszRaw;      // The RAW multi NULL terminated string buffer used for IPrintCoreUI2::EnumOptions().
        PCSTR           m_pszFeature;   // Pointer to the feature for which the enumerate options belong.
        PCSTR          *m_ppszOptions;  // String list pointer that points to begining of each of the strings in multi-SZ pointed to by m_pmszRaw.
        POINT           m_ptRange;      // Option range for features, such as %JobTimeout, that have a range of possible vaules not a small selection list.
        DWORD           m_dwSize;       // Size of m_pmszRaw buffer.
        PWSTR           m_pszUnits;     // String that contains the unit specifier for options, such as %JobTimeout, which need Units (i.e. seconds).
        HANDLE          m_hHeap;        // Heap to do allocations from.
        POPTION_INFO    m_pInfo;        // Array of Info about each option for a feature.
 
        union {                         // Current selected option for a feature.
            LONG    m_Sel;              // This is what pOptItem->m_pSel or pOptItem->m_Sel
            LPTSTR  m_pSel;             // will be set to.
        };
 
    public:
        COptions();
        virtual ~COptions();
 
        // Populate Options list for specified keyword.
        HRESULT COptions::Acquire(_In_ HANDLE hHeap,
                                  CUIHelper &Helper,
                                  _In_ POEMUIOBJ poemuiobj,
                                  _In_ PCSTR pszFeature);
 
        // Returns number of feature options contained in class instance.
        inline WORD GetCount() const {return m_wOptions;}
 
        // Returns selection.
        inline LPTSTR GetSelection() const {return m_pSel;}
 
        // Return nth options keyword.
        PCSTR GetKeyword(WORD wIndex) const;
 
        // Return nth option Display Name.
        PCWSTR GetName(WORD wIndex) const;
 
        // Find option with matching keyword string.
        WORD FindOption(_In_opt_ PCSTR pszOption, WORD wDefault) const;
 
        // Initializes options portion of OPTITEM.
        HRESULT InitOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem);
 
        // Refresh option selection.
        HRESULT RefreshSelection(CUIHelper &Helper, POEMUIOBJ poemuiobj);
 
    private:
        void Init();
        void Clear();
        void FreeOptionInfo();
        HRESULT GetOptionsForSpecialFeatures(CUIHelper &Helper, POEMUIOBJ poemuiobj);
        HRESULT GetOptionsForOutputPSLevel(CUIHelper &Helper, POEMUIOBJ poemuiobj);
        HRESULT GetOptionSelectionString(CUIHelper &Helper, POEMUIOBJ poemuiobj, _Outptr_result_maybenull_ PSTR *ppszSel);
        HRESULT GetOptionSelectionLong(CUIHelper &Helper, POEMUIOBJ poemuiobj);
        HRESULT GetOptionSelectionShort(CUIHelper &Helper, POEMUIOBJ poemuiobj);
        HRESULT GetOptionSelectionIndex(CUIHelper &Helper, POEMUIOBJ poemuiobj);
};
 
 
// Class wrapper and container for Cor Driver Features.
class CFeatures
{
    private:
 
        // Feature Infomation
        class FEATURE_INFO
        {
            public:
                PKEYWORDMAP pMapping;
                PWSTR       pszDisplayName;
                COptions    Options;
                DWORD       dwMode;
 
            public:
                FEATURE_INFO()
                {
                    pMapping        = NULL;
                    pszDisplayName  = NULL;
                    dwMode          = 0;
                }
 
                virtual ~FEATURE_INFO() {}
        };
        typedef class FEATURE_INFO  *PFEATURE_INFO;
 
        WORD            m_wFeatures;        // Count of the number of features.
        WORD            m_wDocFeatures;     // Count of the number of Document sticky features.
        WORD            m_wPrintFeatures;   // Count of the number of Printer sticky features.
        PSTR            m_pmszRaw;          // Buffer for multi-SZ for call to IPrintCoreUI2::EnumFeatures.
        PCSTR          *m_ppszKeywords;     // String list that points to each of the strings in m_pmszRaw.
        DWORD           m_dwSize;           // Size of m_pmszRaw.
        HANDLE          m_hHeap;            // Heap to do allocations from.
        PFEATURE_INFO   m_pInfo;            // Array of feature information about each of the enumerate features.
 
    public:
        CFeatures();
        virtual ~CFeatures();
 
        // Populates the Feature list
        HRESULT Acquire(_In_ HANDLE hHeap, CUIHelper &Helper, _In_ POEMUIOBJ poemuiobj);
 
        // Returns number of features contained in class instance.
        WORD GetCount(DWORD dwMode = 0) const;
 
        // Returns feature keyword.
        PCSTR GetKeyword(WORD wIndex, DWORD dwMode = 0) const;
 
        // Return feature Display Name.
        PCWSTR GetName(WORD wIndex, DWORD dwMode = 0) const;
 
        // Returns pointer to option class for nth feature.
        COptions* GetOptions(WORD wIndex, DWORD dwMode = 0) const;
 
        // Initializes OPTITEM for the feature.
        HRESULT InitOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem, WORD wIndex, DWORD dwMode);
 
    private:
        void Init();
        void Clear();
        void FreeFeatureInfo();
        WORD GetModelessIndex(WORD wIndex, DWORD dwMode) const;
};
 
 
 
////////////////////////////////////////////////////////
//      Prototypes
////////////////////////////////////////////////////////
 
HRESULT DetermineFeatureDisplayName(_In_ HANDLE hHeap, CUIHelper &Helper, POEMUIOBJ poemuiobj,
                                    _In_ PCSTR pszKeyword, const PKEYWORDMAP pMapping,
                                    _Outptr_result_maybenull_ PWSTR *ppszDisplayName);
HRESULT DetermineOptionDisplayName(_In_ HANDLE hHeap, CUIHelper &Helper, POEMUIOBJ poemuiobj,
                                   _In_ PCSTR pszFeature, _In_ PCSTR pszOption,
                                   const PKEYWORDMAP pMapping, _Outptr_result_maybenull_ PWSTR *ppszDisplayName);
HRESULT DetermineStickiness(CUIHelper &Helper, POEMUIOBJ poemuiobj, PCSTR pszKeyword,
                            const PKEYWORDMAP pMapping,PDWORD pdwMode);
 
PKEYWORDMAP FindKeywordMapping(PKEYWORDMAP pKeywordMap, WORD wMapSize, PCSTR pszKeyword);
HRESULT GetDisplayNameFromMapping(_In_ HANDLE hHeap, PKEYWORDMAP pMapping, _Outptr_result_maybenull_ PWSTR *ppszDisplayName);
 
BOOL IsFeatureOptitem(POPTITEM pOptItem);
HRESULT SaveFeatureOptItems(_In_ HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj,
                            HWND hWnd, POPTITEM pOptItem, WORD wItems);
HRESULT GetWhyConstrained(_In_ HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj,
                          _In_ PCSTR pszFeature, _In_ PCSTR pszOption, _Inout_ PSTR *ppmszReason,
                          _Inout_ PDWORD pdwSize);
HRESULT GetChangedFeatureOptions(_In_ HANDLE hHeap, POPTITEM pOptItem, WORD wItems,
                                 _Outptr_result_maybenull_ PSTR *ppmszPairs, _Out_ PWORD pdwPairs, _Out_ PDWORD pdwSize);
PSTR GetOptionKeywordFromOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem);
PWSTR GetOptionDisplayNameFromOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem);
HRESULT RefreshOptItemSelection(CUIHelper *pHelper, POEMUIOBJ poemuiobj, POPTITEM pOptItems,
                                WORD wItems);
HRESULT GetFirstConflictingFeature(_In_ HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj,
                                   POPTITEM pOptItem, WORD wItems, PCONFLICT pConflict);

Our Services

  • What our customers say about us?

© 2011-2025 All Rights Reserved. Joya Systems. 4425 South Mopac Building II Suite 101 Austin, TX 78735 Tel: 800-DEV-KERNEL

Privacy Policy. Terms of use. Valid XHTML & CSS