2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 // (these functions are in their own file because of problems including windows.h
27 // at the same time as the Digi headers)
31 #define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY // (workaround for a VC build problem)
35 #pragma pack (push, 8)
36 #include "../juce_PluginHeaders.h"
39 #if JucePlugin_Build_RTAS
41 //==============================================================================
42 void JUCE_CALLTYPE
attachSubWindow (void* hostWindow
,
43 int& titleW
, int& titleH
,
47 GetClientRect ((HWND
) hostWindow
, &clientRect
);
49 titleW
= clientRect
.right
- clientRect
.left
;
50 titleH
= jmax (0, (int) (clientRect
.bottom
- clientRect
.top
) - comp
->getHeight());
51 comp
->setTopLeftPosition (0, titleH
);
53 comp
->addToDesktop (0);
55 HWND plugWnd
= (HWND
) comp
->getWindowHandle();
56 SetParent (plugWnd
, (HWND
) hostWindow
);
58 DWORD val
= GetWindowLong (plugWnd
, GWL_STYLE
);
59 val
= (val
& ~WS_POPUP
) | WS_CHILD
;
60 SetWindowLong (plugWnd
, GWL_STYLE
, val
);
62 val
= GetWindowLong ((HWND
) hostWindow
, GWL_STYLE
);
63 SetWindowLong ((HWND
) hostWindow
, GWL_STYLE
, val
| WS_CLIPCHILDREN
);
66 void JUCE_CALLTYPE
resizeHostWindow (void* hostWindow
,
67 int& titleW
, int& titleH
,
70 RECT clientRect
, windowRect
;
71 GetClientRect ((HWND
) hostWindow
, &clientRect
);
72 GetWindowRect ((HWND
) hostWindow
, &windowRect
);
73 const int borderW
= (windowRect
.right
- windowRect
.left
) - (clientRect
.right
- clientRect
.left
);
74 const int borderH
= (windowRect
.bottom
- windowRect
.top
) - (clientRect
.bottom
- clientRect
.top
);
76 SetWindowPos ((HWND
) hostWindow
, 0, 0, 0,
77 borderW
+ jmax (titleW
, comp
->getWidth()),
78 borderH
+ comp
->getHeight() + titleH
,
79 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOOWNERZORDER
);
82 #if ! JucePlugin_EditorRequiresKeyboardFocus
86 HWND
findMDIParentOf (HWND w
)
88 const int frameThickness
= GetSystemMetrics (SM_CYFIXEDFRAME
);
92 HWND parent
= GetParent (w
);
97 TCHAR windowType
[32] = { 0 };
98 GetClassName (parent
, windowType
, 31);
100 if (String (windowType
).equalsIgnoreCase ("MDIClient"))
106 RECT windowPos
, parentPos
;
107 GetWindowRect (w
, &windowPos
);
108 GetWindowRect (parent
, &parentPos
);
110 int dw
= (parentPos
.right
- parentPos
.left
) - (windowPos
.right
- windowPos
.left
);
111 int dh
= (parentPos
.bottom
- parentPos
.top
) - (windowPos
.bottom
- windowPos
.top
);
113 if (dw
> 100 || dh
> 100)
118 if (dw
== 2 * frameThickness
)
126 void JUCE_CALLTYPE
passFocusToHostWindow (void* hostWindow
)
128 SetFocus (findMDIParentOf ((HWND
) hostWindow
));