2 * Copyright 2012 Stefan Leichter
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(atl100
);
27 /***********************************************************************
28 * AtlAdvise [atl100.@]
30 HRESULT WINAPI
AtlAdvise(IUnknown
*pUnkCP
, IUnknown
*pUnk
, const IID
*iid
, LPDWORD pdw
)
32 FIXME("%p %p %p %p\n", pUnkCP
, pUnk
, iid
, pdw
);
36 /***********************************************************************
37 * AtlUnadvise [atl100.@]
39 HRESULT WINAPI
AtlUnadvise(IUnknown
*pUnkCP
, const IID
*iid
, DWORD dw
)
41 FIXME("%p %p %d\n", pUnkCP
, iid
, dw
);
45 /***********************************************************************
46 * AtlFreeMarshalStream [atl100.@]
48 HRESULT WINAPI
AtlFreeMarshalStream(IStream
*stm
)
54 /***********************************************************************
55 * AtlMarshalPtrInProc [atl100.@]
57 HRESULT WINAPI
AtlMarshalPtrInProc(IUnknown
*pUnk
, const IID
*iid
, IStream
**pstm
)
59 FIXME("%p %p %p\n", pUnk
, iid
, pstm
);
63 /***********************************************************************
64 * AtlUnmarshalPtr [atl100.@]
66 HRESULT WINAPI
AtlUnmarshalPtr(IStream
*stm
, const IID
*iid
, IUnknown
**ppUnk
)
68 FIXME("%p %p %p\n", stm
, iid
, ppUnk
);
72 /***********************************************************************
73 * AtlCreateTargetDC [atl100.@]
75 HDC WINAPI
AtlCreateTargetDC( HDC hdc
, DVTARGETDEVICE
*dv
)
77 static const WCHAR displayW
[] = {'d','i','s','p','l','a','y',0};
78 const WCHAR
*driver
= NULL
, *device
= NULL
, *port
= NULL
;
79 DEVMODEW
*devmode
= NULL
;
81 TRACE( "(%p, %p)\n", hdc
, dv
);
85 if (dv
->tdDriverNameOffset
) driver
= (WCHAR
*)((char *)dv
+ dv
->tdDriverNameOffset
);
86 if (dv
->tdDeviceNameOffset
) device
= (WCHAR
*)((char *)dv
+ dv
->tdDeviceNameOffset
);
87 if (dv
->tdPortNameOffset
) port
= (WCHAR
*)((char *)dv
+ dv
->tdPortNameOffset
);
88 if (dv
->tdExtDevmodeOffset
) devmode
= (DEVMODEW
*)((char *)dv
+ dv
->tdExtDevmodeOffset
);
95 return CreateDCW( driver
, device
, port
, devmode
);
98 /***********************************************************************
99 * AtlHiMetricToPixel [atl100.@]
101 void WINAPI
AtlHiMetricToPixel(const SIZEL
* lpHiMetric
, SIZEL
* lpPix
)
103 HDC dc
= GetDC(NULL
);
104 lpPix
->cx
= lpHiMetric
->cx
* GetDeviceCaps( dc
, LOGPIXELSX
) / 100;
105 lpPix
->cy
= lpHiMetric
->cy
* GetDeviceCaps( dc
, LOGPIXELSY
) / 100;
106 ReleaseDC( NULL
, dc
);
109 /***********************************************************************
110 * AtlPixelToHiMetric [atl100.@]
112 void WINAPI
AtlPixelToHiMetric(const SIZEL
* lpPix
, SIZEL
* lpHiMetric
)
114 HDC dc
= GetDC(NULL
);
115 lpHiMetric
->cx
= 100 * lpPix
->cx
/ GetDeviceCaps( dc
, LOGPIXELSX
);
116 lpHiMetric
->cy
= 100 * lpPix
->cy
/ GetDeviceCaps( dc
, LOGPIXELSY
);
117 ReleaseDC( NULL
, dc
);
120 /***********************************************************************
121 * AtlComPtrAssign [atl100.@]
123 IUnknown
* WINAPI
AtlComPtrAssign(IUnknown
** pp
, IUnknown
*p
)
125 TRACE("(%p %p)\n", pp
, p
);
127 if (p
) IUnknown_AddRef(p
);
128 if (*pp
) IUnknown_Release(*pp
);
133 /***********************************************************************
134 * AtlComQIPtrAssign [atl100.@]
136 IUnknown
* WINAPI
AtlComQIPtrAssign(IUnknown
** pp
, IUnknown
*p
, REFIID riid
)
138 IUnknown
*new_p
= NULL
;
140 TRACE("(%p %p %s)\n", pp
, p
, debugstr_guid(riid
));
142 if (p
) IUnknown_QueryInterface(p
, riid
, (void **)&new_p
);
143 if (*pp
) IUnknown_Release(*pp
);
148 /***********************************************************************
149 * AtlInternalQueryInterface [atl100.@]
151 HRESULT WINAPI
AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY
* pEntries
, REFIID iid
, void** ppvObject
)
154 HRESULT rc
= E_NOINTERFACE
;
155 TRACE("(%p, %p, %s, %p)\n",this, pEntries
, debugstr_guid(iid
), ppvObject
);
157 if (IsEqualGUID(iid
,&IID_IUnknown
))
159 TRACE("Returning IUnknown\n");
160 *ppvObject
= ((LPSTR
)this+pEntries
[0].dw
);
161 IUnknown_AddRef((IUnknown
*)*ppvObject
);
165 while (pEntries
[i
].pFunc
!= 0)
167 TRACE("Trying entry %i (%s %i %p)\n",i
,debugstr_guid(pEntries
[i
].piid
),
168 pEntries
[i
].dw
, pEntries
[i
].pFunc
);
170 if (!pEntries
[i
].piid
|| IsEqualGUID(iid
,pEntries
[i
].piid
))
173 if (pEntries
[i
].pFunc
== (_ATL_CREATORARGFUNC
*)1)
176 *ppvObject
= ((LPSTR
)this+pEntries
[i
].dw
);
177 IUnknown_AddRef((IUnknown
*)*ppvObject
);
183 rc
= pEntries
[i
].pFunc(this, iid
, ppvObject
, pEntries
[i
].dw
);
184 if(rc
==S_OK
|| pEntries
[i
].piid
)
190 TRACE("Done returning (0x%x)\n",rc
);
194 /* FIXME: should be in a header file */
195 typedef struct ATL_PROPMAP_ENTRY
199 const CLSID
* pclsidPropPage
;
200 const IID
* piidDispatch
;
206 /***********************************************************************
207 * AtlIPersistStreamInit_Load [atl100.@]
209 HRESULT WINAPI
AtlIPersistStreamInit_Load( LPSTREAM pStm
, ATL_PROPMAP_ENTRY
*pMap
,
210 void *pThis
, IUnknown
*pUnk
)
212 FIXME("(%p, %p, %p, %p)\n", pStm
, pMap
, pThis
, pUnk
);
217 /***********************************************************************
218 * AtlIPersistStreamInit_Save [atl100.@]
220 HRESULT WINAPI
AtlIPersistStreamInit_Save(LPSTREAM pStm
, BOOL fClearDirty
,
221 ATL_PROPMAP_ENTRY
*pMap
, void *pThis
,
224 FIXME("(%p, %d, %p, %p, %p)\n", pStm
, fClearDirty
, pMap
, pThis
, pUnk
);
229 /***********************************************************************
230 * AtlModuleAddTermFunc [atl100.@]
232 HRESULT WINAPI
AtlModuleAddTermFunc(_ATL_MODULE
*pM
, _ATL_TERMFUNC
*pFunc
, DWORD_PTR dw
)
234 _ATL_TERMFUNC_ELEM
*termfunc_elem
;
236 TRACE("(%p %p %ld)\n", pM
, pFunc
, dw
);
238 termfunc_elem
= HeapAlloc(GetProcessHeap(), 0, sizeof(_ATL_TERMFUNC_ELEM
));
239 termfunc_elem
->pFunc
= pFunc
;
240 termfunc_elem
->dw
= dw
;
241 termfunc_elem
->pNext
= pM
->m_pTermFuncs
;
243 pM
->m_pTermFuncs
= termfunc_elem
;
248 /***********************************************************************
249 * AtlCallTermFunc [atl100.@]
251 void WINAPI
AtlCallTermFunc(_ATL_MODULE
*pM
)
253 _ATL_TERMFUNC_ELEM
*iter
= pM
->m_pTermFuncs
, *tmp
;
258 iter
->pFunc(iter
->dw
);
261 HeapFree(GetProcessHeap(), 0, tmp
);
264 pM
->m_pTermFuncs
= NULL
;
267 /***********************************************************************
268 * AtlLoadTypeLib [atl100.@]
270 HRESULT WINAPI
AtlLoadTypeLib(HINSTANCE inst
, LPCOLESTR lpszIndex
,
271 BSTR
*pbstrPath
, ITypeLib
**ppTypeLib
)
273 OLECHAR path
[MAX_PATH
+8]; /* leave some space for index */
276 TRACE("(%p %s %p %p)\n", inst
, debugstr_w(lpszIndex
), pbstrPath
, ppTypeLib
);
278 GetModuleFileNameW(inst
, path
, MAX_PATH
);
280 lstrcatW(path
, lpszIndex
);
282 hres
= LoadTypeLib(path
, ppTypeLib
);
286 *pbstrPath
= SysAllocString(path
);
290 /***********************************************************************
291 * AtlWinModuleAddCreateWndData [atl100.43]
293 void WINAPI
AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE
*pM
, _AtlCreateWndData
*pData
, void *pvObject
)
295 TRACE("(%p, %p, %p)\n", pM
, pData
, pvObject
);
297 pData
->m_pThis
= pvObject
;
298 pData
->m_dwThreadID
= GetCurrentThreadId();
300 EnterCriticalSection(&pM
->m_csWindowCreate
);
301 pData
->m_pNext
= pM
->m_pCreateWndList
;
302 pM
->m_pCreateWndList
= pData
;
303 LeaveCriticalSection(&pM
->m_csWindowCreate
);
306 /***********************************************************************
307 * AtlGetVersion [atl100.@]
309 DWORD WINAPI
AtlGetVersion(void *pReserved
)