# FarPoint.Win.PopupWindowHelper

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="FarPoint_Win_PopupWindowHelper" data-uid="FarPoint.Win.PopupWindowHelper" class="text-break">PopupWindowHelper Class
</h1>
  <div class="markdown level0 summary"><p>A class to assist in creating popup windows like combo box drop-downs and menus.
This class includes functionality to keep the title bar of the popup owner form
active while the popup is displayed, and to automatically cancel the popup
whenever the user clicks outside the popup window or shifts focus to another
application.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject">MarshalByRefObject</a></div>
    <div class="level2"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.forms.nativewindow">NativeWindow</a></div>
    <div class="level3"><span class="xref">PopupWindowHelper</span></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.forms.iwin32window">IWin32Window</a></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="FarPoint.Win.html">FarPoint.Win</a></h6>
  <h6><strong>Assembly</strong>: FarPoint.Win.dll</h6>
  <h5 id="FarPoint_Win_PopupWindowHelper_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class PopupWindowHelper : NativeWindow, IWin32Window</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class PopupWindowHelper
    Inherits NativeWindow
    Implements IWin32Window</code></pre>
  </div>
  <h3 id="constructors">Constructors
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="FarPoint_Win_PopupWindowHelper__ctor_System_Windows_Forms_Control_" data-uid="FarPoint.Win.PopupWindowHelper.#ctor(System.Windows.Forms.Control)">
          <a class="xref" href="FarPoint.Win.PopupWindowHelper.-ctor.html#FarPoint_Win_PopupWindowHelper__ctor_System_Windows_Forms_Control_">PopupWindowHelper(Control)</a>
        </td>
        <td class="markdown level1 summary"><p>Default constructor.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="FarPoint_Win_PopupWindowHelper_ClosePopup" data-uid="FarPoint.Win.PopupWindowHelper.ClosePopup">
          <a class="xref" href="FarPoint.Win.PopupWindowHelper.ClosePopup.html#FarPoint_Win_PopupWindowHelper_ClosePopup">ClosePopup()</a>
        </td>
        <td class="markdown level1 summary"><p>Called when the popup is being hidden.</p>
</td>
      </tr>
      <tr>
        <td id="FarPoint_Win_PopupWindowHelper_OnPopupCancel_FarPoint_Win_PopupCancelEventArgs_" data-uid="FarPoint.Win.PopupWindowHelper.OnPopupCancel(FarPoint.Win.PopupCancelEventArgs)">
          <a class="xref" href="FarPoint.Win.PopupWindowHelper.OnPopupCancel.html#FarPoint_Win_PopupWindowHelper_OnPopupCancel_FarPoint_Win_PopupCancelEventArgs_">OnPopupCancel(PopupCancelEventArgs)</a>
        </td>
        <td class="markdown level1 summary"><p>Raises the <a class="xref" href="FarPoint.Win.PopupWindowHelper.PopupCancel.html">PopupCancel</a> event.</p>
</td>
      </tr>
      <tr>
        <td id="FarPoint_Win_PopupWindowHelper_OnPopupClosed_FarPoint_Win_PopupClosedEventArgs_" data-uid="FarPoint.Win.PopupWindowHelper.OnPopupClosed(FarPoint.Win.PopupClosedEventArgs)">
          <a class="xref" href="FarPoint.Win.PopupWindowHelper.OnPopupClosed.html#FarPoint_Win_PopupWindowHelper_OnPopupClosed_FarPoint_Win_PopupClosedEventArgs_">OnPopupClosed(PopupClosedEventArgs)</a>
        </td>
        <td class="markdown level1 summary"><p>Raises the <a class="xref" href="FarPoint.Win.PopupWindowHelper.PopupClosed.html">PopupClosed</a> event.</p>
</td>
      </tr>
      <tr>
        <td id="FarPoint_Win_PopupWindowHelper_ShowPopup_System_Windows_Forms_Control_System_Windows_Forms_Form_System_Drawing_Point_" data-uid="FarPoint.Win.PopupWindowHelper.ShowPopup(System.Windows.Forms.Control,System.Windows.Forms.Form,System.Drawing.Point)">
          <a class="xref" href="FarPoint.Win.PopupWindowHelper.ShowPopup.html#FarPoint_Win_PopupWindowHelper_ShowPopup_System_Windows_Forms_Control_System_Windows_Forms_Form_System_Drawing_Point_">ShowPopup(Control, Form, Point)</a>
        </td>
        <td class="markdown level1 summary"><p>Shows the specified Form as a popup window, keeping the
Owner's title bar active and preparing to cancel the popup
should the user click anywhere outside the popup window.</p>
<p>Typical code to use this message is as follows:</p><pre><code class="lang-csharp">frmPopup popup = new frmPopup();
                                                      Point location = this.PointToScreen(new Point(button1.Left, button1.Bottom));
                                                      popupHelper.ShowPopup(this, popup, location);</code></pre><p>Put as much initialization code as possible
into the popup form's constructor, rather than the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.forms.form.load">Load</a>
event as this will improve the visual appearance.</p>
</td>
      </tr>
      <tr>
        <td id="FarPoint_Win_PopupWindowHelper_WndProc_System_Windows_Forms_Message__" data-uid="FarPoint.Win.PopupWindowHelper.WndProc(System.Windows.Forms.Message@)">
          <a class="xref" href="FarPoint.Win.PopupWindowHelper.WndProc.html#FarPoint_Win_PopupWindowHelper_WndProc_System_Windows_Forms_Message__">WndProc(ref Message)</a>
        </td>
        <td class="markdown level1 summary"><p>Subclasses the owning form's existing Window Procedure to enables the
title bar to remain active when a popup is show, and to detect if
the user clicks onto another application whilst the popup is visible.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="events">Events
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="FarPoint_Win_PopupWindowHelper_PopupCancel" data-uid="FarPoint.Win.PopupWindowHelper.PopupCancel">
          <a class="xref" href="FarPoint.Win.PopupWindowHelper.PopupCancel.html">PopupCancel</a>
        </td>
        <td class="markdown level1 summary"><p>Raised when the Popup Window is about to be cancelled.  The
<a class="xref" href="FarPoint.Win.PopupCancelEventArgs.Cancel.html#FarPoint_Win_PopupCancelEventArgs_Cancel">Cancel</a> property can be
set to <code>true</code> to prevent the form from being cancelled.</p>
</td>
      </tr>
      <tr>
        <td id="FarPoint_Win_PopupWindowHelper_PopupClosed" data-uid="FarPoint.Win.PopupWindowHelper.PopupClosed">
          <a class="xref" href="FarPoint.Win.PopupWindowHelper.PopupClosed.html">PopupClosed</a>
        </td>
        <td class="markdown level1 summary"><p>Raised when the popup form is closed.</p>
</td>
      </tr>
    </tbody>
  </table>

</div>
