summaryrefslogtreecommitdiff
path: root/iup/srcole/tOleControlSite.cpp
blob: 71f3519f233805d374fc226be84ab6b33ff81a3c (plain)
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
// tOleControlSite.cpp: implementation of the tOleControlSite class.
//
//////////////////////////////////////////////////////////////////////

#include "tOleControlSite.h"
#include "tOleHandler.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

/*
 * tOleControlSite::tOleControlSite
 * tOleControlSite::~tOleControlSite
 *
 * Parameters (Constructor):
 *  pTen            PCTenant of the object we're in.
 *  pUnkOuter       LPUNKNOWN to which we delegate.
 */

tOleControlSite::tOleControlSite(tOleHandler *pTen
    , LPUNKNOWN pUnkOuter)
    {
    m_cRef=0;
    m_pTen=pTen;
    m_pUnkOuter=pUnkOuter;
    return;
    }

tOleControlSite::~tOleControlSite(void)
    {
    return;
    }




/*
 * tOleControlSite::QueryInterface
 * tOleControlSite::AddRef
 * tOleControlSite::Release
 *
 * Purpose:
 *  Delegating IUnknown members for tOleControlSite.
 */

STDMETHODIMP tOleControlSite::QueryInterface(REFIID riid
    , LPVOID *ppv)
    {
    return m_pUnkOuter->QueryInterface(riid, ppv);
    }


STDMETHODIMP_(ULONG) tOleControlSite::AddRef(void)
    {
    ++m_cRef;
    return m_pUnkOuter->AddRef();
    }

STDMETHODIMP_(ULONG) tOleControlSite::Release(void)
    {
    --m_cRef;
    return m_pUnkOuter->Release();
    }





/*
 * tOleControlSite::OnControlInfoChanged
 *
 * Purpose:
 *  Informs the site that the CONTROLINFO for the control has
 *  changed and we thus need to reload the data.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  HRESULT         NOERROR
 */

STDMETHODIMP tOleControlSite::OnControlInfoChanged(void)
    {
    //We also update our "have info" flag here.
    if(m_pTen->m_pIOleControl != NULL)
    {
      m_pTen->m_fHaveControlInfo=SUCCEEDED(m_pTen->m_pIOleControl
        ->GetControlInfo(&m_pTen->m_ctrlInfo));
    }

    return NOERROR;
    }





/*
 * tOleControlSite::LockInPlaceActive
 *
 * Purpose:
 *  Forces the container to keep this control in-place active
 *  (but not UI active) regardless of other considerations, or
 *  removes this lock.
 *
 * Parameters:
 *  fLock           BOOL indicating to lock (TRUE) or unlock (FALSE)
 *                  in-place activation.
 *
 * Return Value:
 *  HRESULT         NOERROR
 */

STDMETHODIMP tOleControlSite::LockInPlaceActive(BOOL fLock)
    {
    if (fLock)
        m_pTen->m_cLockInPlace++;
    else
        {
        if (0==--m_pTen->m_cLockInPlace)
            {
            //If there's a pending deactivate, do it now.
            if (m_pTen->m_fPendingDeactivate)
                m_pTen->DeactivateInPlaceObject(TRUE);
            }
        }

    return NOERROR;
    }





/*
 * tOleControlSite::GetExtendedControl
 *
 * Purpose:
 *  Returns a pointer to the container's extended control that wraps
 *  the actual control in this site, if one exists.
 *
 * Parameters:
 *  ppDispatch      LPDISPATCH * in which to return the pointer
 *                  to the extended control's IDispatch interface.
 *
 * Return Value:
 *  HRESULT         NOERROR or a general error value.
 */

STDMETHODIMP tOleControlSite::GetExtendedControl(LPDISPATCH
    * ppDispatch)
    {
    *ppDispatch=NULL;
    return ResultFromScode(E_NOTIMPL);
    }






/*
 * tOleControlSite::TransformCoords
 *
 * Purpose:
 *  Converts coordinates in HIMETRIC units into those used by the
 *  container.
 *
 * Parameters:
 *  pptlHiMet       POINTL * containing either the coordinates to
 *                  transform to container or where to store the
 *                  transformed container coordinates.
 *  pptlCont        POINTF * containing the container coordinates.
 *  dwFlags         DWORD containing instructional flags.
 *
 * Return Value:
 *  HRESULT         NOERROR or a general error value.
 */

STDMETHODIMP tOleControlSite::TransformCoords(POINTL *pptlHiMet
    , POINTF *pptlCont, DWORD dwFlags)
    {
    if (NULL==pptlHiMet || NULL==pptlCont)
        return ResultFromScode(E_POINTER);

    /*
     * Convert coordinates.  We use MM_LOMETRIC which means that
     * to convert from HIMETRIC we divide by 10 and negate the y
     * coordinate.  Conversion to HIMETRIC means negate the y
     * and multiply by 10.  Note that size and position are
     * considered the same thing, that is, we don't differentiate
     * the two.
     */

    if (XFORMCOORDS_HIMETRICTOCONTAINER & dwFlags)
        {
        pptlCont->x=(float)(pptlHiMet->x/10);
        pptlCont->y=(float)-(pptlHiMet->y/10);
        }
    else
        {
        pptlHiMet->x=(long)(pptlCont->x*10);
        pptlHiMet->y=(long)-(pptlCont->y*10);
        }

    return NOERROR;
    }





/*
 * tOleControlSite::TranslateAccelerator
 *
 * Purpose:
 *  Instructs the container to translate a keyboard accelerator
 *  message that the control has picked up instead.
 *
 * Parameters:
 *  pMsg            LPMSG to the message to translate.
 *  grfModifiers    DWORD flags with additional instructions.
 *
 * Return Value:
 *  HRESULT         NOERROR or a general error value.
 */

STDMETHODIMP tOleControlSite::TranslateAccelerator(LPMSG pMsg
    , DWORD grfModifiers)
    {
    /*
     * The control has picked up a keystroke through its own
     * TranslateAccelerator and is now giving us the change to
     * play with it.  Currently there are no flags for
     * grfModifiers, so we ignore them.  Especially since
     * we have nothing to do here ourselves anyway.
     */
    return ResultFromScode(S_FALSE);
    }




/*
 * tOleControlSite::OnFocus
 *
 * Purpose:
 *  Informs the container that focus has either been lost or
 *  gained in the control.
 *
 * Parameters:
 *  fGotFocus       BOOL indicating that the control gained (TRUE)
 *                  or lost (FALSE) focus.
 *
 * Return Value:
 *  HRESULT         NOERROR or a general error value.
 */

STDMETHODIMP tOleControlSite::OnFocus(BOOL fGotFocus)
    {
    /*
     * Patron doesn't do this, but to handle the default
     * and cancel buttons properly, we normally process RETURN
     * and ESC accelerators to press the right button.
     * This behavior must be disabled when the control with
     * the focus has either CTRLINFO_EATS_RETURN or
     * CTRLINFO_EATS_ESCAPE set.  We tell the frame as
     * we need to when a new control gets the focus.  We
     * do nothing when a control loses the focus.
     */
    return NOERROR;
    }



/*
 * tOleControlSite::ShowPropertyFrame
 *
 * Purpose:
 *  Instructs the container to show the property frame if
 *  this is an extended object and requires its own property
 *  pages.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  HRESULT         NOERROR or a general error value.
 */

STDMETHODIMP tOleControlSite::ShowPropertyFrame(void)
    {
    /*
     * Returning an error here means that the container has
     * no property pages itself for the control, so the
     * control should display its own.
     */
    return ResultFromScode(E_NOTIMPL);
    }