The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. #if JUCE_WINDOWS || DOXYGEN
  19. //==============================================================================
  20. /**
  21. A Windows-specific class that can create and embed an ActiveX control inside
  22. itself.
  23. To use it, create one of these, put it in place and make sure it's visible in a
  24. window, then use createControl() to instantiate an ActiveX control. The control
  25. will then be moved and resized to follow the movements of this component.
  26. Of course, since the control is a heavyweight window, it'll obliterate any
  27. juce components that may overlap this component, but that's life.
  28. */
  29. class JUCE_API ActiveXControlComponent : public Component
  30. {
  31. public:
  32. //==============================================================================
  33. /** Create an initially-empty container. */
  34. ActiveXControlComponent();
  35. /** Destructor. */
  36. ~ActiveXControlComponent();
  37. /** Tries to create an ActiveX control and embed it in this peer.
  38. The peer controlIID is a pointer to an IID structure - it's treated
  39. as a void* because when including the Juce headers, you might not always
  40. have included windows.h first, in which case IID wouldn't be defined.
  41. e.g. @code
  42. const IID myIID = __uuidof (QTControl);
  43. myControlComp->createControl (&myIID);
  44. @endcode
  45. */
  46. bool createControl (const void* controlIID);
  47. /** Deletes the ActiveX control, if one has been created.
  48. */
  49. void deleteControl();
  50. /** Returns true if a control is currently in use. */
  51. bool isControlOpen() const noexcept { return control != nullptr; }
  52. /** Does a QueryInterface call on the embedded control object.
  53. This allows you to cast the control to whatever type of COM object you need.
  54. The iid parameter is a pointer to an IID structure - it's treated
  55. as a void* because when including the Juce headers, you might not always
  56. have included windows.h first, in which case IID wouldn't be defined, but
  57. you should just pass a pointer to an IID.
  58. e.g. @code
  59. const IID iid = __uuidof (IOleWindow);
  60. IOleWindow* oleWindow = (IOleWindow*) myControlComp->queryInterface (&iid);
  61. if (oleWindow != nullptr)
  62. {
  63. HWND hwnd;
  64. oleWindow->GetWindow (&hwnd);
  65. ...
  66. oleWindow->Release();
  67. }
  68. @endcode
  69. */
  70. void* queryInterface (const void* iid) const;
  71. /** Set this to false to stop mouse events being allowed through to the control.
  72. */
  73. void setMouseEventsAllowed (bool eventsCanReachControl);
  74. /** Returns true if mouse events are allowed to get through to the control.
  75. */
  76. bool areMouseEventsAllowed() const noexcept { return mouseEventsAllowed; }
  77. //==============================================================================
  78. /** @internal */
  79. void paint (Graphics&) override;
  80. private:
  81. class Pimpl;
  82. friend struct ContainerDeletePolicy<Pimpl>;
  83. ScopedPointer<Pimpl> control;
  84. bool mouseEventsAllowed;
  85. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ActiveXControlComponent)
  86. };
  87. #endif