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.

126 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #if JUCE_WINDOWS || DOXYGEN
  21. //==============================================================================
  22. /**
  23. A Windows-specific class that can create and embed an ActiveX control inside
  24. itself.
  25. To use it, create one of these, put it in place and make sure it's visible in a
  26. window, then use createControl() to instantiate an ActiveX control. The control
  27. will then be moved and resized to follow the movements of this component.
  28. Of course, since the control is a heavyweight window, it'll obliterate any
  29. juce components that may overlap this component, but that's life.
  30. */
  31. class JUCE_API ActiveXControlComponent : public Component
  32. {
  33. public:
  34. //==============================================================================
  35. /** Create an initially-empty container. */
  36. ActiveXControlComponent();
  37. /** Destructor. */
  38. ~ActiveXControlComponent();
  39. /** Tries to create an ActiveX control and embed it in this peer.
  40. The peer controlIID is a pointer to an IID structure - it's treated
  41. as a void* because when including the Juce headers, you might not always
  42. have included windows.h first, in which case IID wouldn't be defined.
  43. e.g. @code
  44. const IID myIID = __uuidof (QTControl);
  45. myControlComp->createControl (&myIID);
  46. @endcode
  47. */
  48. bool createControl (const void* controlIID);
  49. /** Deletes the ActiveX control, if one has been created.
  50. */
  51. void deleteControl();
  52. /** Returns true if a control is currently in use. */
  53. bool isControlOpen() const noexcept { return control != nullptr; }
  54. /** Does a QueryInterface call on the embedded control object.
  55. This allows you to cast the control to whatever type of COM object you need.
  56. The iid parameter is a pointer to an IID structure - it's treated
  57. as a void* because when including the Juce headers, you might not always
  58. have included windows.h first, in which case IID wouldn't be defined, but
  59. you should just pass a pointer to an IID.
  60. e.g. @code
  61. const IID iid = __uuidof (IOleWindow);
  62. IOleWindow* oleWindow = (IOleWindow*) myControlComp->queryInterface (&iid);
  63. if (oleWindow != nullptr)
  64. {
  65. HWND hwnd;
  66. oleWindow->GetWindow (&hwnd);
  67. ...
  68. oleWindow->Release();
  69. }
  70. @endcode
  71. */
  72. void* queryInterface (const void* iid) const;
  73. /** Set this to false to stop mouse events being allowed through to the control.
  74. */
  75. void setMouseEventsAllowed (bool eventsCanReachControl);
  76. /** Returns true if mouse events are allowed to get through to the control.
  77. */
  78. bool areMouseEventsAllowed() const noexcept { return mouseEventsAllowed; }
  79. //==============================================================================
  80. /** @internal */
  81. void paint (Graphics&) override;
  82. /** @internal */
  83. intptr_t offerEventToActiveXControl (void*);
  84. static intptr_t offerEventToActiveXControlStatic (void*);
  85. private:
  86. class Pimpl;
  87. friend struct ContainerDeletePolicy<Pimpl>;
  88. ScopedPointer<Pimpl> control;
  89. bool mouseEventsAllowed = true;
  90. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ActiveXControlComponent)
  91. };
  92. #endif