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