winex11: Don't reset OpenGL swap interval of window on SetParent().
[wine.git] / dlls / atl / atl_ax.c
blob0a16010dffe9ea9d40f406dacf72a77e1cfad471
1 /*
2 * Active Template Library ActiveX functions (atl.dll)
4 * Copyright 2006 Andrey Turkin
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winerror.h"
29 #include "winuser.h"
30 #include "wine/debug.h"
31 #include "objbase.h"
32 #include "objidl.h"
33 #include "ole2.h"
34 #include "exdisp.h"
35 #include "atlbase.h"
36 #include "atliface.h"
37 #include "atlwin.h"
39 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(atl);
43 typedef struct IOCS {
44 IOleClientSite IOleClientSite_iface;
45 IOleContainer IOleContainer_iface;
46 IOleInPlaceSiteWindowless IOleInPlaceSiteWindowless_iface;
47 IOleInPlaceFrame IOleInPlaceFrame_iface;
48 IOleControlSite IOleControlSite_iface;
50 LONG ref;
51 HWND hWnd;
52 IOleObject *control;
53 RECT size;
54 WNDPROC OrigWndProc;
55 BOOL fActive, fInPlace, fWindowless;
56 } IOCS;
58 /**********************************************************************
59 * AtlAxWin class window procedure
61 static LRESULT CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
63 if ( wMsg == WM_CREATE )
65 DWORD len = GetWindowTextLengthW( hWnd ) + 1;
66 WCHAR *ptr = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
67 if (!ptr)
68 return 1;
69 GetWindowTextW( hWnd, ptr, len );
70 AtlAxCreateControlEx( ptr, hWnd, NULL, NULL, NULL, NULL, NULL );
71 HeapFree( GetProcessHeap(), 0, ptr );
72 return 0;
74 return DefWindowProcW( hWnd, wMsg, wParam, lParam );
77 /***********************************************************************
78 * AtlAxWinInit [atl100.@]
79 * Initializes the control-hosting code: registering the AtlAxWin,
80 * AtlAxWin7 and AtlAxWinLic7 window classes and some messages.
82 * RETURNS
83 * TRUE or FALSE
86 BOOL WINAPI AtlAxWinInit(void)
88 WNDCLASSEXW wcex;
90 #if _ATL_VER <= _ATL_VER_30
91 #define ATL_NAME_SUFFIX 0
92 #elif _ATL_VER == _ATL_VER_80
93 #define ATL_NAME_SUFFIX '8','0',0
94 #elif _ATL_VER == _ATL_VER_90
95 #define ATL_NAME_SUFFIX '9','0',0
96 #elif _ATL_VER == _ATL_VER_100
97 #define ATL_NAME_SUFFIX '1','0','0',0
98 #elif _ATL_VER == _ATL_VER_110
99 #define ATL_NAME_SUFFIX '1','1','0',0
100 #else
101 #error Unsupported version
102 #endif
104 const WCHAR AtlAxWinW[] = {'A','t','l','A','x','W','i','n',ATL_NAME_SUFFIX};
106 FIXME("version %04x semi-stub\n", _ATL_VER);
108 if ( FAILED( OleInitialize(NULL) ) )
109 return FALSE;
111 wcex.cbSize = sizeof(wcex);
112 wcex.style = CS_GLOBALCLASS | (_ATL_VER > _ATL_VER_30 ? CS_DBLCLKS : 0);
113 wcex.cbClsExtra = 0;
114 wcex.cbWndExtra = 0;
115 wcex.hInstance = GetModuleHandleW( NULL );
116 wcex.hIcon = NULL;
117 wcex.hCursor = NULL;
118 wcex.hbrBackground = NULL;
119 wcex.lpszMenuName = NULL;
120 wcex.hIconSm = 0;
122 wcex.lpfnWndProc = AtlAxWin_wndproc;
123 wcex.lpszClassName = AtlAxWinW;
124 if ( !RegisterClassExW( &wcex ) )
125 return FALSE;
127 if(_ATL_VER > _ATL_VER_30) {
128 const WCHAR AtlAxWinLicW[] = {'A','t','l','A','x','W','i','n','L','i','c',ATL_NAME_SUFFIX};
130 wcex.lpszClassName = AtlAxWinLicW;
131 if ( !RegisterClassExW( &wcex ) )
132 return FALSE;
135 return TRUE;
138 /***********************************************************************
139 * Atl container component implementation
143 static ULONG IOCS_AddRef(IOCS *This)
145 ULONG ref = InterlockedIncrement(&This->ref);
147 TRACE( "(%p) : AddRef from %d\n", This, ref - 1 );
149 return ref;
152 static HRESULT IOCS_QueryInterface(IOCS *This, REFIID riid, void **ppv)
154 *ppv = NULL;
156 if ( IsEqualIID( &IID_IUnknown, riid )
157 || IsEqualIID( &IID_IOleClientSite, riid ) )
159 *ppv = &This->IOleClientSite_iface;
160 } else if ( IsEqualIID( &IID_IOleContainer, riid ) )
162 *ppv = &This->IOleContainer_iface;
163 } else if ( IsEqualIID( &IID_IOleInPlaceSite, riid ) || IsEqualIID( &IID_IOleInPlaceSiteEx, riid ) || IsEqualIID( &IID_IOleInPlaceSiteWindowless, riid ) )
165 *ppv = &This->IOleInPlaceSiteWindowless_iface;
166 } else if ( IsEqualIID( &IID_IOleInPlaceFrame, riid ) )
168 *ppv = &This->IOleInPlaceFrame_iface;
169 } else if ( IsEqualIID( &IID_IOleControlSite, riid ) )
171 *ppv = &This->IOleControlSite_iface;
174 if (*ppv)
176 IOCS_AddRef( This );
177 return S_OK;
180 WARN("unsupported interface %s\n", debugstr_guid( riid ) );
181 *ppv = NULL;
182 return E_NOINTERFACE;
185 static HRESULT IOCS_Detach( IOCS *This );
186 static ULONG IOCS_Release(IOCS *This)
188 ULONG ref = InterlockedDecrement(&This->ref);
190 TRACE( "(%p) : ReleaseRef to %d\n", This, ref );
192 if (!ref)
194 IOCS_Detach( This );
195 HeapFree( GetProcessHeap(), 0, This );
198 return ref;
201 /****** IOleClientSite *****/
202 static inline IOCS *impl_from_IOleClientSite(IOleClientSite *iface)
204 return CONTAINING_RECORD(iface, IOCS, IOleClientSite_iface);
207 static HRESULT WINAPI OleClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
209 IOCS *This = impl_from_IOleClientSite(iface);
210 return IOCS_QueryInterface(This, riid, ppv);
213 static ULONG WINAPI OleClientSite_AddRef(IOleClientSite *iface)
215 IOCS *This = impl_from_IOleClientSite(iface);
216 return IOCS_AddRef(This);
219 static ULONG WINAPI OleClientSite_Release(IOleClientSite *iface)
221 IOCS *This = impl_from_IOleClientSite(iface);
222 return IOCS_Release(This);
225 static HRESULT WINAPI OleClientSite_SaveObject(IOleClientSite *iface)
227 IOCS *This = impl_from_IOleClientSite(iface);
228 FIXME( "(%p) - stub\n", This );
229 return E_NOTIMPL;
232 static HRESULT WINAPI OleClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
234 IOCS *This = impl_from_IOleClientSite(iface);
236 FIXME( "(%p, 0x%x, 0x%x, %p)\n", This, dwAssign, dwWhichMoniker, ppmk );
237 return E_NOTIMPL;
240 static HRESULT WINAPI OleClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
242 IOCS *This = impl_from_IOleClientSite(iface);
243 TRACE( "(%p, %p)\n", This, ppContainer );
244 return OleClientSite_QueryInterface( iface, &IID_IOleContainer, (void**)ppContainer );
247 static HRESULT WINAPI OleClientSite_ShowObject(IOleClientSite *iface)
249 IOCS *This = impl_from_IOleClientSite(iface);
250 FIXME( "(%p) - stub\n", This );
251 return S_OK;
254 static HRESULT WINAPI OleClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
256 IOCS *This = impl_from_IOleClientSite(iface);
257 FIXME( "(%p, %s) - stub\n", This, fShow ? "TRUE" : "FALSE" );
258 return E_NOTIMPL;
261 static HRESULT WINAPI OleClientSite_RequestNewObjectLayout(IOleClientSite *iface)
263 IOCS *This = impl_from_IOleClientSite(iface);
264 FIXME( "(%p) - stub\n", This );
265 return E_NOTIMPL;
269 /****** IOleContainer *****/
270 static inline IOCS *impl_from_IOleContainer(IOleContainer *iface)
272 return CONTAINING_RECORD(iface, IOCS, IOleContainer_iface);
275 static HRESULT WINAPI OleContainer_QueryInterface( IOleContainer* iface, REFIID riid, void** ppv)
277 IOCS *This = impl_from_IOleContainer(iface);
278 return IOCS_QueryInterface( This, riid, ppv );
281 static ULONG WINAPI OleContainer_AddRef(IOleContainer* iface)
283 IOCS *This = impl_from_IOleContainer(iface);
284 return IOCS_AddRef(This);
287 static ULONG WINAPI OleContainer_Release(IOleContainer* iface)
289 IOCS *This = impl_from_IOleContainer(iface);
290 return IOCS_Release(This);
293 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer* iface, IBindCtx* pbc,
294 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
296 IOCS *This = impl_from_IOleContainer(iface);
297 FIXME( "(%p,%p,%s,%p,%p) - stub\n", This, pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut );
298 return E_NOTIMPL;
301 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer* iface, DWORD grfFlags, IEnumUnknown** ppenum)
303 IOCS *This = impl_from_IOleContainer(iface);
304 FIXME( "(%p, %u, %p) - stub\n", This, grfFlags, ppenum );
305 return E_NOTIMPL;
308 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer* iface, BOOL fLock)
310 IOCS *This = impl_from_IOleContainer(iface);
311 FIXME( "(%p, %s) - stub\n", This, fLock?"TRUE":"FALSE" );
312 return E_NOTIMPL;
316 /****** IOleInPlaceSiteWindowless *******/
317 static inline IOCS *impl_from_IOleInPlaceSiteWindowless(IOleInPlaceSiteWindowless *iface)
319 return CONTAINING_RECORD(iface, IOCS, IOleInPlaceSiteWindowless_iface);
322 static HRESULT WINAPI OleInPlaceSiteWindowless_QueryInterface(IOleInPlaceSiteWindowless *iface, REFIID riid, void **ppv)
324 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
325 return IOCS_QueryInterface(This, riid, ppv);
328 static ULONG WINAPI OleInPlaceSiteWindowless_AddRef(IOleInPlaceSiteWindowless *iface)
330 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
331 return IOCS_AddRef(This);
334 static ULONG WINAPI OleInPlaceSiteWindowless_Release(IOleInPlaceSiteWindowless *iface)
336 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
337 return IOCS_Release(This);
340 static HRESULT WINAPI OleInPlaceSiteWindowless_GetWindow(IOleInPlaceSiteWindowless* iface, HWND* phwnd)
342 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
344 TRACE("(%p,%p)\n", This, phwnd);
345 *phwnd = This->hWnd;
346 return S_OK;
349 static HRESULT WINAPI OleInPlaceSiteWindowless_ContextSensitiveHelp(IOleInPlaceSiteWindowless* iface, BOOL fEnterMode)
351 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
352 FIXME("(%p,%d) - stub\n", This, fEnterMode);
353 return E_NOTIMPL;
356 static HRESULT WINAPI OleInPlaceSiteWindowless_CanInPlaceActivate(IOleInPlaceSiteWindowless *iface)
358 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
359 TRACE("(%p)\n", This);
360 return S_OK;
363 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceActivate(IOleInPlaceSiteWindowless *iface)
365 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
367 TRACE("(%p)\n", This);
369 This->fInPlace = TRUE;
370 return S_OK;
373 static HRESULT WINAPI OleInPlaceSiteWindowless_OnUIActivate(IOleInPlaceSiteWindowless *iface)
375 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
377 TRACE("(%p)\n", This);
379 return S_OK;
381 static HRESULT WINAPI OleInPlaceSiteWindowless_GetWindowContext(IOleInPlaceSiteWindowless *iface,
382 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
383 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
385 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
387 TRACE("(%p,%p,%p,%p,%p,%p)\n", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo);
389 if ( lprcClipRect )
390 *lprcClipRect = This->size;
391 if ( lprcPosRect )
392 *lprcPosRect = This->size;
394 if ( ppFrame )
396 IOCS_QueryInterface( This, &IID_IOleInPlaceFrame, (void**) ppFrame );
399 if ( ppDoc )
400 *ppDoc = NULL;
402 if ( lpFrameInfo )
404 lpFrameInfo->fMDIApp = FALSE;
405 lpFrameInfo->hwndFrame = This->hWnd;
406 lpFrameInfo->haccel = NULL;
407 lpFrameInfo->cAccelEntries = 0;
410 return S_OK;
413 static HRESULT WINAPI OleInPlaceSiteWindowless_Scroll(IOleInPlaceSiteWindowless *iface, SIZE scrollExtent)
415 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
416 FIXME("(%p) - stub\n", This);
417 return E_NOTIMPL;
420 static HRESULT WINAPI OleInPlaceSiteWindowless_OnUIDeactivate(IOleInPlaceSiteWindowless *iface, BOOL fUndoable)
422 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
423 FIXME("(%p,%d) - stub\n", This, fUndoable);
424 return E_NOTIMPL;
427 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceDeactivate(IOleInPlaceSiteWindowless *iface)
429 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
431 TRACE("(%p)\n", This);
433 This->fInPlace = This->fWindowless = FALSE;
434 return S_OK;
437 static HRESULT WINAPI OleInPlaceSiteWindowless_DiscardUndoState(IOleInPlaceSiteWindowless *iface)
439 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
440 FIXME("(%p) - stub\n", This);
441 return E_NOTIMPL;
444 static HRESULT WINAPI OleInPlaceSiteWindowless_DeactivateAndUndo(IOleInPlaceSiteWindowless *iface)
446 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
447 FIXME("(%p) - stub\n", This);
448 return E_NOTIMPL;
451 static HRESULT WINAPI OleInPlaceSiteWindowless_OnPosRectChange(IOleInPlaceSiteWindowless *iface, LPCRECT lprcPosRect)
453 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
454 FIXME("(%p,%p) - stub\n", This, lprcPosRect);
455 return E_NOTIMPL;
458 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceActivateEx( IOleInPlaceSiteWindowless *iface, BOOL* pfNoRedraw, DWORD dwFlags)
460 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
462 TRACE("\n");
464 This->fActive = This->fInPlace = TRUE;
465 if ( dwFlags & ACTIVATE_WINDOWLESS )
466 This->fWindowless = TRUE;
467 return S_OK;
470 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceDeactivateEx( IOleInPlaceSiteWindowless *iface, BOOL fNoRedraw)
472 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
474 TRACE("\n");
476 This->fActive = This->fInPlace = This->fWindowless = FALSE;
477 return S_OK;
479 static HRESULT WINAPI OleInPlaceSiteWindowless_RequestUIActivate( IOleInPlaceSiteWindowless *iface)
481 FIXME("\n");
482 return E_NOTIMPL;
484 static HRESULT WINAPI OleInPlaceSiteWindowless_CanWindowlessActivate( IOleInPlaceSiteWindowless *iface)
486 FIXME("\n");
487 return S_OK;
489 static HRESULT WINAPI OleInPlaceSiteWindowless_GetCapture( IOleInPlaceSiteWindowless *iface)
491 FIXME("\n");
492 return E_NOTIMPL;
494 static HRESULT WINAPI OleInPlaceSiteWindowless_SetCapture( IOleInPlaceSiteWindowless *iface, BOOL fCapture)
496 FIXME("\n");
497 return E_NOTIMPL;
499 static HRESULT WINAPI OleInPlaceSiteWindowless_GetFocus( IOleInPlaceSiteWindowless *iface)
501 FIXME("\n");
502 return E_NOTIMPL;
504 static HRESULT WINAPI OleInPlaceSiteWindowless_SetFocus( IOleInPlaceSiteWindowless *iface, BOOL fFocus)
506 FIXME("\n");
507 return E_NOTIMPL;
509 static HRESULT WINAPI OleInPlaceSiteWindowless_GetDC( IOleInPlaceSiteWindowless *iface, LPCRECT pRect, DWORD grfFlags, HDC* phDC)
511 FIXME("\n");
512 return E_NOTIMPL;
514 static HRESULT WINAPI OleInPlaceSiteWindowless_ReleaseDC( IOleInPlaceSiteWindowless *iface, HDC hDC)
516 FIXME("\n");
517 return E_NOTIMPL;
519 static HRESULT WINAPI OleInPlaceSiteWindowless_InvalidateRect( IOleInPlaceSiteWindowless *iface, LPCRECT pRect, BOOL fErase)
521 FIXME("\n");
522 return E_NOTIMPL;
524 static HRESULT WINAPI OleInPlaceSiteWindowless_InvalidateRgn( IOleInPlaceSiteWindowless *iface, HRGN hRGN, BOOL fErase)
526 FIXME("\n");
527 return E_NOTIMPL;
529 static HRESULT WINAPI OleInPlaceSiteWindowless_ScrollRect( IOleInPlaceSiteWindowless *iface, INT dx, INT dy, LPCRECT pRectScroll, LPCRECT pRectClip)
531 FIXME("\n");
532 return E_NOTIMPL;
534 static HRESULT WINAPI OleInPlaceSiteWindowless_AdjustRect( IOleInPlaceSiteWindowless *iface, LPRECT prc)
536 FIXME("\n");
537 return E_NOTIMPL;
539 static HRESULT WINAPI OleInPlaceSiteWindowless_OnDefWindowMessage( IOleInPlaceSiteWindowless *iface, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT* plResult)
541 FIXME("\n");
542 return E_NOTIMPL;
546 /****** IOleInPlaceFrame *******/
547 static inline IOCS *impl_from_IOleInPlaceFrame(IOleInPlaceFrame *iface)
549 return CONTAINING_RECORD(iface, IOCS, IOleInPlaceFrame_iface);
552 static HRESULT WINAPI OleInPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
554 IOCS *This = impl_from_IOleInPlaceFrame(iface);
555 return IOCS_QueryInterface(This, riid, ppv);
558 static ULONG WINAPI OleInPlaceFrame_AddRef(IOleInPlaceFrame *iface)
560 IOCS *This = impl_from_IOleInPlaceFrame(iface);
561 return IOCS_AddRef(This);
564 static ULONG WINAPI OleInPlaceFrame_Release(IOleInPlaceFrame *iface)
566 IOCS *This = impl_from_IOleInPlaceFrame(iface);
567 return IOCS_Release(This);
570 static HRESULT WINAPI OleInPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phWnd)
572 IOCS *This = impl_from_IOleInPlaceFrame(iface);
574 TRACE( "(%p,%p)\n", This, phWnd );
576 *phWnd = This->hWnd;
577 return S_OK;
580 static HRESULT WINAPI OleInPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
582 IOCS *This = impl_from_IOleInPlaceFrame(iface);
584 FIXME( "(%p,%d) - stub\n", This, fEnterMode );
585 return E_NOTIMPL;
588 static HRESULT WINAPI OleInPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
590 IOCS *This = impl_from_IOleInPlaceFrame(iface);
592 FIXME( "(%p,%p) - stub\n", This, lprectBorder );
593 return E_NOTIMPL;
596 static HRESULT WINAPI OleInPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
598 IOCS *This = impl_from_IOleInPlaceFrame(iface);
600 FIXME( "(%p,%p) - stub\n", This, pborderwidths );
601 return E_NOTIMPL;
604 static HRESULT WINAPI OleInPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
606 IOCS *This = impl_from_IOleInPlaceFrame(iface);
608 FIXME( "(%p,%p) - stub\n", This, pborderwidths );
609 return E_NOTIMPL;
612 static HRESULT WINAPI OleInPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface, IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
614 IOCS *This = impl_from_IOleInPlaceFrame(iface);
616 FIXME( "(%p,%p,%s) - stub\n", This, pActiveObject, debugstr_w(pszObjName) );
617 return S_OK;
620 static HRESULT WINAPI OleInPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
622 IOCS *This = impl_from_IOleInPlaceFrame(iface);
624 FIXME( "(%p,%p,%p) - stub\n", This, hmenuShared, lpMenuWidths );
625 return E_NOTIMPL;
628 static HRESULT WINAPI OleInPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
630 IOCS *This = impl_from_IOleInPlaceFrame(iface);
632 FIXME( "(%p,%p,%p,%p) - stub\n", This, hmenuShared, holemenu, hwndActiveObject );
633 return E_NOTIMPL;
636 static HRESULT WINAPI OleInPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
638 IOCS *This = impl_from_IOleInPlaceFrame(iface);
640 FIXME( "(%p, %p) - stub\n", This, hmenuShared );
641 return E_NOTIMPL;
644 static HRESULT WINAPI OleInPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
646 IOCS *This = impl_from_IOleInPlaceFrame(iface);
648 FIXME( "(%p, %s) - stub\n", This, debugstr_w( pszStatusText ) );
649 return E_NOTIMPL;
652 static HRESULT WINAPI OleInPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
654 IOCS *This = impl_from_IOleInPlaceFrame(iface);
656 FIXME( "(%p, %d) - stub\n", This, fEnable );
657 return E_NOTIMPL;
660 static HRESULT WINAPI OleInPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
662 IOCS *This = impl_from_IOleInPlaceFrame(iface);
664 FIXME( "(%p, %p, %x) - stub\n", This, lpmsg, wID );
665 return E_NOTIMPL;
669 /****** IOleControlSite *******/
670 static inline IOCS *impl_from_IOleControlSite(IOleControlSite *iface)
672 return CONTAINING_RECORD(iface, IOCS, IOleControlSite_iface);
675 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
677 IOCS *This = impl_from_IOleControlSite(iface);
678 return IOCS_QueryInterface(This, riid, ppv);
681 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
683 IOCS *This = impl_from_IOleControlSite(iface);
684 return IOCS_AddRef(This);
687 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
689 IOCS *This = impl_from_IOleControlSite(iface);
690 return IOCS_Release(This);
693 static HRESULT WINAPI OleControlSite_OnControlInfoChanged( IOleControlSite* This)
695 FIXME( "\n" );
696 return E_NOTIMPL;
698 static HRESULT WINAPI OleControlSite_LockInPlaceActive( IOleControlSite* This, BOOL fLock)
700 FIXME( "\n" );
701 return E_NOTIMPL;
703 static HRESULT WINAPI OleControlSite_GetExtendedControl( IOleControlSite* This, IDispatch** ppDisp)
705 FIXME( "\n" );
706 return E_NOTIMPL;
708 static HRESULT WINAPI OleControlSite_TransformCoords( IOleControlSite* This, POINTL* pPtlHimetric, POINTF* pPtfContainer, DWORD dwFlags)
710 FIXME( "\n" );
711 return E_NOTIMPL;
713 static HRESULT WINAPI OleControlSite_TranslateAccelerator( IOleControlSite* This, MSG* pMsg, DWORD grfModifiers)
715 FIXME( "\n" );
716 return E_NOTIMPL;
718 static HRESULT WINAPI OleControlSite_OnFocus( IOleControlSite* This, BOOL fGotFocus)
720 FIXME( "\n" );
721 return E_NOTIMPL;
723 static HRESULT WINAPI OleControlSite_ShowPropertyFrame( IOleControlSite* This)
725 FIXME( "\n" );
726 return E_NOTIMPL;
730 static const IOleClientSiteVtbl OleClientSite_vtbl = {
731 OleClientSite_QueryInterface,
732 OleClientSite_AddRef,
733 OleClientSite_Release,
734 OleClientSite_SaveObject,
735 OleClientSite_GetMoniker,
736 OleClientSite_GetContainer,
737 OleClientSite_ShowObject,
738 OleClientSite_OnShowWindow,
739 OleClientSite_RequestNewObjectLayout
741 static const IOleContainerVtbl OleContainer_vtbl = {
742 OleContainer_QueryInterface,
743 OleContainer_AddRef,
744 OleContainer_Release,
745 OleContainer_ParseDisplayName,
746 OleContainer_EnumObjects,
747 OleContainer_LockContainer
749 static const IOleInPlaceSiteWindowlessVtbl OleInPlaceSiteWindowless_vtbl = {
750 OleInPlaceSiteWindowless_QueryInterface,
751 OleInPlaceSiteWindowless_AddRef,
752 OleInPlaceSiteWindowless_Release,
753 OleInPlaceSiteWindowless_GetWindow,
754 OleInPlaceSiteWindowless_ContextSensitiveHelp,
755 OleInPlaceSiteWindowless_CanInPlaceActivate,
756 OleInPlaceSiteWindowless_OnInPlaceActivate,
757 OleInPlaceSiteWindowless_OnUIActivate,
758 OleInPlaceSiteWindowless_GetWindowContext,
759 OleInPlaceSiteWindowless_Scroll,
760 OleInPlaceSiteWindowless_OnUIDeactivate,
761 OleInPlaceSiteWindowless_OnInPlaceDeactivate,
762 OleInPlaceSiteWindowless_DiscardUndoState,
763 OleInPlaceSiteWindowless_DeactivateAndUndo,
764 OleInPlaceSiteWindowless_OnPosRectChange,
765 OleInPlaceSiteWindowless_OnInPlaceActivateEx,
766 OleInPlaceSiteWindowless_OnInPlaceDeactivateEx,
767 OleInPlaceSiteWindowless_RequestUIActivate,
768 OleInPlaceSiteWindowless_CanWindowlessActivate,
769 OleInPlaceSiteWindowless_GetCapture,
770 OleInPlaceSiteWindowless_SetCapture,
771 OleInPlaceSiteWindowless_GetFocus,
772 OleInPlaceSiteWindowless_SetFocus,
773 OleInPlaceSiteWindowless_GetDC,
774 OleInPlaceSiteWindowless_ReleaseDC,
775 OleInPlaceSiteWindowless_InvalidateRect,
776 OleInPlaceSiteWindowless_InvalidateRgn,
777 OleInPlaceSiteWindowless_ScrollRect,
778 OleInPlaceSiteWindowless_AdjustRect,
779 OleInPlaceSiteWindowless_OnDefWindowMessage
781 static const IOleInPlaceFrameVtbl OleInPlaceFrame_vtbl =
783 OleInPlaceFrame_QueryInterface,
784 OleInPlaceFrame_AddRef,
785 OleInPlaceFrame_Release,
786 OleInPlaceFrame_GetWindow,
787 OleInPlaceFrame_ContextSensitiveHelp,
788 OleInPlaceFrame_GetBorder,
789 OleInPlaceFrame_RequestBorderSpace,
790 OleInPlaceFrame_SetBorderSpace,
791 OleInPlaceFrame_SetActiveObject,
792 OleInPlaceFrame_InsertMenus,
793 OleInPlaceFrame_SetMenu,
794 OleInPlaceFrame_RemoveMenus,
795 OleInPlaceFrame_SetStatusText,
796 OleInPlaceFrame_EnableModeless,
797 OleInPlaceFrame_TranslateAccelerator
799 static const IOleControlSiteVtbl OleControlSite_vtbl =
801 OleControlSite_QueryInterface,
802 OleControlSite_AddRef,
803 OleControlSite_Release,
804 OleControlSite_OnControlInfoChanged,
805 OleControlSite_LockInPlaceActive,
806 OleControlSite_GetExtendedControl,
807 OleControlSite_TransformCoords,
808 OleControlSite_TranslateAccelerator,
809 OleControlSite_OnFocus,
810 OleControlSite_ShowPropertyFrame
813 static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */
815 if ( This->hWnd )
817 SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc );
818 SetWindowLongPtrW( This->hWnd, GWLP_USERDATA, 0 );
819 This->hWnd = NULL;
821 if ( This->control )
823 IOleObject *control = This->control;
825 This->control = NULL;
826 IOleObject_Close( control, OLECLOSE_NOSAVE );
827 IOleObject_SetClientSite( control, NULL );
828 IOleObject_Release( control );
830 return S_OK;
833 static void IOCS_OnSize( IOCS* This, LPCRECT rect )
835 SIZEL inPix, inHi;
837 This->size.left = rect->left; This->size.right = rect->right; This->size.top = rect->top; This->size.bottom = rect->bottom;
839 if ( !This->control )
840 return;
842 inPix.cx = rect->right - rect->left;
843 inPix.cy = rect->bottom - rect->top;
844 AtlPixelToHiMetric( &inPix, &inHi );
845 IOleObject_SetExtent( This->control, DVASPECT_CONTENT, &inHi );
847 if ( This->fInPlace )
849 IOleInPlaceObject *wl;
851 if ( SUCCEEDED( IOleObject_QueryInterface( This->control, &IID_IOleInPlaceObject, (void**)&wl ) ) )
853 IOleInPlaceObject_SetObjectRects( wl, rect, rect );
854 IOleInPlaceObject_Release( wl );
859 static void IOCS_OnShow( IOCS *This, BOOL fShow )
861 if (!This->control || This->fActive || !fShow )
862 return;
864 This->fActive = TRUE;
867 static void IOCS_OnDraw( IOCS *This )
869 IViewObject *view;
871 if ( !This->control || !This->fWindowless )
872 return;
874 if ( SUCCEEDED( IOleObject_QueryInterface( This->control, &IID_IViewObject, (void**)&view ) ) )
876 HDC dc = GetDC( This->hWnd );
877 RECTL rect;
879 rect.left = This->size.left; rect.top = This->size.top;
880 rect.bottom = This->size.bottom; rect.right = This->size.right;
882 IViewObject_Draw( view, DVASPECT_CONTENT, ~0, NULL, NULL, 0, dc, &rect, &rect, NULL, 0 );
883 IViewObject_Release( view );
884 ReleaseDC( This->hWnd, dc );
888 static LRESULT IOCS_OnWndProc( IOCS *This, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
890 WNDPROC OrigWndProc = This->OrigWndProc;
892 switch( uMsg )
894 case WM_DESTROY:
895 IOCS_Detach( This );
896 break;
897 case WM_SIZE:
899 RECT r;
900 r.left = r.top = 0;
901 r.right = LOWORD( lParam );
902 r.bottom = HIWORD( lParam );
903 IOCS_OnSize( This, &r );
905 break;
906 case WM_SHOWWINDOW:
907 IOCS_OnShow( This, (BOOL) wParam );
908 break;
909 case WM_PAINT:
910 IOCS_OnDraw( This );
911 break;
914 return CallWindowProcW( OrigWndProc, hWnd, uMsg, wParam, lParam );
917 static LRESULT CALLBACK AtlHost_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
919 IOCS *This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
920 return IOCS_OnWndProc( This, hWnd, wMsg, wParam, lParam );
923 static HRESULT IOCS_Attach( IOCS *This, HWND hWnd, IUnknown *pUnkControl ) /* subclass hWnd */
925 This->hWnd = hWnd;
926 IUnknown_QueryInterface( pUnkControl, &IID_IOleObject, (void**)&This->control );
927 IOleObject_SetClientSite( This->control, &This->IOleClientSite_iface );
928 SetWindowLongPtrW( hWnd, GWLP_USERDATA, (ULONG_PTR) This );
929 This->OrigWndProc = (WNDPROC)SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (ULONG_PTR) AtlHost_wndproc );
931 return S_OK;
934 static HRESULT IOCS_Init( IOCS *This )
936 RECT rect;
937 static const WCHAR AXWIN[] = {'A','X','W','I','N',0};
939 IOleObject_SetHostNames( This->control, AXWIN, AXWIN );
941 GetClientRect( This->hWnd, &rect );
942 IOCS_OnSize( This, &rect );
943 IOleObject_DoVerb( This->control, OLEIVERB_INPLACEACTIVATE, NULL, &This->IOleClientSite_iface,
944 0, This->hWnd, &rect );
946 return S_OK;
949 /**********************************************************************
950 * Create new instance of Atl host component and attach it to window *
952 static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IOCS **ppSite )
954 HRESULT hr;
955 IOCS *This;
957 *ppSite = NULL;
958 This = HeapAlloc(GetProcessHeap(), 0, sizeof(IOCS));
960 if (!This)
961 return E_OUTOFMEMORY;
963 This->IOleClientSite_iface.lpVtbl = &OleClientSite_vtbl;
964 This->IOleContainer_iface.lpVtbl = &OleContainer_vtbl;
965 This->IOleInPlaceSiteWindowless_iface.lpVtbl = &OleInPlaceSiteWindowless_vtbl;
966 This->IOleInPlaceFrame_iface.lpVtbl = &OleInPlaceFrame_vtbl;
967 This->IOleControlSite_iface.lpVtbl = &OleControlSite_vtbl;
968 This->ref = 1;
970 This->OrigWndProc = NULL;
971 This->hWnd = NULL;
972 This->fWindowless = This->fActive = This->fInPlace = FALSE;
974 hr = IOCS_Attach( This, hWnd, pUnkControl );
975 if ( SUCCEEDED( hr ) )
976 hr = IOCS_Init( This );
977 if ( SUCCEEDED( hr ) )
978 *ppSite = This;
979 else
980 IOCS_Release( This );
982 return hr;
986 /***********************************************************************
987 * AtlAxCreateControl [atl100.@]
989 HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd,
990 IStream *pStream, IUnknown **ppUnkContainer)
992 return AtlAxCreateControlEx( lpszName, hWnd, pStream, ppUnkContainer,
993 NULL, NULL, NULL );
996 /***********************************************************************
997 * AtlAxCreateControlEx [atl100.@]
999 * REMARKS
1000 * See http://www.codeproject.com/com/cwebpage.asp for some background
1003 HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
1004 IStream *pStream, IUnknown **ppUnkContainer, IUnknown **ppUnkControl,
1005 REFIID iidSink, IUnknown *punkSink)
1007 CLSID controlId;
1008 HRESULT hRes;
1009 IOleObject *pControl;
1010 IUnknown *pUnkControl;
1011 IPersistStreamInit *pPSInit;
1012 IUnknown *pContainer;
1013 enum {IsGUID=0,IsHTML=1,IsURL=2} content;
1015 TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream,
1016 ppUnkContainer, ppUnkControl, iidSink, punkSink);
1018 hRes = CLSIDFromString( lpszName, &controlId );
1019 if ( FAILED(hRes) )
1020 hRes = CLSIDFromProgID( lpszName, &controlId );
1021 if ( SUCCEEDED( hRes ) )
1022 content = IsGUID;
1023 else {
1024 /* FIXME - check for MSHTML: prefix! */
1025 content = IsURL;
1026 controlId = CLSID_WebBrowser;
1029 hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject,
1030 (void**) &pControl );
1031 if ( FAILED( hRes ) )
1033 WARN( "cannot create ActiveX control %s instance - error 0x%08x\n",
1034 debugstr_guid( &controlId ), hRes );
1035 return hRes;
1038 hRes = IOleObject_QueryInterface( pControl, &IID_IPersistStreamInit, (void**) &pPSInit );
1039 if ( SUCCEEDED( hRes ) )
1041 if (!pStream)
1042 IPersistStreamInit_InitNew( pPSInit );
1043 else
1044 IPersistStreamInit_Load( pPSInit, pStream );
1045 IPersistStreamInit_Release( pPSInit );
1046 } else
1047 WARN("cannot get IID_IPersistStreamInit out of control\n");
1049 IOleObject_QueryInterface( pControl, &IID_IUnknown, (void**) &pUnkControl );
1050 IOleObject_Release( pControl );
1053 hRes = AtlAxAttachControl( pUnkControl, hWnd, &pContainer );
1054 if ( FAILED( hRes ) )
1055 WARN("cannot attach control to window\n");
1057 if ( content == IsURL )
1059 IWebBrowser2 *browser;
1061 hRes = IOleObject_QueryInterface( pControl, &IID_IWebBrowser2, (void**) &browser );
1062 if ( !browser )
1063 WARN( "Cannot query IWebBrowser2 interface: %08x\n", hRes );
1064 else {
1065 VARIANT url;
1067 IWebBrowser2_put_Visible( browser, VARIANT_TRUE ); /* it seems that native does this on URL (but do not on MSHTML:! why? */
1069 V_VT(&url) = VT_BSTR;
1070 V_BSTR(&url) = SysAllocString( lpszName );
1072 hRes = IWebBrowser2_Navigate2( browser, &url, NULL, NULL, NULL, NULL );
1073 if ( FAILED( hRes ) )
1074 WARN( "IWebBrowser2::Navigate2 failed: %08x\n", hRes );
1075 SysFreeString( V_BSTR(&url) );
1077 IWebBrowser2_Release( browser );
1081 if (ppUnkContainer)
1083 *ppUnkContainer = pContainer;
1084 if ( pContainer )
1085 IUnknown_AddRef( pContainer );
1087 if (ppUnkControl)
1089 *ppUnkControl = pUnkControl;
1090 if ( pUnkControl )
1091 IUnknown_AddRef( pUnkControl );
1094 if ( pUnkControl )
1095 IUnknown_Release( pUnkControl );
1096 if ( pContainer )
1097 IUnknown_Release( pContainer );
1099 return S_OK;
1102 /***********************************************************************
1103 * AtlAxAttachControl [atl100.@]
1105 HRESULT WINAPI AtlAxAttachControl(IUnknown* pControl, HWND hWnd, IUnknown** ppUnkContainer)
1107 IOCS *pUnkContainer;
1108 HRESULT hr;
1110 TRACE( "%p %p %p\n", pControl, hWnd, ppUnkContainer );
1112 if (!pControl)
1113 return E_INVALIDARG;
1115 hr = IOCS_Create( hWnd, pControl, &pUnkContainer );
1116 if ( SUCCEEDED( hr ) && ppUnkContainer)
1118 *ppUnkContainer = (IUnknown*) pUnkContainer;
1121 if(!hWnd)
1122 return S_FALSE;
1124 return hr;
1127 /**********************************************************************
1128 * Helper function for AX_ConvertDialogTemplate
1130 static inline BOOL advance_array(WORD **pptr, DWORD *palloc, DWORD *pfilled, const WORD *data, DWORD size)
1132 if ( (*pfilled + size) > *palloc )
1134 *palloc = ((*pfilled+size) + 0xFF) & ~0xFF;
1135 *pptr = HeapReAlloc( GetProcessHeap(), 0, *pptr, *palloc * sizeof(WORD) );
1136 if (!*pptr)
1137 return FALSE;
1139 RtlMoveMemory( *pptr+*pfilled, data, size * sizeof(WORD) );
1140 *pfilled += size;
1141 return TRUE;
1144 /**********************************************************************
1145 * Convert ActiveX control templates to AtlAxWin class instances
1147 static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
1149 #define GET_WORD(x) (*(const WORD *)(x))
1150 #define GET_DWORD(x) (*(const DWORD *)(x))
1151 #define PUT_BLOCK(x,y) do {if (!advance_array(&output, &allocated, &filled, (x), (y))) return NULL;} while (0)
1152 #define PUT_WORD(x) do {WORD w = (x);PUT_BLOCK(&w, 1);} while(0)
1153 #define PUT_DWORD(x) do {DWORD w = (x);PUT_BLOCK(&w, 2);} while(0)
1154 const WORD *tmp, *src = (const WORD *)src_tmpl;
1155 WORD *output;
1156 DWORD allocated, filled; /* in WORDs */
1157 BOOL ext;
1158 WORD signature, dlgver, rescount;
1159 DWORD style;
1161 filled = 0; allocated = 256;
1162 output = HeapAlloc( GetProcessHeap(), 0, allocated * sizeof(WORD) );
1163 if (!output)
1164 return NULL;
1166 /* header */
1167 tmp = src;
1168 signature = GET_WORD(src);
1169 dlgver = GET_WORD(src + 1);
1170 if (signature == 1 && dlgver == 0xFFFF)
1172 ext = TRUE;
1173 src += 6;
1174 style = GET_DWORD(src);
1175 src += 2;
1176 rescount = GET_WORD(src++);
1177 src += 4;
1178 if ( GET_WORD(src) == 0xFFFF ) /* menu */
1179 src += 2;
1180 else
1181 src += strlenW(src) + 1;
1182 if ( GET_WORD(src) == 0xFFFF ) /* class */
1183 src += 2;
1184 else
1185 src += strlenW(src) + 1;
1186 src += strlenW(src) + 1; /* title */
1187 if ( style & (DS_SETFONT | DS_SHELLFONT) )
1189 src += 3;
1190 src += strlenW(src) + 1;
1192 } else {
1193 ext = FALSE;
1194 style = GET_DWORD(src);
1195 src += 4;
1196 rescount = GET_WORD(src++);
1197 src += 4;
1198 if ( GET_WORD(src) == 0xFFFF ) /* menu */
1199 src += 2;
1200 else
1201 src += strlenW(src) + 1;
1202 if ( GET_WORD(src) == 0xFFFF ) /* class */
1203 src += 2;
1204 else
1205 src += strlenW(src) + 1;
1206 src += strlenW(src) + 1; /* title */
1207 if ( style & DS_SETFONT )
1209 src++;
1210 src += strlenW(src) + 1;
1213 PUT_BLOCK(tmp, src-tmp);
1215 while(rescount--)
1217 src = (const WORD *)( ( ((ULONG_PTR)src) + 3) & ~3); /* align on DWORD boundary */
1218 filled = (filled + 1) & ~1; /* depends on DWORD-aligned allocation unit */
1220 tmp = src;
1221 if (ext)
1222 src += 12;
1223 else
1224 src += 9;
1225 PUT_BLOCK(tmp, src-tmp);
1227 tmp = src;
1228 if ( GET_WORD(src) == 0xFFFF ) /* class */
1230 src += 2;
1231 } else
1233 src += strlenW(src) + 1;
1235 src += strlenW(src) + 1; /* title */
1236 if ( GET_WORD(tmp) == '{' ) /* all this mess created because of this line */
1238 static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n', 0};
1239 PUT_BLOCK(AtlAxWin, sizeof(AtlAxWin)/sizeof(WCHAR));
1240 PUT_BLOCK(tmp, strlenW(tmp)+1);
1241 } else
1242 PUT_BLOCK(tmp, src-tmp);
1244 if ( GET_WORD(src) )
1246 WORD size = (GET_WORD(src)+sizeof(WORD)-1) / sizeof(WORD); /* quite ugly :( Maybe use BYTE* instead of WORD* everywhere ? */
1247 PUT_BLOCK(src, size);
1248 src+=size;
1250 else
1252 PUT_WORD(0);
1253 src++;
1256 return (LPDLGTEMPLATEW) output;
1259 /***********************************************************************
1260 * AtlAxCreateDialogA [atl100.@]
1262 * Creates a dialog window
1264 * PARAMS
1265 * hInst [I] Application instance
1266 * name [I] Dialog box template name
1267 * owner [I] Dialog box parent HWND
1268 * dlgProc [I] Dialog box procedure
1269 * param [I] This value will be passed to dlgProc as WM_INITDIALOG's message lParam
1271 * RETURNS
1272 * Window handle of dialog window.
1274 HWND WINAPI AtlAxCreateDialogA(HINSTANCE hInst, LPCSTR name, HWND owner, DLGPROC dlgProc ,LPARAM param)
1276 HWND res = NULL;
1277 int length;
1278 WCHAR *nameW;
1280 if (IS_INTRESOURCE(name))
1281 return AtlAxCreateDialogW( hInst, (LPCWSTR) name, owner, dlgProc, param );
1283 length = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
1284 nameW = HeapAlloc( GetProcessHeap(), 0, length * sizeof(WCHAR) );
1285 if (nameW)
1287 MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, length );
1288 res = AtlAxCreateDialogW( hInst, nameW, owner, dlgProc, param );
1289 HeapFree( GetProcessHeap(), 0, nameW );
1291 return res;
1294 /***********************************************************************
1295 * AtlAxCreateDialogW [atl100.@]
1297 * See AtlAxCreateDialogA
1300 HWND WINAPI AtlAxCreateDialogW(HINSTANCE hInst, LPCWSTR name, HWND owner, DLGPROC dlgProc ,LPARAM param)
1302 HRSRC hrsrc;
1303 HGLOBAL hgl;
1304 LPCDLGTEMPLATEW ptr;
1305 LPDLGTEMPLATEW newptr;
1306 HWND res;
1308 TRACE("(%p %s %p %p %lx)\n", hInst, debugstr_w(name), owner, dlgProc, param);
1310 hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
1311 if ( !hrsrc )
1312 return NULL;
1313 hgl = LoadResource (hInst, hrsrc);
1314 if ( !hgl )
1315 return NULL;
1316 ptr = LockResource ( hgl );
1317 if (!ptr)
1319 FreeResource( hgl );
1320 return NULL;
1322 newptr = AX_ConvertDialogTemplate( ptr );
1323 if ( newptr )
1325 res = CreateDialogIndirectParamW( hInst, newptr, owner, dlgProc, param );
1326 HeapFree( GetProcessHeap(), 0, newptr );
1327 } else
1328 res = NULL;
1329 FreeResource ( hrsrc );
1330 return res;
1333 /***********************************************************************
1334 * AtlAxGetHost [atl100.@]
1337 HRESULT WINAPI AtlAxGetHost(HWND hWnd, IUnknown **pUnk)
1339 IOCS *This;
1341 TRACE( "(%p, %p)\n", hWnd, pUnk );
1343 *pUnk = NULL;
1345 This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
1346 if ( !This )
1348 WARN("No container attached to %p\n", hWnd );
1349 return E_FAIL;
1352 return IOCS_QueryInterface( This, &IID_IUnknown, (void**) pUnk );
1355 /***********************************************************************
1356 * AtlAxGetControl [atl100.@]
1359 HRESULT WINAPI AtlAxGetControl(HWND hWnd, IUnknown **pUnk)
1361 IOCS *This;
1363 TRACE( "(%p, %p)\n", hWnd, pUnk );
1365 *pUnk = NULL;
1367 This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
1368 if ( !This || !This->control )
1370 WARN("No control attached to %p\n", hWnd );
1371 return E_FAIL;
1374 return IOleObject_QueryInterface( This->control, &IID_IUnknown, (void**) pUnk );
1377 /***********************************************************************
1378 * AtlAxDialogBoxW [atl100.35]
1381 INT_PTR WINAPI AtlAxDialogBoxW(HINSTANCE hInstance, LPCWSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogProc,
1382 LPARAM dwInitParam)
1384 FIXME("(%p %s %p %p %lx)\n", hInstance, debugstr_w(lpTemplateName), hWndParent, lpDialogProc, dwInitParam);
1385 return 0;
1388 /***********************************************************************
1389 * AtlAxDialogBoxA [atl100.36]
1392 INT_PTR WINAPI AtlAxDialogBoxA(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogProc,
1393 LPARAM dwInitParam)
1395 FIXME("(%p %s %p %p %lx)\n", hInstance, debugstr_a(lpTemplateName), hWndParent, lpDialogProc, dwInitParam);
1396 return 0;