2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
23 ==============================================================================
29 #if JUCE_WINDOWS || DOXYGEN
31 //==============================================================================
33 A Windows-specific class that can create and embed a HWND inside itself.
35 To use it, create one of these, put it in place and make sure it's visible in a
36 window, then use setHWND() to assign a HWND to it. The window will then be
37 moved and resized to follow the movements of this component.
39 Of course, since the window is a native object, it'll obliterate any
40 JUCE components that may overlap this component, but that's life.
44 class JUCE_API HWNDComponent
: public Component
47 //==============================================================================
48 /** Create an initially-empty container. */
52 ~HWNDComponent() override
;
54 /** Assigns a HWND to this peer.
56 The window will be retained and released by this component for as long as
57 it is needed. To remove the current HWND, just call setHWND (nullptr).
59 Note: A void* is used here to avoid including the Windows headers as
60 part of JuceHeader.h, but the method expects a HWND.
62 void setHWND (void* hwnd
);
64 /** Returns the current HWND.
66 Note: A void* is returned here to avoid the needing to include the Windows
67 headers, so you should just cast the return value to a HWND.
69 void* getHWND() const;
71 /** Resizes this component to fit the HWND that it contains. */
74 /** Forces the bounds of the HWND to match the bounds of this component. */
75 void updateHWNDBounds();
78 void paint (Graphics
&) override
;
82 std::unique_ptr
<Pimpl
> pimpl
;
84 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HWNDComponent
)