xref: /AOO41X/main/embedserv/source/embed/syswinwrapper.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER > 1310)
28*cdf0e10cSrcweir #pragma warning(disable : 4917 4555)
29*cdf0e10cSrcweir #endif
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "docholder.hxx"
32*cdf0e10cSrcweir #include "syswinwrapper.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir /*
35*cdf0e10cSrcweir  * CWindow::CWindow
36*cdf0e10cSrcweir  * CWindow::~CWindow
37*cdf0e10cSrcweir  *
38*cdf0e10cSrcweir  * Constructor Parameters:
39*cdf0e10cSrcweir  *  hInst           HINSTANCE of the task owning us.
40*cdf0e10cSrcweir  */
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir using namespace winwrap;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #define HWWL_STRUCTURE                  0
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir //Notification codes for WM_COMMAND messages
49*cdf0e10cSrcweir #define HWN_BORDERDOUBLECLICKED         1
50*cdf0e10cSrcweir #define CBHATCHWNDEXTRA                 (sizeof(LONG))
51*cdf0e10cSrcweir #define SZCLASSHATCHWIN                 TEXT("hatchwin")
52*cdf0e10cSrcweir #define SendCommand(hWnd, wID, wCode, hControl)                     \
53*cdf0e10cSrcweir             SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(wID, wCode)    \
54*cdf0e10cSrcweir                         , (LPARAM)hControl)
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir typedef CHatchWin *PCHatchWin;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir void DrawShading(LPRECT prc, HDC hDC, UINT cWidth);
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir winwrap::CWindow::CWindow(HINSTANCE hInst)
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir     m_hInst=hInst;
67*cdf0e10cSrcweir     m_hWnd=NULL;
68*cdf0e10cSrcweir     return;
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir winwrap::CWindow::~CWindow(void)
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir     if (IsWindow(m_hWnd))
74*cdf0e10cSrcweir         DestroyWindow(m_hWnd);
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     return;
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir /*
82*cdf0e10cSrcweir  * CWindow::Window
83*cdf0e10cSrcweir  *
84*cdf0e10cSrcweir  * Purpose:
85*cdf0e10cSrcweir  *  Returns the window handle associated with this object.
86*cdf0e10cSrcweir  *
87*cdf0e10cSrcweir  * Return Value:
88*cdf0e10cSrcweir  *  HWND            Window handle for this object
89*cdf0e10cSrcweir  */
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir HWND winwrap::CWindow::Window(void)
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir     return m_hWnd;
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir /*
99*cdf0e10cSrcweir  * CWindow::Instance
100*cdf0e10cSrcweir  *
101*cdf0e10cSrcweir  * Purpose:
102*cdf0e10cSrcweir  *  Returns the instance handle associated with this object.
103*cdf0e10cSrcweir  *
104*cdf0e10cSrcweir  * Return Value:
105*cdf0e10cSrcweir  *  HINSTANCE       Instance handle of the module stored here.
106*cdf0e10cSrcweir  */
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir HINSTANCE winwrap::CWindow::Instance(void)
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir     return m_hInst;
111*cdf0e10cSrcweir }
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir //Hatch pattern brush bits
118*cdf0e10cSrcweir static WORD g_wHatchBmp[]={0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88};
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir // void DrawShading(LPRECT, HDC, UINT);
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir /*
124*cdf0e10cSrcweir  * HatchWindowRegister
125*cdf0e10cSrcweir  *
126*cdf0e10cSrcweir  * Purpose:
127*cdf0e10cSrcweir  *  Registers the hatch window class for use with CHatchWin.
128*cdf0e10cSrcweir  *
129*cdf0e10cSrcweir  * Parameters:
130*cdf0e10cSrcweir  *  hInst           HINSTANCE under which to register.
131*cdf0e10cSrcweir  *
132*cdf0e10cSrcweir  * Return Value:
133*cdf0e10cSrcweir  *  BOOL            TRUE if successful, FALSE otherwise.
134*cdf0e10cSrcweir  */
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir BOOL winwrap::HatchWindowRegister(HINSTANCE hInst)
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir     WNDCLASS    wc;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     //Must have CS_DBLCLKS for border!
141*cdf0e10cSrcweir     wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
142*cdf0e10cSrcweir     wc.hInstance     = hInst;
143*cdf0e10cSrcweir     wc.cbClsExtra    = 0;
144*cdf0e10cSrcweir     wc.lpfnWndProc   = HatchWndProc;
145*cdf0e10cSrcweir     wc.cbWndExtra    = CBHATCHWNDEXTRA;
146*cdf0e10cSrcweir     wc.hIcon         = NULL;
147*cdf0e10cSrcweir     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
148*cdf0e10cSrcweir     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
149*cdf0e10cSrcweir     wc.lpszMenuName  = NULL;
150*cdf0e10cSrcweir     wc.lpszClassName = SZCLASSHATCHWIN;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     return RegisterClass(&wc);
153*cdf0e10cSrcweir     return FALSE;
154*cdf0e10cSrcweir }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir /*
160*cdf0e10cSrcweir  * CHatchWin:CHatchWin
161*cdf0e10cSrcweir  * CHatchWin::~CHatchWin
162*cdf0e10cSrcweir  *
163*cdf0e10cSrcweir  * Constructor Parameters:
164*cdf0e10cSrcweir  *  hInst           HINSTANCE of the application we're in.
165*cdf0e10cSrcweir  */
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir CHatchWin::CHatchWin(HINSTANCE hInst,const DocumentHolder* pDocHolder)
168*cdf0e10cSrcweir     : CWindow(hInst),
169*cdf0e10cSrcweir       m_aTracker()
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir     m_hWnd=NULL;
172*cdf0e10cSrcweir     m_hWndKid=NULL;
173*cdf0e10cSrcweir     m_hWndAssociate=NULL;
174*cdf0e10cSrcweir     m_uID=0;
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir     m_dBorderOrg=GetProfileInt(TEXT("windows")
177*cdf0e10cSrcweir                                , TEXT("OleInPlaceBorderWidth")
178*cdf0e10cSrcweir                                , HATCHWIN_BORDERWIDTHDEFAULT);
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     m_dBorder=m_dBorderOrg;
181*cdf0e10cSrcweir     SetRect(&m_rcPos, 0, 0, 0, 0);
182*cdf0e10cSrcweir     SetRect(&m_rcClip, 0, 0, 0, 0);
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     m_pDocHolder = pDocHolder;
185*cdf0e10cSrcweir     return;
186*cdf0e10cSrcweir }
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir CHatchWin::~CHatchWin(void)
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir     /*
192*cdf0e10cSrcweir      * Chances are this was already destroyed when a document
193*cdf0e10cSrcweir      * was destroyed.
194*cdf0e10cSrcweir      */
195*cdf0e10cSrcweir     if (NULL!=m_hWnd && IsWindow(m_hWnd))
196*cdf0e10cSrcweir         DestroyWindow(m_hWnd);
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     return;
199*cdf0e10cSrcweir }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir /*
204*cdf0e10cSrcweir  * CHatchWin::Init
205*cdf0e10cSrcweir  *
206*cdf0e10cSrcweir  * Purpose:
207*cdf0e10cSrcweir  *  Instantiates a hatch window within a given parent with a
208*cdf0e10cSrcweir  *  default rectangle.  This is not initially visible.
209*cdf0e10cSrcweir  *
210*cdf0e10cSrcweir  * Parameters:
211*cdf0e10cSrcweir  *  hWndParent      HWND of the parent of this window
212*cdf0e10cSrcweir  *  uID             UINT identifier for this window (send in
213*cdf0e10cSrcweir  *                  notifications to associate window).
214*cdf0e10cSrcweir  *  hWndAssoc       HWND of the initial associate.
215*cdf0e10cSrcweir  *
216*cdf0e10cSrcweir  * Return Value:
217*cdf0e10cSrcweir  *  BOOL            TRUE if the function succeeded, FALSE otherwise.
218*cdf0e10cSrcweir  */
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir BOOL CHatchWin::Init(HWND hWndParent, UINT uID, HWND hWndAssoc)
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir     m_hWndParent = hWndParent;
223*cdf0e10cSrcweir 	m_hWnd=CreateWindowEx(
224*cdf0e10cSrcweir 		WS_EX_NOPARENTNOTIFY, SZCLASSHATCHWIN
225*cdf0e10cSrcweir 		, SZCLASSHATCHWIN, WS_CHILD | WS_CLIPSIBLINGS
226*cdf0e10cSrcweir 		| WS_CLIPCHILDREN, 0, 0, 100, 100, hWndParent, (HMENU)uID
227*cdf0e10cSrcweir         , m_hInst, this);
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     m_uID=uID;
230*cdf0e10cSrcweir     m_hWndAssociate=hWndAssoc;
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     return (NULL!=m_hWnd);
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir void CHatchWin::SetTrans()
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir     HRGN hrgn = CreateRectRgn(0,0,0,0);
239*cdf0e10cSrcweir     SetWindowRgn(m_hWnd,hrgn,true);
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir /*
243*cdf0e10cSrcweir  * CHatchWin::HwndAssociateSet
244*cdf0e10cSrcweir  * CHatchWin::HwndAssociateGet
245*cdf0e10cSrcweir  *
246*cdf0e10cSrcweir  * Purpose:
247*cdf0e10cSrcweir  *  Sets (Set) or retrieves (Get) the associate window of the
248*cdf0e10cSrcweir  *  hatch window.
249*cdf0e10cSrcweir  *
250*cdf0e10cSrcweir  * Parameters: (Set only)
251*cdf0e10cSrcweir  *  hWndAssoc       HWND to set as the associate.
252*cdf0e10cSrcweir  *
253*cdf0e10cSrcweir  * Return Value:
254*cdf0e10cSrcweir  *  HWND            Previous (Set) or current (Get) associate
255*cdf0e10cSrcweir  *                  window.
256*cdf0e10cSrcweir  */
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir HWND CHatchWin::HwndAssociateSet(HWND hWndAssoc)
259*cdf0e10cSrcweir {
260*cdf0e10cSrcweir     HWND    hWndT=m_hWndAssociate;
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     m_hWndAssociate=hWndAssoc;
263*cdf0e10cSrcweir     return hWndT;
264*cdf0e10cSrcweir }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir HWND CHatchWin::HwndAssociateGet(void)
268*cdf0e10cSrcweir {
269*cdf0e10cSrcweir     return m_hWndAssociate;
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir /*
274*cdf0e10cSrcweir  * CHatchWin::RectsSet
275*cdf0e10cSrcweir  *
276*cdf0e10cSrcweir  * Purpose:
277*cdf0e10cSrcweir  *  Changes the size and position of the hatch window and the child
278*cdf0e10cSrcweir  *  window within it using a position rectangle for the child and
279*cdf0e10cSrcweir  *  a clipping rectangle for the hatch window and child.  The hatch
280*cdf0e10cSrcweir  *  window occupies prcPos expanded by the hatch border and clipped
281*cdf0e10cSrcweir  *  by prcClip.  The child window is fit to prcPos to give the
282*cdf0e10cSrcweir  *  proper scaling, but it clipped to the hatch window which
283*cdf0e10cSrcweir  *  therefore clips it to prcClip without affecting the scaling.
284*cdf0e10cSrcweir  *
285*cdf0e10cSrcweir  * Parameters:
286*cdf0e10cSrcweir  *  prcPos          LPRECT providing the position rectangle.
287*cdf0e10cSrcweir  *  prcClip         LPRECT providing the clipping rectangle.
288*cdf0e10cSrcweir  *
289*cdf0e10cSrcweir  * Return Value:
290*cdf0e10cSrcweir  *  None
291*cdf0e10cSrcweir  */
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir void CHatchWin::RectsSet(LPRECT prcPos, LPRECT prcClip)
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir     RECT    rc;
296*cdf0e10cSrcweir     RECT    rcPos;
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     m_rcPos=*prcPos;
299*cdf0e10cSrcweir     m_rcClip=*prcClip;
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     //Calculate the rectangle for the hatch window, then clip it.
302*cdf0e10cSrcweir     rcPos=*prcPos;
303*cdf0e10cSrcweir     InflateRect(&rcPos, m_dBorder, m_dBorder);
304*cdf0e10cSrcweir     IntersectRect(&rc, &rcPos, prcClip);
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir     SetWindowPos(m_hWnd, NULL, rc.left, rc.top, rc.right-rc.left
307*cdf0e10cSrcweir                  , rc.bottom-rc.top, SWP_NOZORDER | SWP_NOACTIVATE);
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir     /*
310*cdf0e10cSrcweir      * Set the rectangle of the child window to be at m_dBorder
311*cdf0e10cSrcweir      * from the top and left but with the same size as prcPos
312*cdf0e10cSrcweir      * contains.  The hatch window will clip it.
313*cdf0e10cSrcweir      */
314*cdf0e10cSrcweir //     SetWindowPos(m_hWndKid, NULL, rcPos.left-rc.left+m_dBorder
315*cdf0e10cSrcweir //                  , rcPos.top-rc.top+m_dBorder, prcPos->right-prcPos->left
316*cdf0e10cSrcweir //                  , prcPos->bottom-prcPos->top, SWP_NOZORDER | SWP_NOACTIVATE);
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir     RECT newRC;
319*cdf0e10cSrcweir     GetClientRect(m_hWnd,&newRC);
320*cdf0e10cSrcweir     m_aTracker = Tracker(
321*cdf0e10cSrcweir         &newRC,
322*cdf0e10cSrcweir         Tracker::hatchInside |
323*cdf0e10cSrcweir         Tracker::hatchedBorder |
324*cdf0e10cSrcweir         Tracker::resizeInside
325*cdf0e10cSrcweir     );
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir     return;
328*cdf0e10cSrcweir }
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir /*
333*cdf0e10cSrcweir  * CHatchWin::ChildSet
334*cdf0e10cSrcweir  *
335*cdf0e10cSrcweir  * Purpose:
336*cdf0e10cSrcweir  *  Assigns a child window to this hatch window.
337*cdf0e10cSrcweir  *
338*cdf0e10cSrcweir  * Parameters:
339*cdf0e10cSrcweir  *  hWndKid         HWND of the child window.
340*cdf0e10cSrcweir  *
341*cdf0e10cSrcweir  * Return Value:
342*cdf0e10cSrcweir  *  None
343*cdf0e10cSrcweir  */
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir void CHatchWin::ChildSet(HWND hWndKid)
346*cdf0e10cSrcweir {
347*cdf0e10cSrcweir     m_hWndKid=hWndKid;
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir     if (NULL!=hWndKid)
350*cdf0e10cSrcweir     {
351*cdf0e10cSrcweir         SetParent(hWndKid, m_hWnd);
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir         //Insure this is visible when the hatch window becomes visible.
354*cdf0e10cSrcweir         ShowWindow(hWndKid, SW_SHOW);
355*cdf0e10cSrcweir     }
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir     return;
358*cdf0e10cSrcweir }
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir /*
363*cdf0e10cSrcweir  * CHatchWin::ShowHatch
364*cdf0e10cSrcweir  *
365*cdf0e10cSrcweir  * Purpose:
366*cdf0e10cSrcweir  *  Turns hatching on and off; turning the hatching off changes
367*cdf0e10cSrcweir  *  the size of the window to be exactly that of the child, leaving
368*cdf0e10cSrcweir  *  everything else the same.  The result is that we don't have
369*cdf0e10cSrcweir  *  to turn off drawing because our own WM_PAINT will never be
370*cdf0e10cSrcweir  *  called.
371*cdf0e10cSrcweir  *
372*cdf0e10cSrcweir  * Parameters:
373*cdf0e10cSrcweir  *  fHatch          BOOL indicating to show (TRUE) or hide (FALSE)
374*cdf0e10cSrcweir                     the hatching.
375*cdf0e10cSrcweir  *
376*cdf0e10cSrcweir  * Return Value:
377*cdf0e10cSrcweir  *  None
378*cdf0e10cSrcweir  */
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir void CHatchWin::ShowHatch(BOOL fHatch)
381*cdf0e10cSrcweir {
382*cdf0e10cSrcweir     /*
383*cdf0e10cSrcweir      * All we have to do is set the border to zero and
384*cdf0e10cSrcweir      * call SetRects again with the last rectangles the
385*cdf0e10cSrcweir      * child sent to us.
386*cdf0e10cSrcweir      */
387*cdf0e10cSrcweir     m_dBorder=fHatch ? m_dBorderOrg : 0;
388*cdf0e10cSrcweir     RectsSet(&m_rcPos, &m_rcClip);
389*cdf0e10cSrcweir     return;
390*cdf0e10cSrcweir }
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir /*
395*cdf0e10cSrcweir  * HatchWndProc
396*cdf0e10cSrcweir  *
397*cdf0e10cSrcweir  * Purpose:
398*cdf0e10cSrcweir  *  Standard window procedure for the Hatch Window
399*cdf0e10cSrcweir  */
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir LRESULT APIENTRY winwrap::HatchWndProc(
402*cdf0e10cSrcweir     HWND hWnd, UINT iMsg
403*cdf0e10cSrcweir     , WPARAM wParam, LPARAM lParam)
404*cdf0e10cSrcweir {
405*cdf0e10cSrcweir     PCHatchWin  phw;
406*cdf0e10cSrcweir     HDC         hDC;
407*cdf0e10cSrcweir     PAINTSTRUCT ps;
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir     phw=(PCHatchWin)GetWindowLong(hWnd, HWWL_STRUCTURE);
410*cdf0e10cSrcweir     POINT ptMouse;
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir     switch (iMsg)
413*cdf0e10cSrcweir     {
414*cdf0e10cSrcweir         case WM_CREATE:
415*cdf0e10cSrcweir             phw=(PCHatchWin)((LPCREATESTRUCT)lParam)->lpCreateParams;
416*cdf0e10cSrcweir             SetWindowLong(hWnd, HWWL_STRUCTURE, (LONG)phw);
417*cdf0e10cSrcweir             break;
418*cdf0e10cSrcweir         case WM_PAINT:
419*cdf0e10cSrcweir             hDC=BeginPaint(hWnd,&ps);
420*cdf0e10cSrcweir             //Always draw the hatching.
421*cdf0e10cSrcweir             phw->m_aTracker.Draw(hDC);
422*cdf0e10cSrcweir             EndPaint(hWnd,&ps);
423*cdf0e10cSrcweir             break;
424*cdf0e10cSrcweir         case WM_LBUTTONDOWN:
425*cdf0e10cSrcweir             GetCursorPos(&ptMouse);
426*cdf0e10cSrcweir             ScreenToClient(hWnd,&ptMouse);
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir             // track in case we have to
429*cdf0e10cSrcweir             if(phw->m_aTracker.Track(hWnd,ptMouse,FALSE,GetParent(hWnd)))
430*cdf0e10cSrcweir             {
431*cdf0e10cSrcweir                 RECT aRect = phw->m_aTracker.m_rect;
432*cdf0e10cSrcweir                 TransformRect(&aRect,hWnd,GetParent(hWnd));
433*cdf0e10cSrcweir                 phw->m_pDocHolder->OnPosRectChanged(&aRect);
434*cdf0e10cSrcweir             }
435*cdf0e10cSrcweir             break;
436*cdf0e10cSrcweir 		case WM_LBUTTONUP:
437*cdf0e10cSrcweir         case WM_MOUSEMOVE:
438*cdf0e10cSrcweir             GetCursorPos(&ptMouse);
439*cdf0e10cSrcweir             ScreenToClient(hWnd,&ptMouse);
440*cdf0e10cSrcweir             phw->m_aTracker.SetCursor(hWnd,HTCLIENT);
441*cdf0e10cSrcweir             break;
442*cdf0e10cSrcweir         case WM_SETFOCUS:
443*cdf0e10cSrcweir             //We need this since the container will SetFocus to us.
444*cdf0e10cSrcweir             if (NULL!=phw->m_hWndKid)
445*cdf0e10cSrcweir                 SetFocus(phw->m_hWndKid);
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir             break;
448*cdf0e10cSrcweir         case WM_LBUTTONDBLCLK:
449*cdf0e10cSrcweir             /*
450*cdf0e10cSrcweir              * If the double click was within m_dBorder of an
451*cdf0e10cSrcweir              * edge, send the HWN_BORDERDOUBLECLICKED notification.
452*cdf0e10cSrcweir              *
453*cdf0e10cSrcweir              * Because we're always sized just larger than our child
454*cdf0e10cSrcweir              * window by the border width, we can only *get* this
455*cdf0e10cSrcweir              * message when the mouse is on the border.  So we can
456*cdf0e10cSrcweir              * just send the notification.
457*cdf0e10cSrcweir              */
458*cdf0e10cSrcweir             if (NULL!=phw->m_hWndAssociate)
459*cdf0e10cSrcweir             {
460*cdf0e10cSrcweir                 SendCommand(phw->m_hWndAssociate, phw->m_uID
461*cdf0e10cSrcweir                             , HWN_BORDERDOUBLECLICKED, hWnd);
462*cdf0e10cSrcweir             }
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir             break;
465*cdf0e10cSrcweir         default:
466*cdf0e10cSrcweir             return DefWindowProc(hWnd, iMsg, wParam, lParam);
467*cdf0e10cSrcweir     }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir     return 0L;
470*cdf0e10cSrcweir }
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir // Fix strange warnings about some
473*cdf0e10cSrcweir // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
474*cdf0e10cSrcweir // warning C4505: 'xxx' : unreferenced local function has been removed
475*cdf0e10cSrcweir #if defined(_MSC_VER)
476*cdf0e10cSrcweir #pragma warning(disable: 4505)
477*cdf0e10cSrcweir #endif
478