xref: /aoo4110/main/dtrans/test/win32/dnd/atlwindow.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _WINDOW_HXX_
24 #define _WINDOW_HXX_
25 #include <atlbase.h>
26 extern CComModule _Module;
27 #include<atlcom.h>
28 #include<atlctl.h>
29 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
30 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
31 #include <com/sun/star/datatransfer/XTransferable.hpp>
32 #include <com/sun/star/uno/Reference.h>
33 #include "../../source/inc/DtObjFactory.hxx"
34 
35 
36 using namespace com::sun::star::uno;
37 using namespace com::sun::star::datatransfer::dnd;
38 using namespace com::sun::star::datatransfer;
39 
40 struct ThreadData
41 {
42 	Reference<XDragSource> source;
43 	Reference<XTransferable> transferable;
44 	HANDLE evtThreadReady;
45 };
46 
47 class AWindow: public CWindowImpl<AWindow, CWindow,
48 	  CWinTraits<WS_CAPTION |WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0> >
49 {
50 	TCHAR m_strName[80];
51 	Reference<XDropTarget> m_xDropTarget;
52 	Reference<XDragSource> m_xDragSource;
53 	BOOL m_isMTA;
54 
55 	HWND m_hwndEdit;
56 
57 	CDTransObjFactory m_aDataConverter;
58 
59 public:
AWindow(LPCTSTR strName)60 	AWindow(LPCTSTR strName)
61 	{
62 		RECT rcPos= {0,0,200,200};
63 		Create(0, rcPos, strName);
64 	}
AWindow(LPCTSTR strName,RECT pos,BOOL mta=FALSE)65 	AWindow(LPCTSTR strName, RECT pos, BOOL mta=FALSE): m_isMTA( mta)
66 	{
67 		Create(0, pos, strName);
68 	}
69 
~AWindow()70 	~AWindow()
71 	{
72 		if(m_hWnd)
73 			DestroyWindow();
74 	}
75 
76 
77 	BEGIN_MSG_MAP(AWindow)
78 		MESSAGE_HANDLER( WM_CLOSE, OnClose)
79 		MESSAGE_HANDLER( WM_CREATE, OnCreate)
80 		MESSAGE_RANGE_HANDLER( WM_MOUSEFIRST,  WM_MOUSELAST, OnMouseAction)
81 		MESSAGE_HANDLER( WM_TIMER, OnTimer)
82 		MESSAGE_HANDLER( WM_SIZE, OnSize)
83 		MESSAGE_HANDLER( WM_SETFOCUS, OnFocus)
84 
85 	END_MSG_MAP()
86 
87 	LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
88 	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
89 	LRESULT OnMouseAction(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
90 	LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
91 	LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
92 	LRESULT OnFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
93 
94 };
95 
96 #endif
97